2011-02-12 05:22:29 +00:00
|
|
|
#ifndef _SCHED_H
|
|
|
|
#define _SCHED_H
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2012-09-08 03:13:55 +00:00
|
|
|
#include <features.h>
|
|
|
|
|
2011-02-12 05:22:29 +00:00
|
|
|
#define __NEED_struct_timespec
|
|
|
|
#define __NEED_pid_t
|
|
|
|
#define __NEED_time_t
|
|
|
|
|
2013-08-11 01:15:11 +00:00
|
|
|
#ifdef _GNU_SOURCE
|
|
|
|
#define __NEED_size_t
|
|
|
|
#endif
|
|
|
|
|
2011-02-12 05:22:29 +00:00
|
|
|
#include <bits/alltypes.h>
|
|
|
|
|
|
|
|
struct sched_param {
|
|
|
|
int sched_priority;
|
2019-08-15 00:50:42 +00:00
|
|
|
int __reserved1;
|
2019-08-10 02:20:55 +00:00
|
|
|
#if _REDIR_TIME64
|
|
|
|
long __reserved2[4];
|
|
|
|
#else
|
2019-08-15 00:50:42 +00:00
|
|
|
struct {
|
|
|
|
time_t __reserved1;
|
|
|
|
long __reserved2;
|
|
|
|
} __reserved2[2];
|
2019-08-10 02:20:55 +00:00
|
|
|
#endif
|
2019-08-15 00:50:42 +00:00
|
|
|
int __reserved3;
|
2011-02-12 05:22:29 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
int sched_get_priority_max(int);
|
|
|
|
int sched_get_priority_min(int);
|
|
|
|
int sched_getparam(pid_t, struct sched_param *);
|
|
|
|
int sched_getscheduler(pid_t);
|
|
|
|
int sched_rr_get_interval(pid_t, struct timespec *);
|
|
|
|
int sched_setparam(pid_t, const struct sched_param *);
|
|
|
|
int sched_setscheduler(pid_t, int, const struct sched_param *);
|
|
|
|
int sched_yield(void);
|
|
|
|
|
|
|
|
#define SCHED_OTHER 0
|
|
|
|
#define SCHED_FIFO 1
|
|
|
|
#define SCHED_RR 2
|
2012-11-11 20:38:04 +00:00
|
|
|
#define SCHED_BATCH 3
|
|
|
|
#define SCHED_IDLE 5
|
2014-05-30 11:47:44 +00:00
|
|
|
#define SCHED_DEADLINE 6
|
2012-11-11 20:38:04 +00:00
|
|
|
#define SCHED_RESET_ON_FORK 0x40000000
|
2011-02-12 05:22:29 +00:00
|
|
|
|
overhaul clone syscall wrapping
several things are changed. first, i have removed the old __uniclone
function signature and replaced it with the "standard" linux
__clone/clone signature. this was necessary to expose clone to
applications anyway, and it makes it easier to port __clone to new
archs, since it's now testable independently of pthread_create.
secondly, i have removed all references to the ugly ldt descriptor
structure (i386 only) from the c code and pthread structure. in places
where it is needed, it is now created on the stack just when it's
needed, in assembly code. thus, the i386 __clone function takes the
desired thread pointer as its argument, rather than an ldt descriptor
pointer, just like on all other sane archs. this should not affect
applications since there is really no way an application can use clone
with threads/tls in a way that doesn't horribly conflict with and
clobber the underlying implementation's use. applications are expected
to use clone only for creating actual processes, possibly with new
namespace features and whatnot.
2011-09-18 14:14:37 +00:00
|
|
|
#ifdef _GNU_SOURCE
|
|
|
|
#define CSIGNAL 0x000000ff
|
2020-03-31 20:42:14 +00:00
|
|
|
#define CLONE_NEWTIME 0x00000080
|
overhaul clone syscall wrapping
several things are changed. first, i have removed the old __uniclone
function signature and replaced it with the "standard" linux
__clone/clone signature. this was necessary to expose clone to
applications anyway, and it makes it easier to port __clone to new
archs, since it's now testable independently of pthread_create.
secondly, i have removed all references to the ugly ldt descriptor
structure (i386 only) from the c code and pthread structure. in places
where it is needed, it is now created on the stack just when it's
needed, in assembly code. thus, the i386 __clone function takes the
desired thread pointer as its argument, rather than an ldt descriptor
pointer, just like on all other sane archs. this should not affect
applications since there is really no way an application can use clone
with threads/tls in a way that doesn't horribly conflict with and
clobber the underlying implementation's use. applications are expected
to use clone only for creating actual processes, possibly with new
namespace features and whatnot.
2011-09-18 14:14:37 +00:00
|
|
|
#define CLONE_VM 0x00000100
|
|
|
|
#define CLONE_FS 0x00000200
|
|
|
|
#define CLONE_FILES 0x00000400
|
|
|
|
#define CLONE_SIGHAND 0x00000800
|
2019-08-12 17:57:42 +00:00
|
|
|
#define CLONE_PIDFD 0x00001000
|
overhaul clone syscall wrapping
several things are changed. first, i have removed the old __uniclone
function signature and replaced it with the "standard" linux
__clone/clone signature. this was necessary to expose clone to
applications anyway, and it makes it easier to port __clone to new
archs, since it's now testable independently of pthread_create.
secondly, i have removed all references to the ugly ldt descriptor
structure (i386 only) from the c code and pthread structure. in places
where it is needed, it is now created on the stack just when it's
needed, in assembly code. thus, the i386 __clone function takes the
desired thread pointer as its argument, rather than an ldt descriptor
pointer, just like on all other sane archs. this should not affect
applications since there is really no way an application can use clone
with threads/tls in a way that doesn't horribly conflict with and
clobber the underlying implementation's use. applications are expected
to use clone only for creating actual processes, possibly with new
namespace features and whatnot.
2011-09-18 14:14:37 +00:00
|
|
|
#define CLONE_PTRACE 0x00002000
|
|
|
|
#define CLONE_VFORK 0x00004000
|
|
|
|
#define CLONE_PARENT 0x00008000
|
|
|
|
#define CLONE_THREAD 0x00010000
|
|
|
|
#define CLONE_NEWNS 0x00020000
|
|
|
|
#define CLONE_SYSVSEM 0x00040000
|
|
|
|
#define CLONE_SETTLS 0x00080000
|
|
|
|
#define CLONE_PARENT_SETTID 0x00100000
|
|
|
|
#define CLONE_CHILD_CLEARTID 0x00200000
|
|
|
|
#define CLONE_DETACHED 0x00400000
|
|
|
|
#define CLONE_UNTRACED 0x00800000
|
|
|
|
#define CLONE_CHILD_SETTID 0x01000000
|
2016-05-26 20:06:44 +00:00
|
|
|
#define CLONE_NEWCGROUP 0x02000000
|
overhaul clone syscall wrapping
several things are changed. first, i have removed the old __uniclone
function signature and replaced it with the "standard" linux
__clone/clone signature. this was necessary to expose clone to
applications anyway, and it makes it easier to port __clone to new
archs, since it's now testable independently of pthread_create.
secondly, i have removed all references to the ugly ldt descriptor
structure (i386 only) from the c code and pthread structure. in places
where it is needed, it is now created on the stack just when it's
needed, in assembly code. thus, the i386 __clone function takes the
desired thread pointer as its argument, rather than an ldt descriptor
pointer, just like on all other sane archs. this should not affect
applications since there is really no way an application can use clone
with threads/tls in a way that doesn't horribly conflict with and
clobber the underlying implementation's use. applications are expected
to use clone only for creating actual processes, possibly with new
namespace features and whatnot.
2011-09-18 14:14:37 +00:00
|
|
|
#define CLONE_NEWUTS 0x04000000
|
|
|
|
#define CLONE_NEWIPC 0x08000000
|
|
|
|
#define CLONE_NEWUSER 0x10000000
|
|
|
|
#define CLONE_NEWPID 0x20000000
|
|
|
|
#define CLONE_NEWNET 0x40000000
|
|
|
|
#define CLONE_IO 0x80000000
|
|
|
|
int clone (int (*)(void *), void *, int, void *, ...);
|
2012-04-29 23:54:03 +00:00
|
|
|
int unshare(int);
|
2012-09-09 00:22:08 +00:00
|
|
|
int setns(int, int);
|
2013-08-11 01:15:11 +00:00
|
|
|
|
|
|
|
void *memcpy(void *__restrict, const void *__restrict, size_t);
|
|
|
|
int memcmp(const void *, const void *, size_t);
|
2017-09-28 16:57:06 +00:00
|
|
|
void *memset (void *, int, size_t);
|
2013-08-11 01:15:11 +00:00
|
|
|
void *calloc(size_t, size_t);
|
|
|
|
void free(void *);
|
|
|
|
|
|
|
|
typedef struct cpu_set_t { unsigned long __bits[128/sizeof(long)]; } cpu_set_t;
|
|
|
|
int __sched_cpucount(size_t, const cpu_set_t *);
|
2016-03-02 16:26:26 +00:00
|
|
|
int sched_getcpu(void);
|
2013-08-11 01:15:11 +00:00
|
|
|
int sched_getaffinity(pid_t, size_t, cpu_set_t *);
|
|
|
|
int sched_setaffinity(pid_t, size_t, const cpu_set_t *);
|
|
|
|
|
2014-02-11 09:51:16 +00:00
|
|
|
#define __CPU_op_S(i, size, set, op) ( (i)/8U >= (size) ? 0 : \
|
2016-09-19 15:15:51 +00:00
|
|
|
(((unsigned long *)(set))[(i)/8/sizeof(long)] op (1UL<<((i)%(8*sizeof(long))))) )
|
2013-08-11 01:15:11 +00:00
|
|
|
|
|
|
|
#define CPU_SET_S(i, size, set) __CPU_op_S(i, size, set, |=)
|
|
|
|
#define CPU_CLR_S(i, size, set) __CPU_op_S(i, size, set, &=~)
|
|
|
|
#define CPU_ISSET_S(i, size, set) __CPU_op_S(i, size, set, &)
|
|
|
|
|
|
|
|
#define __CPU_op_func_S(func, op) \
|
|
|
|
static __inline void __CPU_##func##_S(size_t __size, cpu_set_t *__dest, \
|
|
|
|
const cpu_set_t *__src1, const cpu_set_t *__src2) \
|
|
|
|
{ \
|
|
|
|
size_t __i; \
|
|
|
|
for (__i=0; __i<__size/sizeof(long); __i++) \
|
2016-09-19 15:15:51 +00:00
|
|
|
((unsigned long *)__dest)[__i] = ((unsigned long *)__src1)[__i] \
|
|
|
|
op ((unsigned long *)__src2)[__i] ; \
|
2013-08-11 01:15:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
__CPU_op_func_S(AND, &)
|
|
|
|
__CPU_op_func_S(OR, |)
|
|
|
|
__CPU_op_func_S(XOR, ^)
|
|
|
|
|
|
|
|
#define CPU_AND_S(a,b,c,d) __CPU_AND_S(a,b,c,d)
|
|
|
|
#define CPU_OR_S(a,b,c,d) __CPU_OR_S(a,b,c,d)
|
|
|
|
#define CPU_XOR_S(a,b,c,d) __CPU_XOR_S(a,b,c,d)
|
|
|
|
|
|
|
|
#define CPU_COUNT_S(size,set) __sched_cpucount(size,set)
|
|
|
|
#define CPU_ZERO_S(size,set) memset(set,0,size)
|
|
|
|
#define CPU_EQUAL_S(size,set1,set2) (!memcmp(set1,set2,size))
|
|
|
|
|
|
|
|
#define CPU_ALLOC_SIZE(n) (sizeof(long) * ( (n)/(8*sizeof(long)) \
|
|
|
|
+ ((n)%(8*sizeof(long)) + 8*sizeof(long)-1)/(8*sizeof(long)) ) )
|
|
|
|
#define CPU_ALLOC(n) ((cpu_set_t *)calloc(1,CPU_ALLOC_SIZE(n)))
|
|
|
|
#define CPU_FREE(set) free(set)
|
|
|
|
|
2023-02-23 15:10:44 +00:00
|
|
|
#define CPU_SETSIZE 1024
|
2013-08-11 01:15:11 +00:00
|
|
|
|
|
|
|
#define CPU_SET(i, set) CPU_SET_S(i,sizeof(cpu_set_t),set)
|
|
|
|
#define CPU_CLR(i, set) CPU_CLR_S(i,sizeof(cpu_set_t),set)
|
|
|
|
#define CPU_ISSET(i, set) CPU_ISSET_S(i,sizeof(cpu_set_t),set)
|
|
|
|
#define CPU_AND(d,s1,s2) CPU_AND_S(sizeof(cpu_set_t),d,s1,s2)
|
|
|
|
#define CPU_OR(d,s1,s2) CPU_OR_S(sizeof(cpu_set_t),d,s1,s2)
|
|
|
|
#define CPU_XOR(d,s1,s2) CPU_XOR_S(sizeof(cpu_set_t),d,s1,s2)
|
|
|
|
#define CPU_COUNT(set) CPU_COUNT_S(sizeof(cpu_set_t),set)
|
|
|
|
#define CPU_ZERO(set) CPU_ZERO_S(sizeof(cpu_set_t),set)
|
2014-08-13 14:55:56 +00:00
|
|
|
#define CPU_EQUAL(s1,s2) CPU_EQUAL_S(sizeof(cpu_set_t),s1,s2)
|
2013-08-11 01:15:11 +00:00
|
|
|
|
overhaul clone syscall wrapping
several things are changed. first, i have removed the old __uniclone
function signature and replaced it with the "standard" linux
__clone/clone signature. this was necessary to expose clone to
applications anyway, and it makes it easier to port __clone to new
archs, since it's now testable independently of pthread_create.
secondly, i have removed all references to the ugly ldt descriptor
structure (i386 only) from the c code and pthread structure. in places
where it is needed, it is now created on the stack just when it's
needed, in assembly code. thus, the i386 __clone function takes the
desired thread pointer as its argument, rather than an ldt descriptor
pointer, just like on all other sane archs. this should not affect
applications since there is really no way an application can use clone
with threads/tls in a way that doesn't horribly conflict with and
clobber the underlying implementation's use. applications are expected
to use clone only for creating actual processes, possibly with new
namespace features and whatnot.
2011-09-18 14:14:37 +00:00
|
|
|
#endif
|
|
|
|
|
add time64 symbol name redirects to public headers, under arch control
a _REDIR_TIME64 macro is introduced, which the arch's alltypes.h is
expected to define, to control redirection of symbol names for
interfaces that involve time_t and derived types. this ensures that
object files will only be linked to libc interfaces matching the ABI
whose headers they were compiled against.
along with time32 compat shims, which will be introduced separately,
the redirection also makes it possible for a single libc (static or
shared) to be used with object files produced with either the old
(32-bit time_t) headers or the new ones after 64-bit time_t switchover
takes place. mixing of such object files (or shared libraries) in the
same program will also be possible, but must be done with care; ABI
between libc and a consumer of the libc interfaces is guaranteed to
match by the the symbol name redirection, but pairwise ABI between
consumers of libc that define interfaces between each other in terms
of time_t is not guaranteed to match.
this change adds a dependency on an additional "GNU C" feature to the
public headers for existing 32-bit archs, which is generally
undesirable; however, the feature is one which glibc has depended on
for a long time, and thus which any viable alternative compiler is
going to need to provide. 64-bit archs are not affected, nor will
future 32-bit archs be, regardless of whether they are "new" on the
kernel side (e.g. riscv32) or just newly-added (e.g. a new sparc or
xtensa port). the same applies to newly-added ABIs for existing
machine-level archs.
2019-07-31 19:24:58 +00:00
|
|
|
#if _REDIR_TIME64
|
|
|
|
__REDIR(sched_rr_get_interval, __sched_rr_get_interval_time64);
|
|
|
|
#endif
|
|
|
|
|
2011-02-12 05:22:29 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif
|