diff --git a/Makefile b/Makefile index 8baa9a8..d27eb2d 100644 --- a/Makefile +++ b/Makefile @@ -107,12 +107,11 @@ $(B)/api/main: $(api.OBJS) api/main.OBJS:=$(api.OBJS) $(api.OBJS):$(B)/common/options.h $(api.OBJS):CFLAGS+=-pedantic-errors -Werror -Wno-unused -D_XOPEN_SOURCE=700 -$(api.OBJS):CFLAGS+=-DX_PS -DX_TPS -DX_SS all:$(B)/REPORT run:$(B)/REPORT clean: - rm -f $(OBJS) $(BINS) $(LIBS) $(B)/common/libtest.a $(B)/common/runtest $(B)/*/*.err + rm -f $(OBJS) $(BINS) $(LIBS) $(B)/common/libtest.a $(B)/common/runtest $(B)/common/options.h $(B)/*/*.err cleanall: clean rm -f $(B)/REPORT $(B)/*/REPORT $(B)/REPORT: diff --git a/src/api/fcntl.c b/src/api/fcntl.c index 4c25cdc..bd1d8dd 100644 --- a/src/api/fcntl.c +++ b/src/api/fcntl.c @@ -1,4 +1,5 @@ #include +#include "options.h" #define T(t) (t*)0; #define F(t,n) {t *y = &x.n;} #define C(n) switch(n){case n:;} @@ -28,9 +29,11 @@ C(O_NOCTTY) C(O_TRUNC) C(O_TTY_INIT) C(O_APPEND) -C(O_DSYNC) C(O_NONBLOCK) +#ifdef POSIX_SYNCHRONIZED_IO +C(O_DSYNC) C(O_RSYNC) +#endif C(O_SYNC) C(O_ACCMODE) C(O_EXEC) diff --git a/src/api/limits.c b/src/api/limits.c index cbe88f8..b26cbbe 100644 --- a/src/api/limits.c +++ b/src/api/limits.c @@ -1,4 +1,5 @@ #include +#include "options.h" #define C(n) switch(n){case n:;} static void f() { @@ -23,8 +24,10 @@ C(_POSIX_LINK_MAX) C(_POSIX_LOGIN_NAME_MAX) C(_POSIX_MAX_CANON) C(_POSIX_MAX_INPUT) +#ifdef POSIX_MESSAGE_PASSING C(_POSIX_MQ_OPEN_MAX) C(_POSIX_MQ_PRIO_MAX) +#endif C(_POSIX_NAME_MAX) C(_POSIX_NGROUPS_MAX) C(_POSIX_OPEN_MAX) @@ -36,7 +39,9 @@ C(_POSIX_SEM_NSEMS_MAX) C(_POSIX_SEM_VALUE_MAX) C(_POSIX_SIGQUEUE_MAX) C(_POSIX_SSIZE_MAX) +#if defined(POSIX_SPORADIC_SERVER) || defined(POSIX_THREAD_SPORADIC_SERVER) C(_POSIX_SS_REPL_MAX) +#endif C(_POSIX_STREAM_MAX) C(_POSIX_SYMLINK_MAX) C(_POSIX_SYMLOOP_MAX) diff --git a/src/api/mqueue.c b/src/api/mqueue.c index d9f754c..d16faf1 100644 --- a/src/api/mqueue.c +++ b/src/api/mqueue.c @@ -1,3 +1,5 @@ +#include "options.h" +#ifdef POSIX_MESSAGE_PASSING #include #define T(t) (t*)0; #define F(t,n) {t *y = &x.n;} @@ -31,3 +33,5 @@ static void g() {ssize_t(*p)(mqd_t,char*restrict,size_t,unsigned*restrict,const struct timespec*restrict) = mq_timedreceive;} {int(*p)(mqd_t,const char*,size_t,unsigned,const struct timespec*) = mq_timedsend;} } +#endif + diff --git a/src/api/pthread.c b/src/api/pthread.c index 0501380..fa2b2fc 100644 --- a/src/api/pthread.c +++ b/src/api/pthread.c @@ -31,14 +31,19 @@ C(PTHREAD_MUTEX_RECURSIVE) C(PTHREAD_MUTEX_ROBUST) C(PTHREAD_MUTEX_STALLED) C(PTHREAD_ONCE_INIT) +#if defined(POSIX_THREAD_ROBUST_PRIO_INHERIT) || defined(POSIX_THREAD_PRIO_INHERIT) C(PTHREAD_PRIO_INHERIT) +#endif +#if defined(POSIX_THREAD_ROBUST_PRIO_INHERIT) || defined(POSIX_THREAD_PRIO_INHERIT) \ + || defined(POSIX_THREAD_ROBUST_PRIO_PROTECT) || defined(POSIX_THREAD_PRIO_PROTECT) C(PTHREAD_PRIO_NONE) -#ifdef X_RPP_TPP +#endif +#if defined(POSIX_THREAD_ROBUST_PRIO_PROTECT) || defined(POSIX_THREAD_PRIO_PROTECT) C(PTHREAD_PRIO_PROTECT) #endif C(PTHREAD_PROCESS_SHARED) C(PTHREAD_PROCESS_PRIVATE) -#ifdef X_TPS +#ifdef POSIX_THREAD_PRIORITY_SCHEDULING C(PTHREAD_EXPLICIT_SCHED) C(PTHREAD_INHERIT_SCHED) C(PTHREAD_SCOPE_PROCESS) @@ -101,12 +106,15 @@ C(PTHREAD_SCOPE_SYSTEM) {int(*p)(pthread_mutex_t*) = pthread_mutex_trylock;} {int(*p)(pthread_mutex_t*) = pthread_mutex_unlock;} {int(*p)(pthread_mutexattr_t*) = pthread_mutexattr_destroy;} +#if defined(POSIX_THREAD_ROBUST_PRIO_INHERIT) || defined(POSIX_THREAD_PRIO_INHERIT) \ + || defined(POSIX_THREAD_ROBUST_PRIO_PROTECT) || defined(POSIX_THREAD_PRIO_PROTECT) {int(*p)(const pthread_mutexattr_t*restrict,int*restrict) = pthread_mutexattr_getprotocol;} +{int(*p)(pthread_mutexattr_t*,int) = pthread_mutexattr_setprotocol;} +#endif {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_setprotocol;} {int(*p)(pthread_mutexattr_t*,int) = pthread_mutexattr_setpshared;} {int(*p)(pthread_mutexattr_t*,int) = pthread_mutexattr_setrobust;} {int(*p)(pthread_mutexattr_t*,int) = pthread_mutexattr_settype;} @@ -133,15 +141,13 @@ 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 +#if defined(POSIX_THREAD_ROBUST_PRIO_PROTECT) || defined(POSIX_THREAD_PRIO_PROTECT) {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 +#ifdef POSIX_THREAD_PRIORITY_SCHEDULING {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;} diff --git a/src/api/sched.c b/src/api/sched.c index 365b01f..def5b35 100644 --- a/src/api/sched.c +++ b/src/api/sched.c @@ -1,4 +1,5 @@ #include +#include "options.h" #define T(t) (t*)0; #define F(t,n) {t *y = &x.n;} #define C(n) switch(n){case n:;} @@ -8,7 +9,7 @@ T(struct timespec) { struct sched_param x; F(int,sched_priority) -#ifdef X_SS +#if defined(POSIX_SPORADIC_SERVER) || defined(POSIX_THREAD_SPORADIC_SERVER) F(int,sched_ss_low_priority) F(struct timespec,sched_ss_repl_period) F(struct timespec,sched_ss_init_budget) @@ -17,18 +18,18 @@ T(time_t) C(SCHED_SPORADIC) #endif } -#ifdef X_PS +#ifdef POSIX_PRIORITY_SCHEDULING T(pid_t) +{int(*p)(pid_t,struct sched_param*) = sched_getparam;} +{int(*p)(pid_t) = sched_getscheduler;} +{int(*p)(pid_t,const struct sched_param*) = sched_setparam;} +{int(*p)(pid_t,int,const struct sched_param*) = sched_setscheduler;} +#endif C(SCHED_FIFO) C(SCHED_RR) C(SCHED_OTHER) -{int(*p)(pid_t,struct sched_param*) = sched_getparam;} -{int(*p)(pid_t) = sched_getscheduler;} {int(*p)(int) = sched_get_priority_max;} {int(*p)(int) = sched_get_priority_min;} {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;} -#endif {int(*p)(void) = sched_yield;} } diff --git a/src/api/spawn.c b/src/api/spawn.c index 6cd91ce..94511ea 100644 --- a/src/api/spawn.c +++ b/src/api/spawn.c @@ -1,4 +1,5 @@ #include +#include "options.h" #define T(t) (t*)0; #define C(n) switch(n){case n:;} static void f() @@ -11,7 +12,7 @@ T(sigset_t) T(struct sched_param) C(POSIX_SPAWN_RESETIDS) C(POSIX_SPAWN_SETPGROUP) -#ifdef X_PS +#ifdef POSIX_PRIORITY_SCHEDULING C(POSIX_SPAWN_SETSCHEDPARAM) C(POSIX_SPAWN_SETSCHEDULER) #endif @@ -39,7 +40,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 +#ifdef POSIX_PRIORITY_SCHEDULING #include static void h() { diff --git a/src/api/sys_mman.c b/src/api/sys_mman.c index 73e53c6..62b1722 100644 --- a/src/api/sys_mman.c +++ b/src/api/sys_mman.c @@ -1,4 +1,5 @@ #include +#include "options.h" #define T(t) (t*)0; #define F(t,n) {t *y = &x.n;} #define C(n) switch(n){case n:;} @@ -29,7 +30,7 @@ C(POSIX_MADV_RANDOM) C(POSIX_MADV_SEQUENTIAL) C(POSIX_MADV_WILLNEED) -#ifdef X_TYM +#ifdef POSIX_TYPED_MEMORY_OBJECTS C(POSIX_TYPED_MEM_ALLOCATE) C(POSIX_TYPED_MEM_ALLOCATE_CONTIG) C(POSIX_TYPED_MEM_MAP_ALLOCATABLE) @@ -53,6 +54,8 @@ int(*p)(const char*,int,int) = posix_typed_mem_open; {int(*p)(void) = munlockall;} {int(*p)(void*,size_t) = munmap;} {int(*p)(void*,size_t,int) = posix_madvise;} +#ifdef POSIX_SHARED_MEMORY_OBJECTS {int(*p)(const char*,int,mode_t) = shm_open;} {int(*p)(const char*) = shm_unlink;} +#endif } diff --git a/src/api/sys_stat.c b/src/api/sys_stat.c index b51b1e1..75477a0 100644 --- a/src/api/sys_stat.c +++ b/src/api/sys_stat.c @@ -1,4 +1,5 @@ #include +#include "options.h" #define T(t) (t*)0; #define F(t,n) {t *y = &x.n;} #define C(n) switch(n){case n:;} @@ -73,7 +74,9 @@ struct stat x = {0}; {int i = S_TYPEISMQ(&x);} {int i = S_TYPEISSEM(&x);} {int i = S_TYPEISSHM(&x);} +#ifdef POSIX_TYPED_MEMORY_OBJECTS {int i = S_TYPEISTMO(&x);} +#endif } C(UTIME_NOW) C(UTIME_OMIT) diff --git a/src/api/unistd.c b/src/api/unistd.c index d63da54..93355a6 100644 --- a/src/api/unistd.c +++ b/src/api/unistd.c @@ -1,14 +1,72 @@ #include +#include "options.h" #define T(t) (t*)0; #define F(t,n) {t *y = &x.n;} #define C(n) switch(n){case n:;} +#define A(n) {char p[n];} static void f() { -C(_POSIX_VERSION) -C(_POSIX2_VERSION) +A(_POSIX_VERSION >= 200809L) +A(_POSIX2_VERSION >= 200809L) #ifdef _XOPEN_SOURCE -C(_XOPEN_VERSION) +A(_XOPEN_VERSION >= 700) +// A(_XOPEN_CRYPT >= 0) + A(_XOPEN_ENH_I18N > 0) +// A(_XOPEN_REALTIME >= 0) +// A(_XOPEN_REALTIME_THREADS >= 0) +// A(_XOPEN_SHM >= 0) + A(_XOPEN_UNIX >= 0) #endif +A(_POSIX_ASYNCHRONOUS_IO >= 200809L) +A(_POSIX_BARRIERS >= 200809L) +A(_POSIX_CHOWN_RESTRICTED >= 0) +A(_POSIX_CLOCK_SELECTION >= 200809L) +A(_POSIX_JOB_CONTROL > 0) +A(_POSIX_MAPPED_FILES >= 200809L) +A(_POSIX_MEMORY_PROTECTION >= 200809L) +A(_POSIX_NO_TRUNC >= 0) +A(_POSIX_READER_WRITER_LOCKS >= 200809L) +A(_POSIX_REALTIME_SIGNALS >= 200809L) +A(_POSIX_REGEXP > 0) +A(_POSIX_SAVED_IDS > 0) +A(_POSIX_SEMAPHORES >= 200809L) +A(_POSIX_SHELL > 0) +A(_POSIX_SPIN_LOCKS >= 200809L) +A(_POSIX_THREAD_SAFE_FUNCTIONS >= 200809L) +A(_POSIX_THREADS >= 200809L) +A(_POSIX_TIMEOUTS >= 200809L) +A(_POSIX_TIMERS >= 200809L) +#if _POSIX_V7_ILP32_OFFBIG<=0 && _POSIX_V7_LP64_OFF64<=0 && _POSIX_V7_LPBIG_OFFBIG<=0 +#error _POSIX_V7_ILP32_OFFBIG<=0 && _POSIX_V7_LP64_OFF64<=0 && _POSIX_V7_LPBIG_OFFBIG<=0 +#endif +A(_POSIX2_C_BIND >= 200809L) +// not required by the standard + A(_POSIX_ADVISORY_INFO >= 0) + A(_POSIX_CPUTIME >= 0) + A(_POSIX_FSYNC >= 0) + A(_POSIX_IPV6 >= 0) + A(_POSIX_MEMLOCK >= 0) + A(_POSIX_MEMLOCK_RANGE >= 0) + A(_POSIX_MESSAGE_PASSING >= 0) + A(_POSIX_MONOTONIC_CLOCK >= 0) +// A(_POSIX_PRIORITIZED_IO >= 0) +// A(_POSIX_PRIORITY_SCHEDULING >= 0) + A(_POSIX_RAW_SOCKETS >= 0) +// A(_POSIX_SHARED_MEMORY_OBJECTS >= 0) + A(_POSIX_SPAWN >= 0) +// A(_POSIX_SPORADIC_SERVER >= 0) +// A(_POSIX_SYNCHRONIZED_IO >= 0) + A(_POSIX_THREAD_ATTR_STACKADDR >= 0) + A(_POSIX_THREAD_ATTR_STACKSIZE >= 0) + A(_POSIX_THREAD_CPUTIME >= 0) +// A(_POSIX_THREAD_PRIO_INHERIT >= 0) +// A(_POSIX_THREAD_PRIO_PROTECT >= 0) + A(_POSIX_THREAD_PRIORITY_SCHEDULING >= 0) + A(_POSIX_THREAD_PROCESS_SHARED >= 0) +// A(_POSIX_THREAD_ROBUST_PRIO_INHERIT >= 0) +// A(_POSIX_THREAD_ROBUST_PRIO_PROTECT >= 0) +// A(_POSIX_THREAD_SPORADIC_SERVER >= 0) +// A(_POSIX_TYPED_MEMORY_OBJECTS >= 0) C(F_OK) C(R_OK) C(W_OK) @@ -211,7 +269,9 @@ T(intptr_t) {int(*p)(int) = fchdir;} {int(*p)(int,uid_t,gid_t) = fchown;} {int(*p)(int,const char*,uid_t,gid_t,int) = fchownat;} +#ifdef POSIX_SYNCHRONIZED_IO {int(*p)(int) = fdatasync;} +#endif {int(*p)(int,char*const[],char*const[]) = fexecve;} {pid_t(*p)(void) = fork;} {long(*p)(int,int) = fpathconf;}