From 54a7d18c67f55ae00cb542b3d6e3a2ea1fd5ff16 Mon Sep 17 00:00:00 2001 From: Lionel Sambuc Date: Mon, 19 Jun 2017 01:05:41 +0000 Subject: [PATCH] libpthread compiles, with empty stubs --- lib/libpthread/pthread.c | 2 + lib/libpthread/pthread_cancelstub.c | 2 + lib/libpthread/pthread_compat.c | 183 ++++++++++++++++++++++++++++ lib/libpthread/pthread_int.h | 7 +- tests/lib/Makefile | 4 +- 5 files changed, 195 insertions(+), 3 deletions(-) diff --git a/lib/libpthread/pthread.c b/lib/libpthread/pthread.c index f5b1e4044..64499621c 100644 --- a/lib/libpthread/pthread.c +++ b/lib/libpthread/pthread.c @@ -1330,6 +1330,7 @@ pthread__initmain(pthread_t *newt) 4 * pthread__pagesize / 1024); *newt = pthread__main; +#if defined(__HAVE_TLS_VARIANT_I) || defined(__HAVE_TLS_VARIANT_II) || !defined(__minix) #if defined(_PTHREAD_GETTCB_EXT) pthread__main->pt_tls = _PTHREAD_GETTCB_EXT(); #elif defined(__HAVE___LWP_GETTCB_FAST) @@ -1338,6 +1339,7 @@ pthread__initmain(pthread_t *newt) pthread__main->pt_tls = _lwp_getprivate(); #endif pthread__main->pt_tls->tcb_pthread = pthread__main; +#endif /* defined(__HAVE_TLS_VARIANT_I) || defined(__HAVE_TLS_VARIANT_II) || !defined(__minix) */ } static signed int diff --git a/lib/libpthread/pthread_cancelstub.c b/lib/libpthread/pthread_cancelstub.c index 369ab39dd..f52350b02 100644 --- a/lib/libpthread/pthread_cancelstub.c +++ b/lib/libpthread/pthread_cancelstub.c @@ -224,6 +224,7 @@ fcntl(int fd, int cmd, ...) return retval; } +#if !defined(__minix) int fdatasync(int d) { @@ -237,6 +238,7 @@ fdatasync(int d) return retval; } +#endif /* !defined(__minix) */ int fsync(int d) diff --git a/lib/libpthread/pthread_compat.c b/lib/libpthread/pthread_compat.c index 97a4bc0ef..3ea1cd1cf 100644 --- a/lib/libpthread/pthread_compat.c +++ b/lib/libpthread/pthread_compat.c @@ -70,6 +70,188 @@ __pthread_init(void) __libc_thr_init(); } +#if defined(__minix) +lwpid_t +_lwp_self(void) +{ + return NULL; +} + +int +_lwp_create(const ucontext_t *, unsigned long, lwpid_t *) +{ + return -1; +} + +int +_lwp_exit(void) +{ + return -1; +} + +int +_lwp_wait(lwpid_t, lwpid_t *) +{ + return -1; +} + +int +_lwp_suspend(lwpid_t) +{ + return -1; +} + +int +_lwp_continue(lwpid_t) +{ + return -1; +} + +int +_lwp_wakeup(lwpid_t) +{ + return -1; +} + +void +_lwp_makecontext(ucontext_t *, void (*)(void *), void *, void *, + caddr_t, size_t) +{ + return; +} + +void * +_lwp_getprivate(void) +{ + return NULL; +} + +void +_lwp_setprivate(void *); +{ + return; +} + +int +_lwp_kill(lwpid_t, int) +{ + return -1; +} + +int +_lwp_detach(lwpid_t) +{ + return -1; +} + +int +_lwp_park(clockid_t, int, const struct timespec *, lwpid_t, + const void *, const void *) +{ + return -1; +} + +int +_lwp_unpark(lwpid_t, const void *) +{ + return -1; +} + +ssize_t +_lwp_unpark_all(const lwpid_t *, size_t, const void *) +{ + return -1; +} + +int +_lwp_setname(lwpid_t, const char *) +{ + return -1; +} + +int +_lwp_getname(lwpid_t, char *, size_t) +{ + return -1; +} + +int +_lwp_ctl(int, struct lwpctl **) +{ + return -1; +} + +#if 0 +int +_sys_sched_yield(void) +{ + return -1; +} + +int +sched_yield(void) +{ + return -1; +} + +int +_sched_setaffinity(pid_t a, lwpid_t b, size_t c, const cpuset_t *d) +{ + return -1; +} + +int +_sched_getaffinity(pid_t a, lwpid_t b, size_t c, cpuset_t *d) +{ + return -1; +} + +int +_sched_setparam(pid_t a, lwpid_t b, int c, const struct sched_param *d) +{ + return -1; +} + +int +_sched_getparam(pid_t a, lwpid_t b, int *c, struct sched_param *d) +{ + return -1; +} + +int +_sys_aio_suspend(const struct aiocb * const a[], int b, + const struct timespec *c) +{ + return -1; +} + +int +_sys_mq_send(mqd_t a, const char *b, size_t c, unsigned d) +{ + return -1; +} + +ssize_t +_sys_mq_receive(mqd_t a, char *b, size_t c, unsigned *d) +{ + return -1; +} + +int +_sys_mq_timedsend(mqd_t a, const char *b, size_t c, unsigned d, + const struct timespec *e) +{ + return -1; +} + +ssize_t +_sys_mq_timedreceive(mqd_t a, char *b, size_t c, unsigned *d, + const struct timespec *e) +{ + return -1; +} +#endif /* 0 */ +#else int _lwp_kill(lwpid_t a, int b) { @@ -206,3 +388,4 @@ _sys_mq_timedreceive(mqd_t a, char *b, size_t c, unsigned *d, return (ssize_t)syscall(SYS_mq_timedreceive, a, b, c, d, e); } +#endif /* defined(__minix) */ diff --git a/lib/libpthread/pthread_int.h b/lib/libpthread/pthread_int.h index b3463ee59..f2cab6e7f 100644 --- a/lib/libpthread/pthread_int.h +++ b/lib/libpthread/pthread_int.h @@ -255,10 +255,11 @@ int pthread__find(pthread_t) PTHREAD_HIDE; _INITCONTEXT_U_MD(ucp) \ } while (/*CONSTCOND*/0) - +#if !defined(__minix) #if !defined(__HAVE_TLS_VARIANT_I) && !defined(__HAVE_TLS_VARIANT_II) #error Either __HAVE_TLS_VARIANT_I or __HAVE_TLS_VARIANT_II must be defined #endif +#endif /* !defined(__minix) */ #ifdef _PTHREAD_GETTCB_EXT struct tls_tcb *_PTHREAD_GETTCB_EXT(void); @@ -267,6 +268,9 @@ struct tls_tcb *_PTHREAD_GETTCB_EXT(void); static inline pthread_t __constfunc pthread__self(void) { +#if defined(__minix) + return NULL; +#else #if defined(_PTHREAD_GETTCB_EXT) struct tls_tcb * const tcb = _PTHREAD_GETTCB_EXT(); #elif defined(__HAVE___LWP_GETTCB_FAST) @@ -275,6 +279,7 @@ pthread__self(void) struct tls_tcb * const tcb = __lwp_getprivate_fast(); #endif return (pthread_t)tcb->tcb_pthread; +#endif /* defined(__minix) */ } #define pthread__abort() \ diff --git a/tests/lib/Makefile b/tests/lib/Makefile index df4933b20..779645b1c 100644 --- a/tests/lib/Makefile +++ b/tests/lib/Makefile @@ -4,10 +4,10 @@ #__MINIX: # libbluetooth -# libobjc libposix libppath libpthread +# libobjc libposix libppath # librt libtre semaphore TESTS_SUBDIRS= csu libc libcrypt libcurses libevent libexecinfo \ - libm libprop \ + libm libprop libpthread \ libutil .if (${MKRUMP} != "no") && !defined(BSD_MK_COMPAT_FILE)