diff options
author | Waldemar Brodkorb <wbx@uclibc-ng.org> | 2016-11-06 17:48:49 +0100 |
---|---|---|
committer | Waldemar Brodkorb <wbx@uclibc-ng.org> | 2016-11-06 17:48:49 +0100 |
commit | 2ce94b3cb4db55c981ee6f2cbe1d3e790e89a2b7 (patch) | |
tree | 4b86ffd597b7c629cf3e65a3e3c2a918acd9a409 /test/nptl | |
parent | 094224b6b6a11ae8cb5b7d47e62e25235704fe0b (diff) |
allow to compile and run on musl based systems
This is a first shot, more improvements required to
allow to run more tests.
Diffstat (limited to 'test/nptl')
59 files changed, 157 insertions, 35 deletions
diff --git a/test/nptl/tst-atfork1.c b/test/nptl/tst-atfork1.c index 1298937..483f7a6 100644 --- a/test/nptl/tst-atfork1.c +++ b/test/nptl/tst-atfork1.c @@ -22,7 +22,7 @@ #include <stdlib.h> #include <unistd.h> #include <sys/wait.h> - +#include "../test-skeleton.h" static int val; diff --git a/test/nptl/tst-atfork2.c b/test/nptl/tst-atfork2.c index 594f56e..b9808ac 100644 --- a/test/nptl/tst-atfork2.c +++ b/test/nptl/tst-atfork2.c @@ -23,7 +23,7 @@ #include <stdlib.h> #include <unistd.h> #include <sys/wait.h> - +#include "../test-skeleton.h" /* Must be exported. */ int val; diff --git a/test/nptl/tst-attr3.c b/test/nptl/tst-attr3.c index 5ccf9ab..27d89f2 100644 --- a/test/nptl/tst-attr3.c +++ b/test/nptl/tst-attr3.c @@ -18,12 +18,17 @@ <http://www.gnu.org/licenses/>. */ #include <errno.h> +#if defined(__GLIBC__) || defined(__UCLIBC__) #include <error.h> +#else +#include "../error.h" +#endif #include <pthread.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> +#include "../test-skeleton.h" static void * tf (void *arg) @@ -164,6 +169,7 @@ tf (void *arg) } } +#if defined(__GLIBC__) || defined(__UCLIBC__) cpu_set_t c1, c2; err = pthread_getaffinity_np (pthread_self (), sizeof (c1), &c1); if (err == 0) @@ -180,6 +186,7 @@ tf (void *arg) result = tf; } } +#endif err = pthread_attr_destroy (&a); if (err) @@ -216,12 +223,14 @@ do_test (void) result = 1; } +#if defined(__GLIBC__) || defined(__UCLIBC__) err = pthread_attr_getaffinity_np (&a, sizeof (c1), &c1); if (err && err != ENOSYS) { error (0, err, "pthread_attr_getaffinity_np failed"); result = 1; } +#endif err = pthread_attr_destroy (&a); if (err) @@ -310,6 +319,7 @@ do_test (void) result = 1; } +#if defined(__GLIBC__) || defined(__UCLIBC__) err = pthread_getaffinity_np (pthread_self (), sizeof (c1), &c1); if (err == 0) { @@ -325,6 +335,7 @@ do_test (void) result = 1; } } +#endif err = pthread_attr_destroy (&a); if (err) diff --git a/test/nptl/tst-basic4.c b/test/nptl/tst-basic4.c index b69ca20..f7bdf1d 100644 --- a/test/nptl/tst-basic4.c +++ b/test/nptl/tst-basic4.c @@ -23,7 +23,7 @@ #include <stdlib.h> #include <unistd.h> #include <sys/wait.h> - +#include "../test-skeleton.h" static void final_test (void) diff --git a/test/nptl/tst-basic7.c b/test/nptl/tst-basic7.c index 15b6187..7a461a4 100644 --- a/test/nptl/tst-basic7.c +++ b/test/nptl/tst-basic7.c @@ -32,10 +32,10 @@ use_up_memory (void) setrlimit (RLIMIT_AS, &rl); char *c; - int PAGESIZE = getpagesize (); + int pagesize = getpagesize (); while (1) { - c = mmap (NULL, PAGESIZE, PROT_NONE, MAP_ANON | MAP_PRIVATE, -1, 0); + c = mmap (NULL, pagesize, PROT_NONE, MAP_ANON | MAP_PRIVATE, -1, 0); if (c == MAP_FAILED) break; } diff --git a/test/nptl/tst-cancel16.c b/test/nptl/tst-cancel16.c index 6af657c..a1e3c5a 100644 --- a/test/nptl/tst-cancel16.c +++ b/test/nptl/tst-cancel16.c @@ -24,6 +24,7 @@ #include <unistd.h> #include <sys/mman.h> #include <sys/wait.h> +#include "../test-skeleton.h" static pthread_barrier_t b2; diff --git a/test/nptl/tst-cancel18.c b/test/nptl/tst-cancel18.c index e653119..4fb4357 100644 --- a/test/nptl/tst-cancel18.c +++ b/test/nptl/tst-cancel18.c @@ -22,7 +22,7 @@ #include <stdlib.h> #include <time.h> #include <unistd.h> - +#include "../test-skeleton.h" static pthread_barrier_t b; diff --git a/test/nptl/tst-cancel22.c b/test/nptl/tst-cancel22.c index 8febbf0..e2c41f1 100644 --- a/test/nptl/tst-cancel22.c +++ b/test/nptl/tst-cancel22.c @@ -21,6 +21,7 @@ #include <stdio.h> #include <stdlib.h> #include <unistd.h> +#include "../test-skeleton.h" pthread_barrier_t b; int seen; diff --git a/test/nptl/tst-cancel4.c b/test/nptl/tst-cancel4.c index 696a527..6eaf5b1 100644 --- a/test/nptl/tst-cancel4.c +++ b/test/nptl/tst-cancel4.c @@ -37,8 +37,13 @@ #include <sys/uio.h> #include <sys/un.h> #include <sys/wait.h> +#include "../test-skeleton.h" +#if defined(__GLIBC__) || defined(__UCLIBC__) #define SIGCANCEL __SIGRTMIN +#else +#define SIGCANCEL SIGRTMIN +#endif /* Since STREAMS are not supported in the standard Linux kernel and diff --git a/test/nptl/tst-cleanup4.c b/test/nptl/tst-cleanup4.c index 3fe3998..982bc3e 100644 --- a/test/nptl/tst-cleanup4.c +++ b/test/nptl/tst-cleanup4.c @@ -21,6 +21,7 @@ #include <stdlib.h> #include <unistd.h> +#if defined(__GLIBC__) || defined(__UCLIBC__) /* LinuxThreads pthread_cleanup_{push,pop} helpers. */ extern void _pthread_cleanup_push (struct _pthread_cleanup_buffer *__buffer, void (*__routine) (void *), @@ -120,11 +121,12 @@ tf (void *a) return NULL; } - +#endif int do_test (void) { +#if defined(__GLIBC__) || defined(__UCLIBC__) int result = 0; if (pipe (fds) != 0) @@ -191,6 +193,9 @@ do_test (void) } return result; +#else + return 23; +#endif } #define TEST_FUNCTION do_test () diff --git a/test/nptl/tst-cleanup4aux.c b/test/nptl/tst-cleanup4aux.c index 029c493..1894293 100644 --- a/test/nptl/tst-cleanup4aux.c +++ b/test/nptl/tst-cleanup4aux.c @@ -21,6 +21,7 @@ #include <stdlib.h> #include <unistd.h> +#if defined(__GLIBC__) || defined(__UCLIBC__) extern void _pthread_cleanup_push (struct _pthread_cleanup_buffer *__buffer, void (*__routine) (void *), void *__arg); @@ -118,3 +119,4 @@ fn9 (void) _pthread_cleanup_pop (&b, 1); } +#endif diff --git a/test/nptl/tst-clock2.c b/test/nptl/tst-clock2.c index df6ec00..6902c25 100644 --- a/test/nptl/tst-clock2.c +++ b/test/nptl/tst-clock2.c @@ -22,6 +22,7 @@ #include <stdlib.h> #include <time.h> #include <unistd.h> +#include "../test-skeleton.h" #if defined _POSIX_THREAD_CPUTIME && _POSIX_THREAD_CPUTIME >= 0 diff --git a/test/nptl/tst-clock_nanosleep.c b/test/nptl/tst-clock_nanosleep.c index a2d1f00..0b4ad01 100644 --- a/test/nptl/tst-clock_nanosleep.c +++ b/test/nptl/tst-clock_nanosleep.c @@ -20,7 +20,7 @@ #include <unistd.h> #include <sys/time.h> #include <time.h> - +#include "../test-skeleton.h" /* Test that clock_nanosleep() does sleep. */ static int diff --git a/test/nptl/tst-cond14.c b/test/nptl/tst-cond14.c index 8378405..f0fe4cc 100644 --- a/test/nptl/tst-cond14.c +++ b/test/nptl/tst-cond14.c @@ -22,7 +22,7 @@ #include <string.h> #include <unistd.h> - +#if defined(__GLIBC__) || defined(__UCLIBC__) static pthread_cond_t cond = PTHREAD_COND_INITIALIZER; static pthread_mutex_t mut = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP; static pthread_mutex_t mut2 = PTHREAD_MUTEX_INITIALIZER; @@ -62,11 +62,12 @@ tf (void *p) return NULL; } - +#endif static int do_test (void) { +#if defined(__GLIBC__) || defined(__UCLIBC__) if (pthread_mutex_lock (&mut2) != 0) { puts ("1st mutex_lock failed"); @@ -109,6 +110,9 @@ do_test (void) puts ("done"); return 0; +#else + return 23; +#endif } diff --git a/test/nptl/tst-cond15.c b/test/nptl/tst-cond15.c index 0e8448c..e4c1d72 100644 --- a/test/nptl/tst-cond15.c +++ b/test/nptl/tst-cond15.c @@ -24,7 +24,7 @@ #include <unistd.h> #include <sys/time.h> - +#if defined(__GLIBC__) || defined(__UCLIBC__) static pthread_cond_t cond = PTHREAD_COND_INITIALIZER; static pthread_mutex_t mut = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP; static pthread_mutex_t mut2 = PTHREAD_MUTEX_INITIALIZER; @@ -87,11 +87,12 @@ tf (void *p) return NULL; } - +#endif static int do_test (void) { +#if defined(__GLIBC__) || defined(__UCLIBC__) if (pthread_mutex_lock (&mut2) != 0) { puts ("1st mutex_lock failed"); @@ -151,6 +152,9 @@ do_test (void) puts ("done"); return 0; +#else + return 23; +#endif } diff --git a/test/nptl/tst-cond22.c b/test/nptl/tst-cond22.c index bd978e5..3255cc0 100644 --- a/test/nptl/tst-cond22.c +++ b/test/nptl/tst-cond22.c @@ -2,7 +2,7 @@ #include <stdio.h> #include <stdlib.h> - +#if defined(__GLIBC__) || defined(__UCLIBC__) static pthread_barrier_t b; static pthread_cond_t c = PTHREAD_COND_INITIALIZER; static pthread_mutex_t m = PTHREAD_MUTEX_INITIALIZER; @@ -49,11 +49,12 @@ tf (void *arg) } return NULL; } - +#endif static int do_test (void) { +#if defined(__GLIBC__) || defined(__UCLIBC__) int status = 0; if (pthread_barrier_init (&b, NULL, 2) != 0) @@ -154,6 +155,9 @@ do_test (void) c.__data.__nwaiters, c.__data.__broadcast_seq); return status; +#else + return 23; +#endif } #define TEST_FUNCTION do_test () diff --git a/test/nptl/tst-cond8.c b/test/nptl/tst-cond8.c index fb13fa4..0805149 100644 --- a/test/nptl/tst-cond8.c +++ b/test/nptl/tst-cond8.c @@ -24,6 +24,7 @@ #include <sys/time.h> +#if defined(__GLIBC__) || defined(__UCLIBC__) static pthread_cond_t cond = PTHREAD_COND_INITIALIZER; static pthread_mutex_t mut = PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP; @@ -142,11 +143,12 @@ tf2 (void *p) return NULL; } - +#endif static int do_test (void) { +#if defined(__GLIBC__) || defined(__UCLIBC__) pthread_t th; int err; @@ -269,6 +271,9 @@ do_test (void) puts ("done"); return 0; +#else + return 23; +#endif } diff --git a/test/nptl/tst-cond9.c b/test/nptl/tst-cond9.c index dcb597d..31a6cb2 100644 --- a/test/nptl/tst-cond9.c +++ b/test/nptl/tst-cond9.c @@ -24,6 +24,7 @@ #include <sys/time.h> +#if defined(__GLIBC__) || defined(__UCLIBC__) static pthread_cond_t cond = PTHREAD_COND_INITIALIZER; static pthread_mutex_t mut = PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP; @@ -68,11 +69,12 @@ tf (void *arg) return (void *) 1l; } - +#endif static int do_test (void) { +#if defined(__GLIBC__) || defined(__UCLIBC__) pthread_t th; int err; @@ -142,6 +144,9 @@ do_test (void) puts ("done"); return 0; +#else + return 23; +#endif } diff --git a/test/nptl/tst-exec2.c b/test/nptl/tst-exec2.c index 061e3fc..c621b4e 100644 --- a/test/nptl/tst-exec2.c +++ b/test/nptl/tst-exec2.c @@ -26,7 +26,7 @@ #include <stdlib.h> #include <unistd.h> #include <sys/wait.h> - +#include "../test-skeleton.h" static void * tf (void *arg) diff --git a/test/nptl/tst-exec3.c b/test/nptl/tst-exec3.c index be4098b..f4a6807 100644 --- a/test/nptl/tst-exec3.c +++ b/test/nptl/tst-exec3.c @@ -26,6 +26,7 @@ #include <stdlib.h> #include <unistd.h> #include <sys/wait.h> +#include "../test-skeleton.h" static void * diff --git a/test/nptl/tst-flock2.c b/test/nptl/tst-flock2.c index 941c52f..acc6972 100644 --- a/test/nptl/tst-flock2.c +++ b/test/nptl/tst-flock2.c @@ -21,10 +21,11 @@ #include <stdio.h> #include <stdlib.h> #include <unistd.h> +#include <fcntl.h> #include <sys/file.h> #include <sys/mman.h> #include <sys/wait.h> - +#include "../test-skeleton.h" static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER; static pthread_mutex_t lock2 = PTHREAD_MUTEX_INITIALIZER; diff --git a/test/nptl/tst-fork1.c b/test/nptl/tst-fork1.c index 0d89728..448255d 100644 --- a/test/nptl/tst-fork1.c +++ b/test/nptl/tst-fork1.c @@ -23,6 +23,7 @@ #include <string.h> #include <unistd.h> #include <sys/wait.h> +#include "../test-skeleton.h" static void * thread_function (void * arg) diff --git a/test/nptl/tst-fork2.c b/test/nptl/tst-fork2.c index d85ea21..e653d7e 100644 --- a/test/nptl/tst-fork2.c +++ b/test/nptl/tst-fork2.c @@ -22,7 +22,7 @@ #include <stdlib.h> #include <unistd.h> #include <sys/wait.h> - +#include "../test-skeleton.h" static pid_t initial_pid; diff --git a/test/nptl/tst-fork3.c b/test/nptl/tst-fork3.c index 968d0ab..434aa8f 100644 --- a/test/nptl/tst-fork3.c +++ b/test/nptl/tst-fork3.c @@ -22,6 +22,7 @@ #include <stdlib.h> #include <unistd.h> #include <sys/wait.h> +#include "../test-skeleton.h" static pid_t initial_pid; diff --git a/test/nptl/tst-getpid3.c b/test/nptl/tst-getpid3.c index f1e77f6..974cd99 100644 --- a/test/nptl/tst-getpid3.c +++ b/test/nptl/tst-getpid3.c @@ -5,7 +5,7 @@ #include <string.h> #include <unistd.h> #include <sys/wait.h> - +#include "../test-skeleton.h" static pid_t pid; diff --git a/test/nptl/tst-initializers1.c b/test/nptl/tst-initializers1.c index 1e35380..6a458f1 100644 --- a/test/nptl/tst-initializers1.c +++ b/test/nptl/tst-initializers1.c @@ -18,6 +18,7 @@ #include <pthread.h> +#if defined(__GLIBC__) || defined(__UCLIBC__) pthread_mutex_t mtx_normal = PTHREAD_MUTEX_INITIALIZER; pthread_mutex_t mtx_recursive = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP; pthread_mutex_t mtx_errorchk = PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP; @@ -26,10 +27,12 @@ pthread_rwlock_t rwl_normal = PTHREAD_RWLOCK_INITIALIZER; pthread_rwlock_t rwl_writer = PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP; pthread_cond_t cond = PTHREAD_COND_INITIALIZER; +#endif int main (void) { +#if defined(__GLIBC__) || defined(__UCLIBC__) if (mtx_normal.__data.__kind != PTHREAD_MUTEX_TIMED_NP) return 1; if (mtx_recursive.__data.__kind != PTHREAD_MUTEX_RECURSIVE_NP) @@ -44,4 +47,7 @@ main (void) != PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP) return 1; return 0; +#else + return 23; +#endif } diff --git a/test/nptl/tst-kill6.c b/test/nptl/tst-kill6.c index f530e4e..5b801c8 100644 --- a/test/nptl/tst-kill6.c +++ b/test/nptl/tst-kill6.c @@ -23,7 +23,7 @@ #include <stdio.h> #include <stdlib.h> #include <unistd.h> - +#include "../test-skeleton.h" static pthread_t receiver; static sem_t sem; diff --git a/test/nptl/tst-mqueue1.c b/test/nptl/tst-mqueue1.c index 5ec79cf..f07df0b 100644 --- a/test/nptl/tst-mqueue1.c +++ b/test/nptl/tst-mqueue1.c @@ -27,6 +27,7 @@ #include <time.h> #include <unistd.h> #include "tst-mqueue.h" +#include "../test-skeleton.h" static int intcmp (const void *a, const void *b) diff --git a/test/nptl/tst-mqueue3.c b/test/nptl/tst-mqueue3.c index 5686f43..2cec763 100644 --- a/test/nptl/tst-mqueue3.c +++ b/test/nptl/tst-mqueue3.c @@ -18,6 +18,7 @@ <http://www.gnu.org/licenses/>. */ #include <errno.h> +#include <fcntl.h> #include <mqueue.h> #include <signal.h> #include <stddef.h> @@ -28,6 +29,7 @@ #include <sys/mman.h> #include <sys/wait.h> #include <unistd.h> +#include "../test-skeleton.h" #if _POSIX_THREADS # include <pthread.h> diff --git a/test/nptl/tst-mqueue5.c b/test/nptl/tst-mqueue5.c index 58e2ebf..ea6cc96 100644 --- a/test/nptl/tst-mqueue5.c +++ b/test/nptl/tst-mqueue5.c @@ -32,6 +32,7 @@ #include <time.h> #include <unistd.h> #include "tst-mqueue.h" +#include "../test-skeleton.h" #define TIMEOUT 3 diff --git a/test/nptl/tst-mqueue6.c b/test/nptl/tst-mqueue6.c index 8d84c19..5f44e52 100644 |