Move definition of struct sched_attr to a separate header file
Avoid multiple defintions of struct sched_attr by creating a separate header file with its definition and using it in other places. * sched_attr.h: New file. * Makefile.am (strace_SOURCES): Add it. * sched.c: Include it. (print_sched_attr): Use it. * tests/sched_xetattr.c: Include it. (main): Use it.
This commit is contained in:
parent
6e9ad7be61
commit
3e80074350
@ -211,6 +211,7 @@ strace_SOURCES = \
|
|||||||
resource.c \
|
resource.c \
|
||||||
rtc.c \
|
rtc.c \
|
||||||
sched.c \
|
sched.c \
|
||||||
|
sched_attr.h \
|
||||||
scsi.c \
|
scsi.c \
|
||||||
seccomp.c \
|
seccomp.c \
|
||||||
seccomp_fprog.h \
|
seccomp_fprog.h \
|
||||||
|
12
sched.c
12
sched.c
@ -30,6 +30,7 @@
|
|||||||
#include "defs.h"
|
#include "defs.h"
|
||||||
|
|
||||||
#include <sched.h>
|
#include <sched.h>
|
||||||
|
#include "sched_attr.h"
|
||||||
|
|
||||||
#include "xlat/schedulers.h"
|
#include "xlat/schedulers.h"
|
||||||
#include "xlat/sched_flags.h"
|
#include "xlat/sched_flags.h"
|
||||||
@ -97,16 +98,7 @@ static void
|
|||||||
print_sched_attr(struct tcb *const tcp, const kernel_ulong_t addr,
|
print_sched_attr(struct tcb *const tcp, const kernel_ulong_t addr,
|
||||||
unsigned int size)
|
unsigned int size)
|
||||||
{
|
{
|
||||||
struct {
|
struct sched_attr attr = {};
|
||||||
uint32_t size;
|
|
||||||
uint32_t sched_policy;
|
|
||||||
uint64_t sched_flags;
|
|
||||||
uint32_t sched_nice;
|
|
||||||
uint32_t sched_priority;
|
|
||||||
uint64_t sched_runtime;
|
|
||||||
uint64_t sched_deadline;
|
|
||||||
uint64_t sched_period;
|
|
||||||
} attr = {};
|
|
||||||
|
|
||||||
if (size > sizeof(attr))
|
if (size > sizeof(attr))
|
||||||
size = sizeof(attr);
|
size = sizeof(attr);
|
||||||
|
19
sched_attr.h
Normal file
19
sched_attr.h
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
#ifndef STRACE_SCHED_ATTR_H
|
||||||
|
#define STRACE_SCHED_ATTR_H
|
||||||
|
|
||||||
|
# include <stdint.h>
|
||||||
|
|
||||||
|
struct sched_attr {
|
||||||
|
uint32_t size;
|
||||||
|
uint32_t sched_policy;
|
||||||
|
uint64_t sched_flags;
|
||||||
|
uint32_t sched_nice;
|
||||||
|
uint32_t sched_priority;
|
||||||
|
uint64_t sched_runtime;
|
||||||
|
uint64_t sched_deadline;
|
||||||
|
uint64_t sched_period;
|
||||||
|
};
|
||||||
|
|
||||||
|
# define SCHED_ATTR_MIN_SIZE 48
|
||||||
|
|
||||||
|
#endif /* !STRACE_SCHED_ATTR_H */
|
@ -34,6 +34,7 @@
|
|||||||
# include <stdio.h>
|
# include <stdio.h>
|
||||||
# include <sched.h>
|
# include <sched.h>
|
||||||
# include <unistd.h>
|
# include <unistd.h>
|
||||||
|
# include "sched_attr.h"
|
||||||
# include "xlat.h"
|
# include "xlat.h"
|
||||||
# include "xlat/schedulers.h"
|
# include "xlat/schedulers.h"
|
||||||
|
|
||||||
@ -66,16 +67,7 @@ main(void)
|
|||||||
static const kernel_ulong_t bogus_flags =
|
static const kernel_ulong_t bogus_flags =
|
||||||
(kernel_ulong_t) 0xdefaceddeadc0deULL;
|
(kernel_ulong_t) 0xdefaceddeadc0deULL;
|
||||||
|
|
||||||
struct {
|
struct sched_attr *const attr = tail_alloc(sizeof(*attr));
|
||||||
uint32_t size;
|
|
||||||
uint32_t sched_policy;
|
|
||||||
uint64_t sched_flags;
|
|
||||||
int32_t sched_nice;
|
|
||||||
uint32_t sched_priority;
|
|
||||||
uint64_t sched_runtime;
|
|
||||||
uint64_t sched_deadline;
|
|
||||||
uint64_t sched_period;
|
|
||||||
} *const attr = tail_alloc(sizeof(*attr));
|
|
||||||
void *const efault = attr + 1;
|
void *const efault = attr + 1;
|
||||||
|
|
||||||
sys_sched_getattr(bogus_pid, 0, 0, 0);
|
sys_sched_getattr(bogus_pid, 0, 0, 0);
|
||||||
|
Loading…
Reference in New Issue
Block a user