diff --git a/src/api/Makefile b/src/api/Makefile index 1c3ab0c..be3671a 100644 --- a/src/api/Makefile +++ b/src/api/Makefile @@ -1,4 +1,5 @@ -CFLAGS+=-std=c99 -Wall -Werror -Wno-unused -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=700 +CFLAGS+=-std=c99 -pedantic-errors -Wall -Werror -Wno-unused -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=700 +#CFLAGS+=-DX_PS -DX_TPS -DX_TYM -DX_RPP_TPP all: for i in *.c; do \ diff --git a/src/api/pthread.c b/src/api/pthread.c index 45210d4..5be34c7 100644 --- a/src/api/pthread.c +++ b/src/api/pthread.c @@ -24,8 +24,6 @@ C(PTHREAD_CANCEL_DISABLE) {void *x = PTHREAD_CANCELED;} C(PTHREAD_CREATE_DETACHED) C(PTHREAD_CREATE_JOINABLE) -C(PTHREAD_EXPLICIT_SCHED) -C(PTHREAD_INHERIT_SCHED) C(PTHREAD_MUTEX_DEFAULT) C(PTHREAD_MUTEX_ERRORCHECK) C(PTHREAD_MUTEX_NORMAL) @@ -35,11 +33,17 @@ C(PTHREAD_MUTEX_STALLED) C(PTHREAD_ONCE_INIT) C(PTHREAD_PRIO_INHERIT) C(PTHREAD_PRIO_NONE) +#ifdef X_RPP_TPP C(PTHREAD_PRIO_PROTECT) +#endif C(PTHREAD_PROCESS_SHARED) C(PTHREAD_PROCESS_PRIVATE) +#ifdef X_TPS +C(PTHREAD_EXPLICIT_SCHED) +C(PTHREAD_INHERIT_SCHED) C(PTHREAD_SCOPE_PROCESS) C(PTHREAD_SCOPE_SYSTEM) +#endif {pthread_cond_t x = PTHREAD_COND_INITIALIZER;} {pthread_mutex_t x = PTHREAD_MUTEX_INITIALIZER;} {pthread_rwlock_t x = PTHREAD_RWLOCK_INITIALIZER;} @@ -47,19 +51,13 @@ C(PTHREAD_SCOPE_SYSTEM) {int(*p)(pthread_attr_t*) = pthread_attr_destroy;} {int(*p)(const pthread_attr_t*,int*) = pthread_attr_getdetachstate;} {int(*p)(const pthread_attr_t*restrict,size_t*restrict) = pthread_attr_getguardsize;} -{int(*p)(const pthread_attr_t*restrict,int*restrict) = pthread_attr_getinheritsched;} {int(*p)(const pthread_attr_t*restrict,struct sched_param*restrict) = pthread_attr_getschedparam;} -{int(*p)(const pthread_attr_t*restrict,int*restrict) = pthread_attr_getschedpolicy;} -{int(*p)(const pthread_attr_t*restrict,int*restrict) = pthread_attr_getscope;} {int(*p)(const pthread_attr_t*restrict,void**restrict,size_t*restrict) = pthread_attr_getstack;} {int(*p)(const pthread_attr_t*restrict,size_t*restrict) = pthread_attr_getstacksize;} {int(*p)(pthread_attr_t*) = pthread_attr_init;} {int(*p)(pthread_attr_t*,int) = pthread_attr_setdetachstate;} {int(*p)(pthread_attr_t*,size_t) = pthread_attr_setguardsize;} -{int(*p)(pthread_attr_t*,int) = pthread_attr_setinheritsched;} {int(*p)(pthread_attr_t*restrict,const struct sched_param*restrict) = pthread_attr_setschedparam;} -{int(*p)(pthread_attr_t*,int) = pthread_attr_setschedpolicy;} -{int(*p)(pthread_attr_t*,int) = pthread_attr_setscope;} {int(*p)(pthread_attr_t*,void*,size_t) = pthread_attr_setstack;} {int(*p)(pthread_attr_t*,size_t) = pthread_attr_setstacksize;} {int(*p)(pthread_barrier_t*) = pthread_barrier_destroy;} @@ -88,27 +86,22 @@ C(PTHREAD_SCOPE_SYSTEM) {int(*p)(pthread_t) = pthread_detach;} {int(*p)(pthread_t,pthread_t) = pthread_equal;} {void(*p)(void*) = pthread_exit;} -{int(*p)(pthread_t,int*restrict,struct sched_param*restrict) = pthread_getschedparam;} {void*(*p)(pthread_key_t) = pthread_getspecific;} {int(*p)(pthread_t,void**) = pthread_join;} {int(*p)(pthread_key_t*,void(*)(void*)) = pthread_key_create;} {int(*p)(pthread_key_t) = pthread_key_delete;} {int(*p)(pthread_mutex_t*) = pthread_mutex_consistent;} {int(*p)(pthread_mutex_t*) = pthread_mutex_destroy;} -{int(*p)(const pthread_mutex_t*restrict,int*restrict) = pthread_mutex_getprioceiling;} {int(*p)(pthread_mutex_t*restrict,const pthread_mutexattr_t*restrict) = pthread_mutex_init;} {int(*p)(pthread_mutex_t*) = pthread_mutex_lock;} -{int(*p)(pthread_mutex_t*restrict,int,int*restrict) = pthread_mutex_setprioceiling;} {int(*p)(pthread_mutex_t*) = pthread_mutex_trylock;} {int(*p)(pthread_mutex_t*) = pthread_mutex_unlock;} {int(*p)(pthread_mutexattr_t*) = pthread_mutexattr_destroy;} -{int(*p)(const pthread_mutexattr_t*restrict,int*restrict) = pthread_mutexattr_getprioceiling;} {int(*p)(const pthread_mutexattr_t*restrict,int*restrict) = pthread_mutexattr_getprotocol;} {int(*p)(const pthread_mutexattr_t*restrict,int*restrict) = pthread_mutexattr_getpshared;} {int(*p)(const pthread_mutexattr_t*restrict,int*restrict) = pthread_mutexattr_getrobust;} {int(*p)(const pthread_mutexattr_t*restrict,int*restrict) = pthread_mutexattr_gettype;} {int(*p)(pthread_mutexattr_t*) = pthread_mutexattr_init;} -{int(*p)(pthread_mutexattr_t*,int) = pthread_mutexattr_setprioceiling;} {int(*p)(pthread_mutexattr_t*,int) = pthread_mutexattr_setprotocol;} {int(*p)(pthread_mutexattr_t*,int) = pthread_mutexattr_setpshared;} {int(*p)(pthread_mutexattr_t*,int) = pthread_mutexattr_setrobust;} @@ -128,7 +121,6 @@ C(PTHREAD_SCOPE_SYSTEM) {pthread_t(*p)(void) = pthread_self;} {int(*p)(int,int*) = pthread_setcancelstate;} {int(*p)(int,int*) = pthread_setcanceltype;} -{int(*p)(pthread_t,int,const struct sched_param*) = pthread_setschedparam;} {int(*p)(pthread_t,int) = pthread_setschedprio;} {int(*p)(pthread_key_t,const void*) = pthread_setspecific;} {int(*p)(pthread_spinlock_t*) = pthread_spin_destroy;} @@ -137,6 +129,24 @@ C(PTHREAD_SCOPE_SYSTEM) {int(*p)(pthread_spinlock_t*) = pthread_spin_trylock;} {int(*p)(pthread_spinlock_t*) = pthread_spin_unlock;} {void(*p)(void) = pthread_testcancel;} + +#ifdef X_RPP_TPP +{int(*p)(const pthread_mutex_t*restrict,int*restrict) = pthread_mutex_getprioceiling;} +{int(*p)(pthread_mutex_t*restrict,int,int*restrict) = pthread_mutex_setprioceiling;} +{int(*p)(const pthread_mutexattr_t*restrict,int*restrict) = pthread_mutexattr_getprioceiling;} +{int(*p)(pthread_mutexattr_t*,int) = pthread_mutexattr_setprioceiling;} +#endif + +#ifdef X_TPS +{int(*p)(const pthread_attr_t*restrict,int*restrict) = pthread_attr_getinheritsched;} +{int(*p)(const pthread_attr_t*restrict,int*restrict) = pthread_attr_getschedpolicy;} +{int(*p)(const pthread_attr_t*restrict,int*restrict) = pthread_attr_getscope;} +{int(*p)(pthread_attr_t*,int) = pthread_attr_setinheritsched;} +{int(*p)(pthread_attr_t*,int) = pthread_attr_setschedpolicy;} +{int(*p)(pthread_attr_t*,int) = pthread_attr_setscope;} +{int(*p)(pthread_t,int*restrict,struct sched_param*restrict) = pthread_getschedparam;} +{int(*p)(pthread_t,int,const struct sched_param*) = pthread_setschedparam;} +#endif } #include static void g() diff --git a/src/api/sched.c b/src/api/sched.c index ef5fb14..23ce364 100644 --- a/src/api/sched.c +++ b/src/api/sched.c @@ -4,7 +4,9 @@ #define C(n) switch(n){case n:;} static void f() { +#ifdef X_PS T(pid_t) +#endif T(time_t) T(struct timespec) { @@ -15,16 +17,23 @@ F(struct timespec,sched_ss_repl_period) F(struct timespec,sched_ss_init_budget) F(int,sched_ss_max_repl) } + +C(SCHED_SPORADIC) +{int(*p)(void) = sched_yield;} + +#if defined(X_PS) || defined(X_TPS) C(SCHED_FIFO) C(SCHED_RR) -C(SCHED_SPORADIC) C(SCHED_OTHER) {int(*p)(int) = sched_get_priority_max;} {int(*p)(int) = sched_get_priority_min;} +{int(*p)(pid_t,struct timespec*) = sched_rr_get_interval;} +#endif + +#ifdef X_PS {int(*p)(pid_t,struct sched_param*) = sched_getparam;} {int(*p)(pid_t) = sched_getscheduler;} -{int(*p)(pid_t,struct timespec*) = sched_rr_get_interval;} {int(*p)(pid_t,const struct sched_param*) = sched_setparam;} {int(*p)(pid_t,int,const struct sched_param*) = sched_setscheduler;} -{int(*p)(void) = sched_yield;} +#endif } diff --git a/src/api/spawn.c b/src/api/spawn.c index 3fa21a6..6cd91ce 100644 --- a/src/api/spawn.c +++ b/src/api/spawn.c @@ -11,8 +11,10 @@ T(sigset_t) T(struct sched_param) C(POSIX_SPAWN_RESETIDS) C(POSIX_SPAWN_SETPGROUP) +#ifdef X_PS C(POSIX_SPAWN_SETSCHEDPARAM) C(POSIX_SPAWN_SETSCHEDULER) +#endif C(POSIX_SPAWN_SETSIGDEF) C(POSIX_SPAWN_SETSIGMASK) {int(*p)(pid_t*restrict,const char*restrict,const posix_spawn_file_actions_t*,const posix_spawnattr_t*restrict,char*const[restrict],char*const[restrict]) = posix_spawn;} @@ -37,6 +39,7 @@ static void g() {int(*p)(posix_spawnattr_t*restrict,const sigset_t*restrict) = posix_spawnattr_setsigdefault;} {int(*p)(posix_spawnattr_t*restrict,const sigset_t*restrict) = posix_spawnattr_setsigmask;} } +#ifdef X_PS #include static void h() { @@ -45,3 +48,4 @@ static void h() {int(*p)(posix_spawnattr_t*restrict,const struct sched_param*restrict) = posix_spawnattr_setschedparam;} {int(*p)(posix_spawnattr_t*,int) = posix_spawnattr_setschedpolicy;} } +#endif diff --git a/src/api/sys_mman.c b/src/api/sys_mman.c index bba0087..73e53c6 100644 --- a/src/api/sys_mman.c +++ b/src/api/sys_mman.c @@ -7,6 +7,7 @@ static void f() T(mode_t) T(off_t) T(size_t) + C(PROT_EXEC) C(PROT_NONE) C(PROT_READ) @@ -27,13 +28,20 @@ C(POSIX_MADV_NORMAL) C(POSIX_MADV_RANDOM) C(POSIX_MADV_SEQUENTIAL) C(POSIX_MADV_WILLNEED) -//C(POSIX_TYPED_MEM_ALLOCATE) -//C(POSIX_TYPED_MEM_ALLOCATE_CONTIG) -//C(POSIX_TYPED_MEM_MAP_ALLOCATABLE) -//{ -//struct posix_typed_mem_info x; -//F(size_t,posix_tmi_length) -//} + +#ifdef X_TYM +C(POSIX_TYPED_MEM_ALLOCATE) +C(POSIX_TYPED_MEM_ALLOCATE_CONTIG) +C(POSIX_TYPED_MEM_MAP_ALLOCATABLE) +{ +struct posix_typed_mem_info x; +F(size_t,posix_tmi_length) +} +int(*p)(const void*restrict,size_t,off_t*restrict,size_t*restrict,int*restrict) = posix_mem_offset; +int(*p)(int,struct posix_typed_mem_info*) = posix_typed_mem_get_info; +int(*p)(const char*,int,int) = posix_typed_mem_open; +#endif + {int(*p)(const void*,size_t) = mlock;} {int(*p)(int) = mlockall;} {void*(*p)(void*,size_t,int,int,int,off_t) = mmap;} @@ -45,9 +53,6 @@ C(POSIX_MADV_WILLNEED) {int(*p)(void) = munlockall;} {int(*p)(void*,size_t) = munmap;} {int(*p)(void*,size_t,int) = posix_madvise;} -//int(*p)(const void*restrict,size_t,off_t*restrict,size_t*restrict,int*restrict) = posix_mem_offset; -//int(*p)(int,struct posix_typed_mem_info*) = posix_typed_mem_get_info; -//int(*p)(const char*,int,int) = posix_typed_mem_open; {int(*p)(const char*,int,mode_t) = shm_open;} {int(*p)(const char*) = shm_unlink;} }