diff options
author | deischen <deischen@FreeBSD.org> | 2007-11-30 17:20:29 +0000 |
---|---|---|
committer | deischen <deischen@FreeBSD.org> | 2007-11-30 17:20:29 +0000 |
commit | f1ac56b04d023087e7771958a39880cb905293e9 (patch) | |
tree | d3459c2b707d5533cdf469b26aa07ba25bc884ef /lib | |
parent | 7e7891776f848635b8c67e11ba0e40d815f2a092 (diff) | |
download | FreeBSD-src-f1ac56b04d023087e7771958a39880cb905293e9.zip FreeBSD-src-f1ac56b04d023087e7771958a39880cb905293e9.tar.gz |
WARNS=3'ify.
Diffstat (limited to 'lib')
120 files changed, 532 insertions, 159 deletions
diff --git a/lib/libkse/Makefile b/lib/libkse/Makefile index a2b5ae8..7acf612 100644 --- a/lib/libkse/Makefile +++ b/lib/libkse/Makefile @@ -28,12 +28,11 @@ CFLAGS+=-I${.CURDIR}/sys CFLAGS+=-I${.CURDIR}/../../libexec/rtld-elf CFLAGS+=-I${.CURDIR}/../../libexec/rtld-elf/${MACHINE_ARCH} CFLAGS+=-fno-builtin -CFLAGS+=-fno-strict-aliasing # Uncomment this if you want libkse to contain debug information for # thread locking. CFLAGS+=-D_LOCK_DEBUG -WARNS?=2 +WARNS?=3 # Uncomment this if you want to build a 1:1 threading mode library # however it is no longer strictly conformed to POSIX diff --git a/lib/libkse/arch/amd64/include/atomic_ops.h b/lib/libkse/arch/amd64/include/atomic_ops.h index 980eb8e..0ac3b1c 100644 --- a/lib/libkse/arch/amd64/include/atomic_ops.h +++ b/lib/libkse/arch/amd64/include/atomic_ops.h @@ -36,7 +36,7 @@ * void atomic_swap64(intptr_t *dst, intptr_t val, intptr_t *res); */ static inline void -atomic_swap64(intptr_t *dst, intptr_t val, intptr_t *res) +atomic_swap64(volatile intptr_t *dst, intptr_t val, intptr_t *res) { __asm __volatile( "xchgq %2, %1; movq %2, %0" @@ -44,7 +44,7 @@ atomic_swap64(intptr_t *dst, intptr_t val, intptr_t *res) } static inline void -atomic_swap_int(int *dst, int val, int *res) +atomic_swap_int(volatile int *dst, int val, int *res) { __asm __volatile( "xchgl %2, %1; movl %2, %0" @@ -52,6 +52,6 @@ atomic_swap_int(int *dst, int val, int *res) } #define atomic_swap_ptr(d, v, r) \ - atomic_swap64((intptr_t *)(d), (intptr_t)(v), (intptr_t *)(r)) + atomic_swap64((volatile intptr_t *)(d), (intptr_t)(v), (intptr_t *)(r)) #endif diff --git a/lib/libkse/arch/amd64/include/pthread_md.h b/lib/libkse/arch/amd64/include/pthread_md.h index a7da5df..3e451fd 100644 --- a/lib/libkse/arch/amd64/include/pthread_md.h +++ b/lib/libkse/arch/amd64/include/pthread_md.h @@ -250,7 +250,7 @@ _thread_switch(struct kcb *kcb, struct tcb *tcb, int setmbox) _amd64_restore_context( &tcb->tcb_tmbx.tm_context.uc_mcontext, (intptr_t)&tcb->tcb_tmbx, - (intptr_t *)&kcb->kcb_kmbx.km_curthread); + (intptr_t *)(void *)&kcb->kcb_kmbx.km_curthread); else _amd64_restore_context( &tcb->tcb_tmbx.tm_context.uc_mcontext, diff --git a/lib/libkse/arch/arm/include/atomic_ops.h b/lib/libkse/arch/arm/include/atomic_ops.h index 3a209b3..4d8b55e 100644 --- a/lib/libkse/arch/arm/include/atomic_ops.h +++ b/lib/libkse/arch/arm/include/atomic_ops.h @@ -39,15 +39,15 @@ * void atomic_swap32(intptr_t *dst, intptr_t val, intptr_t *res); */ static inline void -atomic_swap32(intptr_t *dst, intptr_t val, intptr_t *res) +atomic_swap32(volatile intptr_t *dst, intptr_t val, intptr_t *res) { *res = __swp(val, dst); } #define atomic_swap_ptr(d, v, r) \ - atomic_swap32((intptr_t *)d, (intptr_t)v, (intptr_t *)r) + atomic_swap32((volatile intptr_t *)d, (intptr_t)v, (intptr_t *)r) #define atomic_swap_int(d, v, r) \ - atomic_swap32((intptr_t *)d, (intptr_t)v, (intptr_t *)r) + atomic_swap32((volatile intptr_t *)d, (intptr_t)v, (intptr_t *)r) #endif diff --git a/lib/libkse/arch/i386/include/atomic_ops.h b/lib/libkse/arch/i386/include/atomic_ops.h index 7bc3d1b..0cd47f8 100644 --- a/lib/libkse/arch/i386/include/atomic_ops.h +++ b/lib/libkse/arch/i386/include/atomic_ops.h @@ -36,7 +36,7 @@ * void atomic_swap32(intptr_t *dst, intptr_t val, intptr_t *res); */ static inline void -atomic_swap32(intptr_t *dst, intptr_t val, intptr_t *res) +atomic_swap32(volatile intptr_t *dst, intptr_t val, intptr_t *res) { __asm __volatile( "xchgl %2, %1; movl %2, %0" @@ -44,8 +44,8 @@ atomic_swap32(intptr_t *dst, intptr_t val, intptr_t *res) } #define atomic_swap_ptr(d, v, r) \ - atomic_swap32((intptr_t *)d, (intptr_t)v, (intptr_t *)r) + atomic_swap32((volatile intptr_t *)d, (intptr_t)v, (intptr_t *)r) #define atomic_swap_int(d, v, r) \ - atomic_swap32((intptr_t *)d, (intptr_t)v, (intptr_t *)r) + atomic_swap32((volatile intptr_t *)d, (intptr_t)v, (intptr_t *)r) #endif diff --git a/lib/libkse/arch/i386/include/pthread_md.h b/lib/libkse/arch/i386/include/pthread_md.h index 52afd6a..151d882 100644 --- a/lib/libkse/arch/i386/include/pthread_md.h +++ b/lib/libkse/arch/i386/include/pthread_md.h @@ -246,7 +246,7 @@ _thread_switch(struct kcb *kcb, struct tcb *tcb, int setmbox) if (setmbox != 0) _thr_setcontext(&tcb->tcb_tmbx.tm_context.uc_mcontext, (intptr_t)&tcb->tcb_tmbx, - (intptr_t *)&kcb->kcb_kmbx.km_curthread); + (intptr_t *)(void *)&kcb->kcb_kmbx.km_curthread); else _thr_setcontext(&tcb->tcb_tmbx.tm_context.uc_mcontext, 0, NULL); diff --git a/lib/libkse/arch/ia64/include/atomic_ops.h b/lib/libkse/arch/ia64/include/atomic_ops.h index 483c905..a8965d1 100644 --- a/lib/libkse/arch/ia64/include/atomic_ops.h +++ b/lib/libkse/arch/ia64/include/atomic_ops.h @@ -30,18 +30,18 @@ #define _ATOMIC_OPS_H_ static inline void -atomic_swap_int(int *dst, int val, int *res) +atomic_swap_int(volatile int *dst, int val, int *res) { __asm("xchg4 %0=[%2],%1" : "=r"(*res) : "r"(val), "r"(dst)); } static inline void -atomic_swap_long(long *dst, long val, long *res) +atomic_swap_long(volatile long *dst, long val, long *res) { __asm("xchg8 %0=[%2],%1" : "=r"(*res) : "r"(val), "r"(dst)); } #define atomic_swap_ptr(d,v,r) \ - atomic_swap_long((long*)d, (long)v, (long*)r) + atomic_swap_long((volatile long *)d, (long)v, (long *)r) #endif /* _ATOMIC_OPS_H_ */ diff --git a/lib/libkse/arch/powerpc/include/atomic_ops.h b/lib/libkse/arch/powerpc/include/atomic_ops.h index 8068e6f..866bed5 100644 --- a/lib/libkse/arch/powerpc/include/atomic_ops.h +++ b/lib/libkse/arch/powerpc/include/atomic_ops.h @@ -37,7 +37,7 @@ * void atomic_swap32(intptr_t *dst, intptr_t val, intptr_t *res); */ static inline void -atomic_swap32(intptr_t *dst, intptr_t val, intptr_t *res) +atomic_swap32(volatile intptr_t *dst, intptr_t val, intptr_t *res) { int tmp; @@ -55,8 +55,8 @@ atomic_swap32(intptr_t *dst, intptr_t val, intptr_t *res) } #define atomic_swap_ptr(d, v, r) \ - atomic_swap32((intptr_t *)d, (intptr_t)v, (intptr_t *)r) + atomic_swap32((volatile intptr_t *)d, (intptr_t)v, (intptr_t *)r) #define atomic_swap_int(d, v, r) \ - atomic_swap32((intptr_t *)d, (intptr_t)v, (intptr_t *)r) + atomic_swap32((volatile intptr_t *)d, (intptr_t)v, (intptr_t *)r) #endif diff --git a/lib/libkse/arch/powerpc/include/pthread_md.h b/lib/libkse/arch/powerpc/include/pthread_md.h index 2b13e4b..71e8e58 100644 --- a/lib/libkse/arch/powerpc/include/pthread_md.h +++ b/lib/libkse/arch/powerpc/include/pthread_md.h @@ -280,7 +280,7 @@ _thread_switch(struct kcb *kcb, struct tcb *tcb, int setmbox) tcb->tcb_tmbx.tm_lwp = kcb->kcb_kmbx.km_lwp; if (setmbox) _ppc32_setcontext(mc, (intptr_t)&tcb->tcb_tmbx, - (intptr_t *)&kcb->kcb_kmbx.km_curthread); + (intptr_t *)(void *)&kcb->kcb_kmbx.km_curthread); else _ppc32_setcontext(mc, 0, NULL); } diff --git a/lib/libkse/arch/sparc64/include/atomic_ops.h b/lib/libkse/arch/sparc64/include/atomic_ops.h index 4f4d8af..2264ec2 100644 --- a/lib/libkse/arch/sparc64/include/atomic_ops.h +++ b/lib/libkse/arch/sparc64/include/atomic_ops.h @@ -38,7 +38,7 @@ * void atomic_swap_long(long *dst, long val, long *res); */ static __inline void -atomic_swap_long(long *dst, long val, long *res) +atomic_swap_long(volatile long *dst, long val, long *res) { long tmp; long r; @@ -54,7 +54,7 @@ atomic_swap_long(long *dst, long val, long *res) } static __inline void -atomic_swap_int(int *dst, int val, int *res) +atomic_swap_int(volatile int *dst, int val, int *res) { int tmp; int r; @@ -70,6 +70,6 @@ atomic_swap_int(int *dst, int val, int *res) } #define atomic_swap_ptr(dst, val, res) \ - atomic_swap_long((long *)dst, (long)val, (long *)res) + atomic_swap_long((volatile long *)dst, (long)val, (long *)res) #endif diff --git a/lib/libkse/arch/sparc64/include/pthread_md.h b/lib/libkse/arch/sparc64/include/pthread_md.h index fac62c2..47cf001 100644 --- a/lib/libkse/arch/sparc64/include/pthread_md.h +++ b/lib/libkse/arch/sparc64/include/pthread_md.h @@ -237,7 +237,7 @@ _thread_switch(struct kcb *kcb, struct tcb *tcb, int setmbox) tcb->tcb_tmbx.tm_lwp = kcb->kcb_kmbx.km_lwp; if (setmbox) _thr_setcontext(mc, (intptr_t)&tcb->tcb_tmbx, - (intptr_t *)&kcb->kcb_kmbx.km_curthread); + (intptr_t *)(void *)&kcb->kcb_kmbx.km_curthread); else _thr_setcontext(mc, 0, NULL); } else { diff --git a/lib/libkse/sys/lock.c b/lib/libkse/sys/lock.c index 7c111bc..77e4e42 100644 --- a/lib/libkse/sys/lock.c +++ b/lib/libkse/sys/lock.c @@ -178,11 +178,12 @@ _lock_acquire(struct lock *lck, struct lockuser *lu, int prio) * Atomically swap the head of the lock request with * this request. */ - atomic_swap_ptr(&lck->l_head, lu->lu_myreq, &lu->lu_watchreq); + atomic_swap_ptr((void *)&lck->l_head, lu->lu_myreq, + (void *)&lu->lu_watchreq); if (lu->lu_watchreq->lr_locked != 0) { atomic_store_rel_ptr - ((volatile uintptr_t *)&lu->lu_watchreq->lr_watcher, + ((volatile uintptr_t *)(void *)&lu->lu_watchreq->lr_watcher, (uintptr_t)lu); if ((lck->l_wait == NULL) || ((lck->l_type & LCK_ADAPTIVE) == 0)) { @@ -214,7 +215,7 @@ _lock_acquire(struct lock *lck, struct lockuser *lu, int prio) if (lu->lu_watchreq->lr_active == 0) break; } - atomic_swap_int((int *)&lu->lu_watchreq->lr_locked, + atomic_swap_int(&lu->lu_watchreq->lr_locked, 2, &lval); if (lval == 0) lu->lu_watchreq->lr_locked = 0; @@ -253,18 +254,19 @@ _lock_release(struct lock *lck, struct lockuser *lu) /* Update tail if our request is last. */ if (lu->lu_watchreq->lr_owner == NULL) { - atomic_store_rel_ptr((volatile uintptr_t *)&lck->l_tail, + atomic_store_rel_ptr((volatile uintptr_t *) + (void *)&lck->l_tail, (uintptr_t)lu->lu_myreq); - atomic_store_rel_ptr - ((volatile uintptr_t *)&lu->lu_myreq->lr_owner, + atomic_store_rel_ptr((volatile uintptr_t *) + (void *)&lu->lu_myreq->lr_owner, (uintptr_t)NULL); } else { /* Remove ourselves from the list. */ atomic_store_rel_ptr((volatile uintptr_t *) - &lu->lu_myreq->lr_owner, + (void *)&lu->lu_myreq->lr_owner, (uintptr_t)lu->lu_watchreq->lr_owner); atomic_store_rel_ptr((volatile uintptr_t *) - &lu->lu_watchreq->lr_owner->lu_myreq, + (void *)&lu->lu_watchreq->lr_owner->lu_myreq, (uintptr_t)lu->lu_myreq); } /* @@ -293,7 +295,7 @@ _lock_release(struct lock *lck, struct lockuser *lu) /* Give the lock to the highest priority user. */ if (lck->l_wakeup != NULL) { atomic_swap_int( - (int *)&lu_h->lu_watchreq->lr_locked, + &lu_h->lu_watchreq->lr_locked, 0, &lval); if (lval == 2) /* Notify the sleeper */ @@ -305,7 +307,7 @@ _lock_release(struct lock *lck, struct lockuser *lu) &lu_h->lu_watchreq->lr_locked, 0); } else { if (lck->l_wakeup != NULL) { - atomic_swap_int((int *)&myreq->lr_locked, + atomic_swap_int(&myreq->lr_locked, 0, &lval); if (lval == 2) /* Notify the sleeper */ @@ -326,7 +328,7 @@ _lock_release(struct lock *lck, struct lockuser *lu) lu->lu_watchreq = NULL; lu->lu_myreq->lr_locked = 1; if (lck->l_wakeup) { - atomic_swap_int((int *)&myreq->lr_locked, 0, &lval); + atomic_swap_int(&myreq->lr_locked, 0, &lval); if (lval == 2) /* Notify the sleeper */ lck->l_wakeup(lck, myreq->lr_watcher); @@ -339,7 +341,7 @@ _lock_release(struct lock *lck, struct lockuser *lu) } void -_lock_grant(struct lock *lck /* unused */, struct lockuser *lu) +_lock_grant(struct lock *lck __unused /* unused */, struct lockuser *lu) { atomic_store_rel_int(&lu->lu_watchreq->lr_locked, 3); } diff --git a/lib/libkse/sys/thr_error.c b/lib/libkse/sys/thr_error.c index 0ba34e0..63fce9c 100644 --- a/lib/libkse/sys/thr_error.c +++ b/lib/libkse/sys/thr_error.c @@ -33,6 +33,7 @@ * * $FreeBSD$ */ +#include <errno.h> #include <pthread.h> #include "libc_private.h" #include "thr_private.h" diff --git a/lib/libkse/thread/thr_accept.c b/lib/libkse/thread/thr_accept.c index fc60fb4..d58c994 100644 --- a/lib/libkse/thread/thr_accept.c +++ b/lib/libkse/thread/thr_accept.c @@ -35,6 +35,9 @@ __FBSDID("$FreeBSD$"); LT10_COMPAT_PRIVATE(__accept); LT10_COMPAT_DEFAULT(accept); +int __accept(int s, struct sockaddr *addr, socklen_t *addrlen); + + __weak_reference(__accept, accept); int diff --git a/lib/libkse/thread/thr_aio_suspend.c b/lib/libkse/thread/thr_aio_suspend.c index 43a2414..5a779c6 100644 --- a/lib/libkse/thread/thr_aio_suspend.c +++ b/lib/libkse/thread/thr_aio_suspend.c @@ -36,6 +36,11 @@ LT10_COMPAT_PRIVATE(_aio_suspend); LT10_COMPAT_DEFAULT(aio_suspend); + +int +_aio_suspend(const struct aiocb * const iocbs[], int niocb, const struct + timespec *timeout); + __weak_reference(_aio_suspend, aio_suspend); int diff --git a/lib/libkse/thread/thr_atfork.c b/lib/libkse/thread/thr_atfork.c index a741329..ba62f11 100644 --- a/lib/libkse/thread/thr_atfork.c +++ b/lib/libkse/thread/thr_atfork.c @@ -25,10 +25,12 @@ * * $FreeBSD$ */ +#include "namespace.h" #include <errno.h> #include <stdlib.h> #include <pthread.h> #include <sys/queue.h> +#include "un-namespace.h" #include "thr_private.h" LT10_COMPAT_PRIVATE(_pthread_atfork); diff --git a/lib/libkse/thread/thr_attr_destroy.c b/lib/libkse/thread/thr_attr_destroy.c index 0e2b2e1..0d85715 100644 --- a/lib/libkse/thread/thr_attr_destroy.c +++ b/lib/libkse/thread/thr_attr_destroy.c @@ -28,9 +28,11 @@ * * $FreeBSD$ */ +#include "namespace.h" #include <stdlib.h> #include <errno.h> #include <pthread.h> +#include "un-namespace.h" #include "thr_private.h" LT10_COMPAT_PRIVATE(_pthread_attr_destroy); diff --git a/lib/libkse/thread/thr_attr_get_np.c b/lib/libkse/thread/thr_attr_get_np.c index a63088f..c2fcfbb 100644 --- a/lib/libkse/thread/thr_attr_get_np.c +++ b/lib/libkse/thread/thr_attr_get_np.c @@ -25,10 +25,13 @@ * * $FreeBSD$ */ + +#include "namespace.h" #include <errno.h> #include <string.h> #include <pthread.h> #include <pthread_np.h> +#include "un-namespace.h" #include "thr_private.h" LT10_COMPAT_PRIVATE(_pthread_attr_get_np); diff --git a/lib/libkse/thread/thr_attr_getdetachstate.c b/lib/libkse/thread/thr_attr_getdetachstate.c index 465ad28..2974327 100644 --- a/lib/libkse/thread/thr_attr_getdetachstate.c +++ b/lib/libkse/thread/thr_attr_getdetachstate.c @@ -28,8 +28,10 @@ * * $FreeBSD$ */ +#include "namespace.h" #include <errno.h> #include <pthread.h> +#include "un-namespace.h" #include "thr_private.h" LT10_COMPAT_PRIVATE(_pthread_attr_getdetachstate); diff --git a/lib/libkse/thread/thr_attr_getguardsize.c b/lib/libkse/thread/thr_attr_getguardsize.c index 351015c..5f233d1 100644 --- a/lib/libkse/thread/thr_attr_getguardsize.c +++ b/lib/libkse/thread/thr_attr_getguardsize.c @@ -29,8 +29,10 @@ * $FreeBSD$ */ +#include "namespace.h" #include <errno.h> #include <pthread.h> +#include "un-namespace.h" #include "thr_private.h" LT10_COMPAT_PRIVATE(_pthread_attr_getguardsize); diff --git a/lib/libkse/thread/thr_attr_getinheritsched.c b/lib/libkse/thread/thr_attr_getinheritsched.c index eab19e3..9568853 100644 --- a/lib/libkse/thread/thr_attr_getinheritsched.c +++ b/lib/libkse/thread/thr_attr_getinheritsched.c @@ -31,8 +31,11 @@ * * $FreeBSD$ */ + +#include "namespace.h" #include <errno.h> #include <pthread.h> +#include "un-namespace.h" #include "thr_private.h" LT10_COMPAT_PRIVATE(_pthread_attr_getinheritsched); diff --git a/lib/libkse/thread/thr_attr_getschedparam.c b/lib/libkse/thread/thr_attr_getschedparam.c index ca2eed3..b0a8ec4 100644 --- a/lib/libkse/thread/thr_attr_getschedparam.c +++ b/lib/libkse/thread/thr_attr_getschedparam.c @@ -31,8 +31,11 @@ * * $FreeBSD$ */ + +#include "namespace.h" #include <errno.h> #include <pthread.h> +#include "un-namespace.h" #include "thr_private.h" LT10_COMPAT_PRIVATE(_pthread_attr_getschedparam); diff --git a/lib/libkse/thread/thr_attr_getschedpolicy.c b/lib/libkse/thread/thr_attr_getschedpolicy.c index dc952bd..32af87d 100644 --- a/lib/libkse/thread/thr_attr_getschedpolicy.c +++ b/lib/libkse/thread/thr_attr_getschedpolicy.c @@ -31,8 +31,11 @@ * * $FreeBSD$ */ + +#include "namespace.h" #include <errno.h> #include <pthread.h> +#include "un-namespace.h" #include "thr_private.h" LT10_COMPAT_PRIVATE(_pthread_attr_getschedpolicy); diff --git a/lib/libkse/thread/thr_attr_getscope.c b/lib/libkse/thread/thr_attr_getscope.c index ceb198f..6a6db6f 100644 --- a/lib/libkse/thread/thr_attr_getscope.c +++ b/lib/libkse/thread/thr_attr_getscope.c @@ -31,8 +31,11 @@ * * $FreeBSD$ */ + +#include "namespace.h" #include <errno.h> #include <pthread.h> +#include "un-namespace.h" #include "thr_private.h" LT10_COMPAT_PRIVATE(_pthread_attr_getscope); diff --git a/lib/libkse/thread/thr_attr_getstack.c b/lib/libkse/thread/thr_attr_getstack.c index 79a92cb..2278bb2 100644 --- a/lib/libkse/thread/thr_attr_getstack.c +++ b/lib/libkse/thread/thr_attr_getstack.c @@ -31,8 +31,11 @@ * * $FreeBSD$ */ + +#include "namespace.h" #include <errno.h> #include <pthread.h> +#include "un-namespace.h" #include "thr_private.h" LT10_COMPAT_PRIVATE(_pthread_attr_getstack); diff --git a/lib/libkse/thread/thr_attr_getstackaddr.c b/lib/libkse/thread/thr_attr_getstackaddr.c index ed526da..76de764 100644 --- a/lib/libkse/thread/thr_attr_getstackaddr.c +++ b/lib/libkse/thread/thr_attr_getstackaddr.c @@ -28,8 +28,11 @@ * * $FreeBSD$ */ + +#include "namespace.h" #include <errno.h> #include <pthread.h> +#include "un-namespace.h" #include "thr_private.h" LT10_COMPAT_PRIVATE(_pthread_attr_getstackaddr); diff --git a/lib/libkse/thread/thr_attr_getstacksize.c b/lib/libkse/thread/thr_attr_getstacksize.c index 4ccced6..57fe614 100644 --- a/lib/libkse/thread/thr_attr_getstacksize.c +++ b/lib/libkse/thread/thr_attr_getstacksize.c @@ -28,8 +28,11 @@ * * $FreeBSD$ */ + +#include "namespace.h" #include <errno.h> #include <pthread.h> +#include "un-namespace.h" #include "thr_private.h" LT10_COMPAT_PRIVATE(_pthread_attr_getstacksize); diff --git a/lib/libkse/thread/thr_attr_init.c b/lib/libkse/thread/thr_attr_init.c index af6260e..b5a966d 100644 --- a/lib/libkse/thread/thr_attr_init.c +++ b/lib/libkse/thread/thr_attr_init.c @@ -28,10 +28,13 @@ * * $FreeBSD$ */ + +#include "namespace.h" #include <string.h> #include <stdlib.h> #include <errno.h> #include <pthread.h> +#include "un-namespace.h" #include "thr_private.h" LT10_COMPAT_PRIVATE(_pthread_attr_init); diff --git a/lib/libkse/thread/thr_attr_setcreatesuspend_np.c b/lib/libkse/thread/thr_attr_setcreatesuspend_np.c index 8ff485b..b72ce81 100644 --- a/lib/libkse/thread/thr_attr_setcreatesuspend_np.c +++ b/lib/libkse/thread/thr_attr_setcreatesuspend_np.c @@ -28,13 +28,18 @@ * * $FreeBSD$ */ + +#include "namespace.h" #include <errno.h> #include <pthread.h> +#include "un-namespace.h" #include "thr_private.h" LT10_COMPAT_PRIVATE(_pthread_attr_setcreatesuspend_np); LT10_COMPAT_DEFAULT(pthread_attr_setcreatesuspend_np); +int _pthread_attr_setcreatesuspend_np(pthread_attr_t *attr); + __weak_reference(_pthread_attr_setcreatesuspend_np, pthread_attr_setcreatesuspend_np); int diff --git a/lib/libkse/thread/thr_attr_setdetachstate.c b/lib/libkse/thread/thr_attr_setdetachstate.c index ebffd20..d1eb135 100644 --- a/lib/libkse/thread/thr_attr_setdetachstate.c +++ b/lib/libkse/thread/thr_attr_setdetachstate.c @@ -28,8 +28,11 @@ * * $FreeBSD$ */ + +#include "namespace.h" #include <errno.h> #include <pthread.h> +#include "un-namespace.h" #include "thr_private.h" LT10_COMPAT_PRIVATE(_pthread_attr_setdetachstate); diff --git a/lib/libkse/thread/thr_attr_setguardsize.c b/lib/libkse/thread/thr_attr_setguardsize.c index dedee8b..f396f82 100644 --- a/lib/libkse/thread/thr_attr_setguardsize.c +++ b/lib/libkse/thread/thr_attr_setguardsize.c @@ -29,9 +29,11 @@ * $FreeBSD$ */ +#include "namespace.h" #include <sys/param.h> #include <errno.h> #include <pthread.h> +#include "un-namespace.h" #include "thr_private.h" LT10_COMPAT_PRIVATE(_pthread_attr_setguardsize); diff --git a/lib/libkse/thread/thr_attr_setinheritsched.c b/lib/libkse/thread/thr_attr_setinheritsched.c index 5182b7d..593f148 100644 --- a/lib/libkse/thread/thr_attr_setinheritsched.c +++ b/lib/libkse/thread/thr_attr_setinheritsched.c @@ -31,8 +31,11 @@ * * $FreeBSD$ */ + +#include "namespace.h" #include <errno.h> #include <pthread.h> +#include "un-namespace.h" #include "thr_private.h" LT10_COMPAT_PRIVATE(_pthread_attr_setinheritsched); diff --git a/lib/libkse/thread/thr_attr_setschedparam.c b/lib/libkse/thread/thr_attr_setschedparam.c index 61d741d..979c502 100644 --- a/lib/libkse/thread/thr_attr_setschedparam.c +++ b/lib/libkse/thread/thr_attr_setschedparam.c @@ -31,8 +31,11 @@ * * $FreeBSD$ */ + +#include "namespace.h" #include <errno.h> #include <pthread.h> +#include "un-namespace.h" #include "thr_private.h" LT10_COMPAT_PRIVATE(_pthread_attr_setschedparam); diff --git a/lib/libkse/thread/thr_attr_setschedpolicy.c b/lib/libkse/thread/thr_attr_setschedpolicy.c index fb24cb1..d8fb5ef 100644 --- a/lib/libkse/thread/thr_attr_setschedpolicy.c +++ b/lib/libkse/thread/thr_attr_setschedpolicy.c @@ -31,8 +31,11 @@ * * $FreeBSD$ */ + +#include "namespace.h" #include <errno.h> #include <pthread.h> +#include "un-namespace.h" #include "thr_private.h" LT10_COMPAT_PRIVATE(_pthread_attr_setschedpolicy); diff --git a/lib/libkse/thread/thr_attr_setscope.c b/lib/libkse/thread/thr_attr_setscope.c index 3cc7f16..a295f25 100644 --- a/lib/libkse/thread/thr_attr_setscope.c +++ b/lib/libkse/thread/thr_attr_setscope.c @@ -31,8 +31,11 @@ * * $FreeBSD$ */ + +#include "namespace.h" #include <errno.h> #include <pthread.h> +#include "un-namespace.h" #include "thr_private.h" LT10_COMPAT_PRIVATE(_pthread_attr_setscope); diff --git a/lib/libkse/thread/thr_attr_setstack.c b/lib/libkse/thread/thr_attr_setstack.c index bdccfd8..9be6ebd 100644 --- a/lib/libkse/thread/thr_attr_setstack.c +++ b/lib/libkse/thread/thr_attr_setstack.c @@ -31,8 +31,11 @@ * * $FreeBSD$ */ + +#include "namespace.h" #include <errno.h> #include <pthread.h> +#include "un-namespace.h" #include "thr_private.h" LT10_COMPAT_PRIVATE(_pthread_attr_setstack); diff --git a/lib/libkse/thread/thr_attr_setstackaddr.c b/lib/libkse/thread/thr_attr_setstackaddr.c index f82729a..da81e1f 100644 --- a/lib/libkse/thread/thr_attr_setstackaddr.c +++ b/lib/libkse/thread/thr_attr_setstackaddr.c @@ -28,8 +28,11 @@ * * $FreeBSD$ */ + +#include "namespace.h" #include <errno.h> #include <pthread.h> +#include "un-namespace.h" #include "thr_private.h" LT10_COMPAT_PRIVATE(_pthread_attr_setstackaddr); diff --git a/lib/libkse/thread/thr_attr_setstacksize.c b/lib/libkse/thread/thr_attr_setstacksize.c index 590e71e..c24c6ec 100644 --- a/lib/libkse/thread/thr_attr_setstacksize.c +++ b/lib/libkse/thread/thr_attr_setstacksize.c @@ -28,8 +28,11 @@ * * $FreeBSD$ */ + +#include "namespace.h" #include <errno.h> #include <pthread.h> +#include "un-namespace.h" #include "thr_private.h" LT10_COMPAT_PRIVATE(_pthread_attr_setstacksize); diff --git a/lib/libkse/thread/thr_barrier.c b/lib/libkse/thread/thr_barrier.c index c8be343..ca26437 100644 --- a/lib/libkse/thread/thr_barrier.c +++ b/lib/libkse/thread/thr_barrier.c @@ -26,9 +26,9 @@ * $FreeBSD$ */ +#include "namespace.h" #include <errno.h> #include <stdlib.h> -#include "namespace.h" #include <pthread.h> #include "un-namespace.h" #include "thr_private.h" @@ -65,7 +65,7 @@ _pthread_barrier_destroy(pthread_barrier_t *barrier) int _pthread_barrier_init(pthread_barrier_t *barrier, - const pthread_barrierattr_t *attr, unsigned count) + const pthread_barrierattr_t *attr __unused, unsigned count) { pthread_barrier_t bar; int ret; diff --git a/lib/libkse/thread/thr_barrierattr.c b/lib/libkse/thread/thr_barrierattr.c index 3384aee..9b05fc4 100644 --- a/lib/libkse/thread/thr_barrierattr.c +++ b/lib/libkse/thread/thr_barrierattr.c @@ -28,9 +28,11 @@ * $FreeBSD$ */ +#include "namespace.h" #include <errno.h> #include <stdlib.h> #include <pthread.h> +#include "un-namespace.h" #include "thr_private.h" LT10_COMPAT_PRIVATE(_pthread_barrierattr_destroy); diff --git a/lib/libkse/thread/thr_cancel.c b/lib/libkse/thread/thr_cancel.c index bbf6fdf..8dfcb4d 100644 --- a/lib/libkse/thread/thr_cancel.c +++ b/lib/libkse/thread/thr_cancel.c @@ -2,8 +2,10 @@ * David Leonard <d@openbsd.org>, 1999. Public domain. * $FreeBSD$ */ +#include "namespace.h" #include <sys/errno.h> #include <pthread.h> +#include "un-namespace.h" #include "thr_private.h" LT10_COMPAT_PRIVATE(_pthread_cancel); @@ -53,7 +55,7 @@ testcancel(struct pthread *curthread) THR_THREAD_UNLOCK(curthread, curthread); _thr_exit_cleanup(); - pthread_exit(PTHREAD_CANCELED); + _pthread_exit(PTHREAD_CANCELED); PANIC("cancel"); } } @@ -214,7 +216,7 @@ _pthread_setcancelstate(int state, int *oldstate) THR_THREAD_UNLOCK(curthread, curthread); if (need_exit != 0) { _thr_exit_cleanup(); - pthread_exit(PTHREAD_CANCELED); + _pthread_exit(PTHREAD_CANCELED); PANIC("cancel"); } if (ret == 0 && oldstate != NULL) @@ -252,7 +254,7 @@ _pthread_setcanceltype(int type, int *oldtype) THR_THREAD_UNLOCK(curthread, curthread); if (need_exit != 0) { _thr_exit_cleanup(); - pthread_exit(PTHREAD_CANCELED); + _pthread_exit(PTHREAD_CANCELED); PANIC("cancel"); } if (ret == 0 && oldtype != NULL) @@ -293,7 +295,7 @@ _thr_cancel_leave(struct pthread *thread, int check) } void -_thr_finish_cancellation(void *arg) +_thr_finish_cancellation(void *arg __unused) { struct pthread *curthread = _get_curthread(); @@ -305,7 +307,7 @@ _thr_finish_cancellation(void *arg) curthread->cancelflags &= ~THR_CANCEL_NEEDED; THR_THREAD_UNLOCK(curthread, curthread); _thr_exit_cleanup(); - pthread_exit(PTHREAD_CANCELED); + _pthread_exit(PTHREAD_CANCELED); } THR_THREAD_UNLOCK(curthread, curthread); } diff --git a/lib/libkse/thread/thr_clean.c b/lib/libkse/thread/thr_clean.c index 0153e99..13501ba 100644 --- a/lib/libkse/thread/thr_clean.c +++ b/lib/libkse/thread/thr_clean.c @@ -28,10 +28,13 @@ * * $FreeBSD$ */ + +#include "namespace.h" #include <signal.h> #include <errno.h> #include <stdlib.h> #include <pthread.h> +#include "un-namespace.h" #include "thr_private.h" LT10_COMPAT_PRIVATE(_pthread_cleanup_push); diff --git a/lib/libkse/thread/thr_close.c b/lib/libkse/thread/thr_close.c index 66747af..349ebaa 100644 --- a/lib/libkse/thread/thr_close.c +++ b/lib/libkse/thread/thr_close.c @@ -28,17 +28,22 @@ * * $FreeBSD$ */ + +#include "namespace.h" #include <errno.h> #include <stdlib.h> #include <unistd.h> #include <fcntl.h> #include <sys/stat.h> #include <pthread.h> +#include "un-namespace.h" #include "thr_private.h" LT10_COMPAT_PRIVATE(__close); LT10_COMPAT_DEFAULT(close); +int __close(int fd); + __weak_reference(__close, close); int diff --git a/lib/libkse/thread/thr_concurrency.c b/lib/libkse/thread/thr_concurrency.c index 74e0e11..d8e2a18 100644 --- a/lib/libkse/thread/thr_concurrency.c +++ b/lib/libkse/thread/thr_concurrency.c @@ -26,10 +26,13 @@ * * $FreeBSD$ */ + +#include "namespace.h" #include <errno.h> #include <pthread.h> #include <sys/types.h> #include <sys/sysctl.h> +#include "un-namespace.h" #include "thr_private.h" diff --git a/lib/libkse/thread/thr_cond.c b/lib/libkse/thread/thr_cond.c index 8e2582a..d5436c4 100644 --- a/lib/libkse/thread/thr_cond.c +++ b/lib/libkse/thread/thr_cond.c @@ -28,10 +28,13 @@ * * $FreeBSD$ */ + +#include "namespace.h" #include <stdlib.h> #include <errno.h> #include <string.h> #include <pthread.h> +#include "un-namespace.h" #include "thr_private.h" LT10_COMPAT_PRIVATE(__pthread_cond_wait); @@ -63,6 +66,10 @@ static void cond_wait_backout(void *); static inline void check_continuation(struct pthread *, struct pthread_cond *, pthread_mutex_t *); +int __pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex); +int __pthread_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex, + const struct timespec *abstime); + /* * Double underscore versions are cancellation points. Single underscore * versions are not and are provided for libc internal usage (which @@ -197,7 +204,7 @@ _pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex) * perform the dynamic initialization: */ if (*cond == NULL && - (rval = pthread_cond_init(cond, NULL)) != 0) + (rval = _pthread_cond_init(cond, NULL)) != 0) return (rval); if (!_kse_isthreaded()) @@ -395,7 +402,7 @@ _pthread_cond_timedwait(pthread_cond_t * cond, pthread_mutex_t * mutex, * If the condition variable is statically initialized, perform dynamic * initialization. */ - if (*cond == NULL && (rval = pthread_cond_init(cond, NULL)) != 0) + if (*cond == NULL && (rval = _pthread_cond_init(cond, NULL)) != 0) return (rval); if (!_kse_isthreaded()) @@ -596,7 +603,7 @@ _pthread_cond_signal(pthread_cond_t * cond) * If the condition variable is statically initialized, perform dynamic * initialization. */ - else if (*cond != NULL || (rval = pthread_cond_init(cond, NULL)) == 0) { + else if (*cond != NULL || (rval = _pthread_cond_init(cond, NULL)) == 0) { /* Lock the condition variable structure: */ THR_LOCK_ACQUIRE(curthread, &(*cond)->c_lock); @@ -665,7 +672,7 @@ _pthread_cond_broadcast(pthread_cond_t * cond) * If the condition variable is statically initialized, perform dynamic * initialization. */ - else if (*cond != NULL || (rval = pthread_cond_init(cond, NULL)) == 0) { + else if (*cond != NULL || (rval = _pthread_cond_init(cond, NULL)) == 0) { /* Lock the condition variable structure: */ THR_LOCK_ACQUIRE(curthread, &(*cond)->c_lock); diff --git a/lib/libkse/thread/thr_condattr_destroy.c b/lib/libkse/thread/thr_condattr_destroy.c index 3805a62..a2925d2 100644 --- a/lib/libkse/thread/thr_condattr_destroy.c +++ b/lib/libkse/thread/thr_condattr_destroy.c @@ -28,9 +28,12 @@ * * $FreeBSD$ */ + +#include "namespace.h" #include <stdlib.h> #include <errno.h> #include <pthread.h> +#include "un-namespace.h" #include "thr_private.h" LT10_COMPAT_PRIVATE(_pthread_condattr_destroy); diff --git a/lib/libkse/thread/thr_condattr_init.c b/lib/libkse/thread/thr_condattr_init.c index 0b86566..7b48732 100644 --- a/lib/libkse/thread/thr_condattr_init.c +++ b/lib/libkse/thread/thr_condattr_init.c @@ -28,10 +28,13 @@ * * $FreeBSD$ */ + +#include "namespace.h" #include <string.h> #include <stdlib.h> #include <errno.h> #include <pthread.h> +#include "un-namespace.h" #include "thr_private.h" LT10_COMPAT_PRIVATE(_pthread_condattr_init); diff --git a/lib/libkse/thread/thr_condattr_pshared.c b/lib/libkse/thread/thr_condattr_pshared.c index 7cef4d9..79e1d60 100644 --- a/lib/libkse/thread/thr_condattr_pshared.c +++ b/lib/libkse/thread/thr_condattr_pshared.c @@ -30,6 +30,9 @@ #include <errno.h> #include "thr_private.h" +int _pthread_condattr_getpshared(const pthread_condattr_t *attr, int *pshared); +int _pthread_condattr_setpshared(pthread_condattr_t *attr, int pshared); + __weak_reference(_pthread_condattr_getpshared, pthread_condattr_getpshared); __weak_reference(_pthread_condattr_setpshared, pthread_condattr_setpshared); diff --git a/lib/libkse/thread/thr_connect.c b/lib/libkse/thread/thr_connect.c index 225d8b9..90331a4 100644 --- a/lib/libkse/thread/thr_connect.c +++ b/lib/libkse/thread/thr_connect.c @@ -35,6 +35,8 @@ __FBSDID("$FreeBSD$"); LT10_COMPAT_PRIVATE(__connect); LT10_COMPAT_DEFAULT(connect); +int __connect(int fd, const struct sockaddr *name, socklen_t namelen); + __weak_reference(__connect, connect); int diff --git a/lib/libkse/thread/thr_creat.c b/lib/libkse/thread/thr_creat.c index 7528f0b..d0a2947 100644 --- a/lib/libkse/thread/thr_creat.c +++ b/lib/libkse/thread/thr_creat.c @@ -29,8 +29,10 @@ * $FreeBSD$ */ +#include "namespace.h" #include <fcntl.h> #include <pthread.h> +#include "un-namespace.h" #include "thr_private.h" LT10_COMPAT_PRIVATE(___creat); @@ -38,6 +40,8 @@ LT10_COMPAT_DEFAULT(creat); extern int __creat(const char *, mode_t); +int ___creat(const char *path, mode_t mode); + __weak_reference(___creat, creat); int diff --git a/lib/libkse/thread/thr_create.c b/lib/libkse/thread/thr_create.c index f4bd4758..e699b74 100644 --- a/lib/libkse/thread/thr_create.c +++ b/lib/libkse/thread/thr_create.c @@ -29,6 +29,8 @@ * * $FreeBSD$ */ + +#include "namespace.h" #include <errno.h> #include <stdlib.h> #include <string.h> @@ -38,6 +40,7 @@ #include <sys/time.h> #include <machine/reg.h> #include <pthread.h> +#include "un-namespace.h" #include "thr_private.h" #include "libc_private.h" @@ -334,11 +337,11 @@ free_stack(struct pthread_attr *pattr) } static void -thread_start(struct pthread *curthread, void *(*start_routine) (void *), +thread_start(struct pthread *curthread __unused, void *(*start_routine) (void *), void *arg) { /* Run the current thread's start routine with argument: */ - pthread_exit(start_routine(arg)); + _pthread_exit(start_routine(arg)); /* This point should never be reached. */ PANIC("Thread has resumed after exit"); diff --git a/lib/libkse/thread/thr_detach.c b/lib/libkse/thread/thr_detach.c index 0c0c0c8..2e2a290 100644 --- a/lib/libkse/thread/thr_detach.c +++ b/lib/libkse/thread/thr_detach.c @@ -28,10 +28,12 @@ * * $FreeBSD$ */ +#include "namespace.h" #include <sys/types.h> #include <machine/atomic.h> #include <errno.h> #include <pthread.h> +#include "un-namespace.h" #include "thr_private.h" LT10_COMPAT_PRIVATE(_pthread_detach); diff --git a/lib/libkse/thread/thr_equal.c b/lib/libkse/thread/thr_equal.c index 0ac747a..78cd6b5 100644 --- a/lib/libkse/thread/thr_equal.c +++ b/lib/libkse/thread/thr_equal.c @@ -28,7 +28,10 @@ * * $FreeBSD$ */ + +#include "namespace.h" #include <pthread.h> +#include "un-namespace.h" #include "thr_private.h" LT10_COMPAT_PRIVATE(_pthread_equal); diff --git a/lib/libkse/thread/thr_execve.c b/lib/libkse/thread/thr_execve.c index b902981..a12cf7f 100644 --- a/lib/libkse/thread/thr_execve.c +++ b/lib/libkse/thread/thr_execve.c @@ -29,9 +29,11 @@ * $FreeBSD$ */ +#include "namespace.h" #include <errno.h> #include <pthread.h> #include <unistd.h> +#include "un-namespace.h" #include "thr_private.h" LT10_COMPAT_PRIVATE(_execve); diff --git a/lib/libkse/thread/thr_exit.c b/lib/libkse/thread/thr_exit.c index ba82fd1..fc93ccb 100644 --- a/lib/libkse/thread/thr_exit.c +++ b/lib/libkse/thread/thr_exit.c @@ -28,6 +28,8 @@ * * $FreeBSD$ */ + +#include "namespace.h" #include <errno.h> #include <unistd.h> #include <fcntl.h> @@ -35,6 +37,7 @@ #include <stdlib.h> #include <string.h> #include <pthread.h> +#include "un-namespace.h" #include "thr_private.h" LT10_COMPAT_PRIVATE(_pthread_exit); @@ -45,7 +48,7 @@ void _pthread_exit(void *status); __weak_reference(_pthread_exit, pthread_exit); void -_thr_exit(char *fname, int lineno, char *msg) +_thr_exit(const char *fname, int lineno, const char *msg) { /* Write an error message to the standard error file descriptor: */ @@ -122,7 +125,7 @@ _pthread_exit(void *status) /* Save the return value: */ curthread->ret = status; while (curthread->cleanup != NULL) { - pthread_cleanup_pop(1); + _pthread_cleanup_pop(1); } if (curthread->attr.cleanup_attr != NULL) { curthread->attr.cleanup_attr(curthread->attr.arg_attr); diff --git a/lib/libkse/thread/thr_fcntl.c b/lib/libkse/thread/thr_fcntl.c index af531b3..f880fcb 100644 --- a/lib/libkse/thread/thr_fcntl.c +++ b/lib/libkse/thread/thr_fcntl.c @@ -28,16 +28,19 @@ * * $FreeBSD$ */ -#include <stdarg.h> + #include "namespace.h" +#include <stdarg.h> #include <fcntl.h> -#include "un-namespace.h" #include <pthread.h> +#include "un-namespace.h" #include "thr_private.h" LT10_COMPAT_PRIVATE(__fcntl); LT10_COMPAT_DEFAULT(fcntl); +int __fcntl(int fd, int cmd,...); + __weak_reference(__fcntl, fcntl); int diff --git a/lib/libkse/thread/thr_find_thread.c b/lib/libkse/thread/thr_find_thread.c index 780624e..e146e97 100644 --- a/lib/libkse/thread/thr_find_thread.c +++ b/lib/libkse/thread/thr_find_thread.c @@ -29,8 +29,11 @@ * * $FreeBSD$ */ + +#include "namespace.h" #include <errno.h> #include <pthread.h> +#include "un-namespace.h" #include "thr_private.h" /* diff --git a/lib/libkse/thread/thr_fork.c b/lib/libkse/thread/thr_fork.c index 1fd212e..0b1c639 100644 --- a/lib/libkse/thread/thr_fork.c +++ b/lib/libkse/thread/thr_fork.c @@ -28,6 +28,8 @@ * * $FreeBSD$ */ + +#include "namespace.h" #include <errno.h> #include <string.h> #include <stdlib.h> @@ -36,6 +38,7 @@ #include <pthread.h> #include <spinlock.h> #include <sys/signalvar.h> +#include "un-namespace.h" #include "libc_private.h" #include "thr_private.h" @@ -43,6 +46,8 @@ LT10_COMPAT_PRIVATE(_fork); LT10_COMPAT_DEFAULT(fork); +pid_t _fork(void); + __weak_reference(_fork, fork); pid_t diff --git a/lib/libkse/thread/thr_fsync.c b/lib/libkse/thread/thr_fsync.c index 9d17050..e040770 100644 --- a/lib/libkse/thread/thr_fsync.c +++ b/lib/libkse/thread/thr_fsync.c @@ -28,13 +28,18 @@ * * $FreeBSD$ */ + +#include "namespace.h" #include <unistd.h> #include <pthread.h> +#include "un-namespace.h" #include "thr_private.h" LT10_COMPAT_PRIVATE(__fsync); LT10_COMPAT_DEFAULT(fsync); +int __fsync(int fd); + __weak_reference(__fsync, fsync); int diff --git a/lib/libkse/thread/thr_getschedparam.c b/lib/libkse/thread/thr_getschedparam.c index dca342f..a56672f 100644 --- a/lib/libkse/thread/thr_getschedparam.c +++ b/lib/libkse/thread/thr_getschedparam.c @@ -31,8 +31,11 @@ * * $FreeBSD$ */ + +#include "namespace.h" #include <errno.h> #include <pthread.h> +#include "un-namespace.h" #include "thr_private.h" LT10_COMPAT_PRIVATE(_pthread_getschedparam); diff --git a/lib/libkse/thread/thr_info.c b/lib/libkse/thread/thr_info.c index e8dc506..1d7c3f8 100644 --- a/lib/libkse/thread/thr_info.c +++ b/lib/libkse/thread/thr_info.c @@ -28,6 +28,8 @@ * * $FreeBSD$ */ + +#include "namespace.h" #include <stdio.h> #include <stdlib.h> #include <fcntl.h> @@ -35,6 +37,7 @@ #include <unistd.h> #include <pthread.h> #include <errno.h> +#include "un-namespace.h" #include "thr_private.h" #ifndef NELEMENTS @@ -45,12 +48,13 @@ LT10_COMPAT_PRIVATE(_pthread_set_name_np); LT10_COMPAT_DEFAULT(pthread_set_name_np); static void dump_thread(int fd, pthread_t pthread, int long_version); +void _pthread_set_name_np(pthread_t thread, char *name); __weak_reference(_pthread_set_name_np, pthread_set_name_np); struct s_thread_info { enum pthread_state state; - char *name; + const char *name; }; /* Static variables: */ @@ -72,15 +76,15 @@ static const struct s_thread_info thread_info[] = { void _thread_dump_info(void) { - char s[512], tmpfile[128]; + char s[512], tempfile[128]; pthread_t pthread; int fd, i; for (i = 0; i < 100000; i++) { - snprintf(tmpfile, sizeof(tmpfile), "/tmp/pthread.dump.%u.%i", + snprintf(tempfile, sizeof(tempfile), "/tmp/pthread.dump.%u.%i", getpid(), i); /* Open the dump file for append and create it if necessary: */ - if ((fd = __sys_open(tmpfile, O_RDWR | O_CREAT | O_EXCL, + if ((fd = __sys_open(tempfile, O_RDWR | O_CREAT | O_EXCL, 0666)) < 0) { /* Can't open the dump file. */ if (errno == EEXIST) @@ -140,7 +144,7 @@ dump_thread(int fd, pthread_t pthread, int long_version) int i; /* Find the state: */ - for (i = 0; i < NELEMENTS(thread_info) - 1; i++) + for (i = 0; i < (int)NELEMENTS(thread_info) - 1; i++) if (thread_info[i].state == pthread->state) break; diff --git a/lib/libkse/thread/thr_init.c b/lib/libkse/thread/thr_init.c index 424378d..8f9ea6a 100644 --- a/lib/libkse/thread/thr_init.c +++ b/lib/libkse/thread/thr_init.c @@ -370,8 +370,8 @@ init_main_thread(struct pthread *thread) * resource limits, so this stack needs an explicitly mapped * red zone to protect the thread stack that is just beyond. */ - if (mmap((void *)_usrstack - _thr_stack_initial - - _thr_guard_default, _thr_guard_default, 0, MAP_ANON, + if (mmap((void *)((uintptr_t)_usrstack - _thr_stack_initial - + _thr_guard_default), _thr_guard_default, 0, MAP_ANON, -1, 0) == MAP_FAILED) PANIC("Cannot allocate red zone for initial thread"); @@ -384,7 +384,8 @@ init_main_thread(struct pthread *thread) * actually free() it; it just puts it in the free * stack queue for later reuse. */ - thread->attr.stackaddr_attr = (void *)_usrstack - _thr_stack_initial; + thread->attr.stackaddr_attr = (void *)((uintptr_t)_usrstack - + _thr_stack_initial); thread->attr.stacksize_attr = _thr_stack_initial; thread->attr.guardsize_attr = _thr_guard_default; thread->attr.flags |= THR_STACK_USER; diff --git a/lib/libkse/thread/thr_join.c b/lib/libkse/thread/thr_join.c index 2396034..b606f5f 100644 --- a/lib/libkse/thread/thr_join.c +++ b/lib/libkse/thread/thr_join.c @@ -28,8 +28,11 @@ * * $FreeBSD$ */ + +#include "namespace.h" #include <errno.h> #include <pthread.h> +#include "un-namespace.h" #include "thr_private.h" LT10_COMPAT_PRIVATE(_pthread_join); @@ -143,7 +146,7 @@ _pthread_join(pthread_t pthread, void **thread_return) THR_SCHED_UNLOCK(curthread, pthread); _thr_ref_delete(curthread, pthread); } - pthread_exit(PTHREAD_CANCELED); + _pthread_exit(PTHREAD_CANCELED); } /* diff --git a/lib/libkse/thread/thr_kill.c b/lib/libkse/thread/thr_kill.c index 2aee0ac..fd8fdca 100644 --- a/lib/libkse/thread/thr_kill.c +++ b/lib/libkse/thread/thr_kill.c @@ -28,9 +28,12 @@ * * $FreeBSD$ */ + +#include "namespace.h" #include <errno.h> #include <signal.h> #include <pthread.h> +#include "un-namespace.h" #include "thr_private.h" LT10_COMPAT_PRIVATE(_pthread_kill); diff --git a/lib/libkse/thread/thr_main_np.c b/lib/libkse/thread/thr_main_np.c index 50fb9c8..78b6754 100644 --- a/lib/libkse/thread/thr_main_np.c +++ b/lib/libkse/thread/thr_main_np.c @@ -27,8 +27,10 @@ * $FreeBSD$ */ +#include "namespace.h" #include <pthread.h> #include <pthread_np.h> +#include "un-namespace.h" #include "thr_private.h" LT10_COMPAT_PRIVATE(_pthread_main_np); @@ -46,5 +48,5 @@ _pthread_main_np() if (!_thr_initial) return (-1); else - return (pthread_equal(pthread_self(), _thr_initial) ? 1 : 0); + return (_pthread_equal(_pthread_self(), _thr_initial) ? 1 : 0); } diff --git a/lib/libkse/thread/thr_mattr_init.c b/lib/libkse/thread/thr_mattr_init.c index b273bab..aadac4b 100644 --- a/lib/libkse/thread/thr_mattr_init.c +++ b/lib/libkse/thread/thr_mattr_init.c @@ -31,10 +31,13 @@ * * $FreeBSD$ */ + +#include "namespace.h" #include <string.h> #include <stdlib.h> #include <errno.h> #include <pthread.h> +#include "un-namespace.h" #include "thr_private.h" LT10_COMPAT_PRIVATE(_pthread_mutexattr_init); diff --git a/lib/libkse/thread/thr_mattr_kind_np.c b/lib/libkse/thread/thr_mattr_kind_np.c index f90f31a..8b82a25 100644 --- a/lib/libkse/thread/thr_mattr_kind_np.c +++ b/lib/libkse/thread/thr_mattr_kind_np.c @@ -28,8 +28,11 @@ * * $FreeBSD$ */ + +#include "namespace.h" #include <errno.h> #include <pthread.h> +#include "un-namespace.h" #include "thr_private.h" LT10_COMPAT_PRIVATE(_pthread_mutexattr_setkind_np); @@ -41,6 +44,9 @@ LT10_COMPAT_DEFAULT(pthread_mutexattr_gettype); LT10_COMPAT_PRIVATE(_pthread_mutexattr_settype); LT10_COMPAT_DEFAULT(pthread_mutexattr_settype); +int _pthread_mutexattr_setkind_np(pthread_mutexattr_t *attr, int kind); +int _pthread_mutexattr_getkind_np(pthread_mutexattr_t attr); + __weak_reference(_pthread_mutexattr_setkind_np, pthread_mutexattr_setkind_np); __weak_reference(_pthread_mutexattr_getkind_np, pthread_mutexattr_getkind_np); __weak_reference(_pthread_mutexattr_gettype, pthread_mutexattr_gettype); diff --git a/lib/libkse/thread/thr_mattr_pshared.c b/lib/libkse/thread/thr_mattr_pshared.c index 03aff41..12d731c 100644 --- a/lib/libkse/thread/thr_mattr_pshared.c +++ b/lib/libkse/thread/thr_mattr_pshared.c @@ -27,9 +27,16 @@ * */ +#include "namespace.h" #include <errno.h> +#include "un-namespace.h" #include "thr_private.h" +int _pthread_mutexattr_getpshared(const pthread_mutexattr_t *attr, + int *pshared); +int _pthread_mutexattr_setpshared(pthread_mutexattr_t *attr, int pshared); + + __weak_reference(_pthread_mutexattr_getpshared, pthread_mutexattr_getpshared); __weak_reference(_pthread_mutexattr_setpshared, pthread_mutexattr_setpshared); diff --git a/lib/libkse/thread/thr_msync.c b/lib/libkse/thread/thr_msync.c index 66e88c5..f51a6a3 100644 --- a/lib/libkse/thread/thr_msync.c +++ b/lib/libkse/thread/thr_msync.c @@ -6,14 +6,18 @@ * $FreeBSD$ */ +#include "namespace.h" #include <sys/types.h> #include <sys/mman.h> #include <pthread.h> +#include "un-namespace.h" #include "thr_private.h" LT10_COMPAT_PRIVATE(__msync); LT10_COMPAT_DEFAULT(msync); +int __msync(void *addr, size_t len, int flags); + __weak_reference(__msync, msync); int @@ -32,5 +36,5 @@ __msync(void *addr, size_t len, int flags) ret = __sys_msync(addr, len, flags); _thr_cancel_leave(curthread, 1); - return ret; + return (ret); } diff --git a/lib/libkse/thread/thr_multi_np.c b/lib/libkse/thread/thr_multi_np.c index f2bdd24..9e76c2a 100644 --- a/lib/libkse/thread/thr_multi_np.c +++ b/lib/libkse/thread/thr_multi_np.c @@ -28,9 +28,11 @@ * * $FreeBSD$ */ + +#include "namespace.h" #include <pthread.h> #include <pthread_np.h> - +#include "un-namespace.h" #include "thr_private.h" LT10_COMPAT_PRIVATE(_pthread_multi_np); @@ -47,6 +49,6 @@ _pthread_multi_np() * XXX - Do we want to do this? * __is_threaded = 1; */ - pthread_resume_all_np(); + _pthread_resume_all_np(); return (0); } diff --git a/lib/libkse/thread/thr_mutex.c b/lib/libkse/thread/thr_mutex.c index 3a3546b..fe101c7 100644 --- a/lib/libkse/thread/thr_mutex.c +++ b/lib/libkse/thread/thr_mutex.c @@ -28,12 +28,15 @@ * * $FreeBSD$ */ + +#include "namespace.h" #include <stdlib.h> #include <errno.h> #include <string.h> #include <sys/param.h> #include <sys/queue.h> #include <pthread.h> +#include "un-namespace.h" #include "thr_private.h" #if defined(_PTHREADS_INVARIANTS) @@ -73,7 +76,7 @@ */ static struct kse_mailbox *mutex_handoff(struct pthread *, struct pthread_mutex *); -static inline int mutex_self_trylock(struct pthread *, pthread_mutex_t); +static inline int mutex_self_trylock(pthread_mutex_t); static inline int mutex_self_lock(struct pthread *, pthread_mutex_t); static int mutex_unlock_common(pthread_mutex_t *, int); static void mutex_priority_adjust(struct pthread *, pthread_mutex_t); @@ -84,6 +87,16 @@ static inline void mutex_queue_remove(pthread_mutex_t, pthread_t); static inline void mutex_queue_enq(pthread_mutex_t, pthread_t); static void mutex_lock_backout(void *arg); +int __pthread_mutex_init(pthread_mutex_t *mutex, + const pthread_mutexattr_t *mutex_attr); +int __pthread_mutex_trylock(pthread_mutex_t *mutex); +int __pthread_mutex_lock(pthread_mutex_t *m); +int __pthread_mutex_timedlock(pthread_mutex_t *m, + const struct timespec *abs_timeout); +int _pthread_mutex_init_calloc_cb(pthread_mutex_t *mutex, + void *(calloc_cb)(size_t, size_t)); + + static struct pthread_mutex_attr static_mutex_attr = PTHREAD_MUTEXATTR_STATIC_INITIALIZER; static pthread_mutexattr_t static_mattr = &static_mutex_attr; @@ -328,7 +341,7 @@ init_static(struct pthread *thread, pthread_mutex_t *mutex) THR_LOCK_ACQUIRE(thread, &_mutex_static_lock); if (*mutex == NULL) - ret = pthread_mutex_init(mutex, NULL); + ret = _pthread_mutex_init(mutex, NULL); else ret = 0; @@ -345,7 +358,7 @@ init_static_private(struct pthread *thread, pthread_mutex_t *mutex) THR_LOCK_ACQUIRE(thread, &_mutex_static_lock); if (*mutex == NULL) - ret = pthread_mutex_init(mutex, &static_mattr); + ret = _pthread_mutex_init(mutex, &static_mattr); else ret = 0; @@ -391,7 +404,7 @@ mutex_trylock_common(struct pthread *curthread, pthread_mutex_t *mutex) TAILQ_INSERT_TAIL(&curthread->mutexq, (*mutex), m_qe); } else if ((*mutex)->m_owner == curthread) - ret = mutex_self_trylock(curthread, *mutex); + ret = mutex_self_trylock(*mutex); else /* Return a busy error: */ ret = EBUSY; @@ -423,7 +436,7 @@ mutex_trylock_common(struct pthread *curthread, pthread_mutex_t *mutex) TAILQ_INSERT_TAIL(&curthread->mutexq, (*mutex), m_qe); } else if ((*mutex)->m_owner == curthread) - ret = mutex_self_trylock(curthread, *mutex); + ret = mutex_self_trylock(*mutex); else /* Return a busy error: */ ret = EBUSY; @@ -460,7 +473,7 @@ mutex_trylock_common(struct pthread *curthread, pthread_mutex_t *mutex) TAILQ_INSERT_TAIL(&curthread->mutexq, (*mutex), m_qe); } else if ((*mutex)->m_owner == curthread) - ret = mutex_self_trylock(curthread, *mutex); + ret = mutex_self_trylock(*mutex); else /* Return a busy error: */ ret = EBUSY; @@ -987,7 +1000,7 @@ _mutex_cv_lock(pthread_mutex_t *m) } static inline int -mutex_self_trylock(struct pthread *curthread, pthread_mutex_t m) +mutex_self_trylock(pthread_mutex_t m) { int ret = 0; @@ -1601,7 +1614,7 @@ _mutex_unlock_private(pthread_t pthread) for (m = TAILQ_FIRST(&pthread->mutexq); m != NULL; m = m_next) { m_next = TAILQ_NEXT(m, m_qe); if ((m->m_flags & MUTEX_FLAGS_PRIVATE) != 0) - pthread_mutex_unlock(&m); + _pthread_mutex_unlock(&m); } } diff --git a/lib/libkse/thread/thr_mutex_prioceiling.c b/lib/libkse/thread/thr_mutex_prioceiling.c index f254346..876f7c7 100644 --- a/lib/libkse/thread/thr_mutex_prioceiling.c +++ b/lib/libkse/thread/thr_mutex_prioceiling.c @@ -31,10 +31,13 @@ * * $FreeBSD$ */ + +#include "namespace.h" #include <string.h> #include <stdlib.h> #include <errno.h> #include <pthread.h> +#include "un-namespace.h" #include "thr_private.h" LT10_COMPAT_PRIVATE(_pthread_mutexattr_getprioceiling); @@ -91,10 +94,11 @@ _pthread_mutex_getprioceiling(pthread_mutex_t *mutex, ret = EINVAL; else if ((*mutex)->m_protocol != PTHREAD_PRIO_PROTECT) ret = EINVAL; - else - ret = (*mutex)->m_prio; - - return(ret); + else { + *prioceiling = (*mutex)->m_prio; + ret = 0; + } + return (ret); } int @@ -109,13 +113,13 @@ _pthread_mutex_setprioceiling(pthread_mutex_t *mutex, else if ((*mutex)->m_protocol != PTHREAD_PRIO_PROTECT) ret = EINVAL; /* Lock the mutex: */ - else if ((ret = pthread_mutex_lock(mutex)) == 0) { + else if ((ret = _pthread_mutex_lock(mutex)) == 0) { tmp = (*mutex)->m_prio; /* Set the new ceiling: */ (*mutex)->m_prio = prioceiling; /* Unlock the mutex: */ - ret = pthread_mutex_unlock(mutex); + ret = _pthread_mutex_unlock(mutex); /* Return the old ceiling: */ *old_ceiling = tmp; diff --git a/lib/libkse/thread/thr_mutex_protocol.c b/lib/libkse/thread/thr_mutex_protocol.c index 9e3e46b..64e31a0 100644 --- a/lib/libkse/thread/thr_mutex_protocol.c +++ b/lib/libkse/thread/thr_mutex_protocol.c @@ -31,10 +31,13 @@ * * $FreeBSD$ */ + +#include "namespace.h" #include <string.h> #include <stdlib.h> #include <errno.h> #include <pthread.h> +#include "un-namespace.h" #include "thr_private.h" LT10_COMPAT_PRIVATE(_pthread_mutexattr_getprotocol); diff --git a/lib/libkse/thread/thr_mutexattr_destroy.c b/lib/libkse/thread/thr_mutexattr_destroy.c index 86c051d..c12efb1 100644 --- a/lib/libkse/thread/thr_mutexattr_destroy.c +++ b/lib/libkse/thread/thr_mutexattr_destroy.c @@ -28,9 +28,12 @@ * * $FreeBSD$ */ + +#include "namespace.h" #include <stdlib.h> #include <errno.h> #include <pthread.h> +#include "un-namespace.h" #include "thr_private.h" LT10_COMPAT_PRIVATE(_pthread_mutexattr_destroy); diff --git a/lib/libkse/thread/thr_nanosleep.c b/lib/libkse/thread/thr_nanosleep.c index 974cc20..9f04ead 100644 --- a/lib/libkse/thread/thr_nanosleep.c +++ b/lib/libkse/thread/thr_nanosleep.c @@ -28,11 +28,17 @@ * * $FreeBSD$ */ + +#include "namespace.h" #include <stdio.h> #include <errno.h> #include <pthread.h> +#include "un-namespace.h" #include "thr_private.h" +int __nanosleep(const struct timespec *time_to_sleep, + struct timespec *time_remaining); + LT10_COMPAT_PRIVATE(__nanosleep); LT10_COMPAT_PRIVATE(_nanosleep); LT10_COMPAT_DEFAULT(nanosleep); diff --git a/lib/libkse/thread/thr_once.c b/lib/libkse/thread/thr_once.c index cd69cd6..ba13499 100644 --- a/lib/libkse/thread/thr_once.c +++ b/lib/libkse/thread/thr_once.c @@ -28,6 +28,7 @@ * * $FreeBSD$ */ + #include "namespace.h" #include <pthread.h> #include "un-namespace.h" diff --git a/lib/libkse/thread/thr_open.c b/lib/libkse/thread/thr_open.c index 7d5035f..732a770 100644 --- a/lib/libkse/thread/thr_open.c +++ b/lib/libkse/thread/thr_open.c @@ -29,14 +29,19 @@ * $FreeBSD$ * */ + +#include "namespace.h" #include <stdarg.h> #include <unistd.h> #include <fcntl.h> #include <dirent.h> #include <errno.h> #include <pthread.h> +#include "un-namespace.h" #include "thr_private.h" +int __open(const char *path, int flags,...); + LT10_COMPAT_PRIVATE(__open); LT10_COMPAT_DEFAULT(open); diff --git a/lib/libkse/thread/thr_pause.c b/lib/libkse/thread/thr_pause.c index b3f0fe5..a513bcb 100644 --- a/lib/libkse/thread/thr_pause.c +++ b/lib/libkse/thread/thr_pause.c @@ -29,10 +29,14 @@ * $FreeBSD$ */ +#include "namespace.h" #include <unistd.h> #include <pthread.h> +#include "un-namespace.h" #include "thr_private.h" +int _pause(void); + extern int __pause(void); LT10_COMPAT_PRIVATE(_pause); diff --git a/lib/libkse/thread/thr_poll.c b/lib/libkse/thread/thr_poll.c index 5e3890b..494e82b 100644 --- a/lib/libkse/thread/thr_poll.c +++ b/lib/libkse/thread/thr_poll.c @@ -31,6 +31,8 @@ * * $FreeBSD$ */ + +#include "namespace.h" #include <unistd.h> #include <errno.h> #include <string.h> @@ -39,11 +41,14 @@ #include <sys/time.h> #include <sys/fcntl.h> #include <pthread.h> +#include "un-namespace.h" #include "thr_private.h" LT10_COMPAT_PRIVATE(__poll); LT10_COMPAT_DEFAULT(poll); +int __poll(struct pollfd *fds, unsigned int nfds, int timeout); + __weak_reference(__poll, poll); int diff --git a/lib/libkse/thread/thr_priority_queue.c b/lib/libkse/thread/thr_priority_queue.c index f750a01..e7d6f57 100644 --- a/lib/libkse/thread/thr_priority_queue.c +++ b/lib/libkse/thread/thr_priority_queue.c @@ -31,10 +31,13 @@ * * $FreeBSD$ */ + +#include "namespace.h" #include <stdlib.h> #include <sys/queue.h> #include <string.h> #include <pthread.h> +#include "un-namespace.h" #include "thr_private.h" /* Prototypes: */ diff --git a/lib/libkse/thread/thr_private.h b/lib/libkse/thread/thr_private.h index 878c0cf..82728d3 100644 --- a/lib/libkse/thread/thr_private.h +++ b/lib/libkse/thread/thr_private.h @@ -637,15 +637,18 @@ struct join_status { }; struct pthread_specific_elem { - const void *data; - int seqno; + void *data; + int seqno; }; +typedef void (*const_key_destructor_t)(const void *); +typedef void (*key_destructor_t)(void *); + struct pthread_key { volatile int allocated; volatile int count; int seqno; - void (*destructor) (void *); + key_destructor_t destructor; }; #define MAX_THR_LOCKLEVEL 5 @@ -867,7 +870,7 @@ struct pthread { /* Cleanup handlers Link List */ struct pthread_cleanup *cleanup; - char *fname; /* Ptr to source file name */ + const char *fname; /* Ptr to source file name */ int lineno; /* Source line number. */ }; @@ -1110,9 +1113,9 @@ SCLASS struct lock _mutex_static_lock; SCLASS struct lock _rwlock_static_lock; SCLASS struct lock _keytable_lock; SCLASS struct lock _thread_list_lock; -SCLASS int _thr_guard_default; -SCLASS int _thr_stack_default; -SCLASS int _thr_stack_initial; +SCLASS size_t _thr_guard_default; +SCLASS size_t _thr_stack_default; +SCLASS size_t _thr_stack_initial; SCLASS int _thr_page_size; SCLASS pthread_t _thr_sig_daemon; SCLASS int _thr_debug_flags SCLASS_PRESET(0); @@ -1173,7 +1176,7 @@ void _pthread_yield(void); void _pthread_cleanup_push(void (*routine) (void *), void *routine_arg); void _pthread_cleanup_pop(int execute); struct pthread *_thr_alloc(struct pthread *); -void _thr_exit(char *, int, char *); +void _thr_exit(const char *, int, const char *) __dead2; void _thr_exit_cleanup(void); void _thr_lock_wait(struct lock *lock, struct lockuser *lu); void _thr_lock_wakeup(struct lock *lock, struct lockuser *lu); @@ -1201,7 +1204,7 @@ void _thr_sched_switch(struct pthread *); void _thr_sched_switch_unlocked(struct pthread *); void _thr_set_timeout(const struct timespec *); void _thr_seterrno(struct pthread *, int); -void _thr_sig_handler(int, siginfo_t *, ucontext_t *); +void _thr_sig_handler(int, siginfo_t *, void *); void _thr_sig_check_pending(struct pthread *); void _thr_sig_rundown(struct pthread *, ucontext_t *); void _thr_sig_send(struct pthread *pthread, int sig); @@ -1301,7 +1304,7 @@ ssize_t __sys_read(int, void *, size_t); ssize_t __sys_write(int, const void *, size_t); void __sys_exit(int); int __sys_sigwait(const sigset_t *, int *); -int __sys_sigtimedwait(sigset_t *, siginfo_t *, struct timespec *); +int __sys_sigtimedwait(const sigset_t *, siginfo_t *, const struct timespec *); #endif /* #include <poll.h> */ diff --git a/lib/libkse/thread/thr_pselect.c b/lib/libkse/thread/thr_pselect.c index a0e9410..c1499b8 100644 --- a/lib/libkse/thread/thr_pselect.c +++ b/lib/libkse/thread/thr_pselect.c @@ -28,17 +28,21 @@ #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); +#include "namespace.h" #include <sys/select.h> #include <sys/time.h> - #include <errno.h> #include <signal.h> #include <pthread.h> +#include "un-namespace.h" #include "thr_private.h" -extern int __pselect(int count, fd_set *rfds, fd_set *wfds, fd_set *efds, - const struct timespec *timo, const sigset_t *mask); +extern int __pselect(int count, fd_set *rfds, fd_set *wfds, fd_set *efds, + const struct timespec *timo, const sigset_t *mask); + +int _pselect(int count, fd_set *rfds, fd_set *wfds, fd_set *efds, + const struct timespec *timo, const sigset_t *mask); LT10_COMPAT_PRIVATE(_pselect); LT10_COMPAT_DEFAULT(pselect); diff --git a/lib/libkse/thread/thr_pspinlock.c b/lib/libkse/thread/thr_pspinlock.c index 5836fde..2d6075a 100644 --- a/lib/libkse/thread/thr_pspinlock.c +++ b/lib/libkse/thread/thr_pspinlock.c @@ -26,11 +26,13 @@ * $FreeBSD$ */ +#include "namespace.h" #include <sys/types.h> #include <errno.h> #include <pthread.h> #include <stdint.h> #include <stdlib.h> +#include "un-namespace.h" #include "atomic_ops.h" #include "thr_private.h" @@ -106,7 +108,7 @@ _pthread_spin_trylock(pthread_spinlock_t *lock) else if (lck->s_lock != 0) ret = EBUSY; else { - atomic_swap_int((int *)&(lck)->s_lock, 1, &oldval); + atomic_swap_int(&(lck)->s_lock, 1, &oldval); if (oldval) ret = EBUSY; else { @@ -141,7 +143,7 @@ _pthread_spin_lock(pthread_spinlock_t *lock) _pthread_yield(); } } - atomic_swap_int((int *)&(lck)->s_lock, 1, &oldval); + atomic_swap_int(&(lck)->s_lock, 1, &oldval); } while (oldval); lck->s_owner = self; @@ -164,7 +166,7 @@ _pthread_spin_unlock(pthread_spinlock_t *lock) ret = EPERM; else { lck->s_owner = NULL; - atomic_swap_int((int *)&lck->s_lock, 0, &ret); + atomic_swap_int(&lck->s_lock, 0, &ret); ret = 0; } } diff --git a/lib/libkse/thread/thr_raise.c b/lib/libkse/thread/thr_raise.c index ad4aa39..835ad234 100644 --- a/lib/libkse/thread/thr_raise.c +++ b/lib/libkse/thread/thr_raise.c @@ -29,10 +29,14 @@ * $FreeBSD$ */ -#include <pthread.h> +#include "namespace.h" #include <errno.h> +#include <pthread.h> +#include "un-namespace.h" #include "thr_private.h" +int _raise(int sig); + LT10_COMPAT_PRIVATE(_raise); LT10_COMPAT_DEFAULT(raise); @@ -46,7 +50,7 @@ _raise(int sig) if (!_kse_isthreaded()) ret = kill(getpid(), sig); else { - ret = pthread_kill(pthread_self(), sig); + ret = _pthread_kill(_pthread_self(), sig); if (ret != 0) { errno = ret; ret = -1; diff --git a/lib/libkse/thread/thr_read.c b/lib/libkse/thread/thr_read.c index 8fd349a..16e8d79 100644 --- a/lib/libkse/thread/thr_read.c +++ b/lib/libkse/thread/thr_read.c @@ -29,14 +29,19 @@ * $FreeBSD$ * */ + +#include "namespace.h" #include <sys/types.h> #include <sys/fcntl.h> #include <sys/uio.h> #include <errno.h> #include <unistd.h> #include <pthread.h> +#include "un-namespace.h" #include "thr_private.h" +ssize_t __read(int fd, void *buf, size_t nbytes); + LT10_COMPAT_PRIVATE(__read); LT10_COMPAT_DEFAULT(read); diff --git a/lib/libkse/thread/thr_readv.c b/lib/libkse/thread/thr_readv.c index 46b08dc..04c9f9d 100644 --- a/lib/libkse/thread/thr_readv.c +++ b/lib/libkse/thread/thr_readv.c @@ -29,14 +29,19 @@ * $FreeBSD$ * */ + +#include "namespace.h" #include <sys/types.h> #include <sys/fcntl.h> #include <sys/uio.h> #include <errno.h> #include <unistd.h> #include <pthread.h> +#include "un-namespace.h" #include "thr_private.h" +ssize_t __readv(int fd, const struct iovec *iov, int iovcnt); + LT10_COMPAT_PRIVATE(__readv); LT10_COMPAT_DEFAULT(readv); diff --git a/lib/libkse/thread/thr_resume_np.c b/lib/libkse/thread/thr_resume_np.c index eb7bcf3..d6991f5 100644 --- a/lib/libkse/thread/thr_resume_np.c +++ b/lib/libkse/thread/thr_resume_np.c @@ -28,10 +28,16 @@ * * $FreeBSD$ */ + +#include "namespace.h" #include <errno.h> #include <pthread.h> +#include "un-namespace.h" #include "thr_private.h" +int _pthread_resume_np(pthread_t thread); +void _pthread_resume_all_np(void); + static struct kse_mailbox *resume_common(struct pthread *); LT10_COMPAT_PRIVATE(_pthread_resume_np); diff --git a/lib/libkse/thread/thr_rtld.c b/lib/libkse/thread/thr_rtld.c index acb92a3..9320c48 100644 --- a/lib/libkse/thread/thr_rtld.c +++ b/lib/libkse/thread/thr_rtld.c @@ -171,7 +171,7 @@ _thr_rtld_lock_create(void) } static void -_thr_rtld_lock_destroy(void *lock) +_thr_rtld_lock_destroy(void *lock __unused) { /* XXX We really can not free memory after a fork() */ #if 0 @@ -268,13 +268,13 @@ _thr_rtld_lock_release(void *lock) static int -_thr_rtld_set_flag(int mask) +_thr_rtld_set_flag(int mask __unused) { return (0); } static int -_thr_rtld_clr_flag(int mask) +_thr_rtld_clr_flag(int mask __unused) { return (0); } diff --git a/lib/libkse/thread/thr_rwlock.c b/lib/libkse/thread/thr_rwlock.c index a0b36de..0f73448 100644 --- a/lib/libkse/thread/thr_rwlock.c +++ b/lib/libkse/thread/thr_rwlock.c @@ -26,11 +26,10 @@ * $FreeBSD$ */ +#include "namespace.h" #include <errno.h> #include <limits.h> #include <stdlib.h> - -#include "namespace.h" #include <pthread.h> #include "un-namespace.h" #include "thr_private.h" @@ -115,7 +114,8 @@ _pthread_rwlock_destroy (pthread_rwlock_t *rwlock) } int -_pthread_rwlock_init (pthread_rwlock_t *rwlock, const pthread_rwlockattr_t *attr) +_pthread_rwlock_init (pthread_rwlock_t *rwlock, + const pthread_rwlockattr_t *attr __unused) { pthread_rwlock_t prwlock; int ret; diff --git a/lib/libkse/thread/thr_rwlockattr.c b/lib/libkse/thread/thr_rwlockattr.c index 174b28f..d8fafe2 100644 --- a/lib/libkse/thread/thr_rwlockattr.c +++ b/lib/libkse/thread/thr_rwlockattr.c @@ -26,10 +26,11 @@ * $FreeBSD$ */ +#include "namespace.h" #include <errno.h> #include <stdlib.h> - #include <pthread.h> +#include "un-namespace.h" #include "thr_private.h" LT10_COMPAT_PRIVATE(_pthread_rwlockattr_destroy); diff --git a/lib/libkse/thread/thr_select.c b/lib/libkse/thread/thr_select.c index 2913c69..19d7dd8 100644 --- a/lib/libkse/thread/thr_select.c +++ b/lib/libkse/thread/thr_select.c @@ -28,6 +28,8 @@ * * $FreeBSD$ */ + +#include "namespace.h" #include <unistd.h> #include <errno.h> #include <poll.h> @@ -38,8 +40,12 @@ #include <sys/time.h> #include <sys/fcntl.h> #include <pthread.h> +#include "un-namespace.h" #include "thr_private.h" +int __select(int numfds, fd_set *readfds, fd_set *writefds, + fd_set *exceptfds, struct timeval *timeout); + LT10_COMPAT_PRIVATE(__select); LT10_COMPAT_DEFAULT(select); @@ -55,11 +61,11 @@ __select(int numfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, if (numfds == 0 && timeout != NULL) { TIMEVAL_TO_TIMESPEC(timeout, &ts); - return nanosleep(&ts, NULL); + ret = _nanosleep(&ts, NULL); } else { _thr_cancel_enter(curthread); ret = __sys_select(numfds, readfds, writefds, exceptfds, timeout); _thr_cancel_leave(curthread, 1); } - return ret; + return (ret); } diff --git a/lib/libkse/thread/thr_self.c b/lib/libkse/thread/thr_self.c index e016b95..426995c 100644 --- a/lib/libkse/thread/thr_self.c +++ b/lib/libkse/thread/thr_self.c @@ -28,7 +28,10 @@ * * $FreeBSD$ */ + +#include "namespace.h" #include <pthread.h> +#include "un-namespace.h" #include "thr_private.h" LT10_COMPAT_PRIVATE(_pthread_self); diff --git a/lib/libkse/thread/thr_seterrno.c b/lib/libkse/thread/thr_seterrno.c index 0b83ff0..f0b5f97 100644 --- a/lib/libkse/thread/thr_seterrno.c +++ b/lib/libkse/thread/thr_seterrno.c @@ -28,7 +28,10 @@ * * $FreeBSD$ */ + +#include "namespace.h" #include <pthread.h> +#include "un-namespace.h" #include "thr_private.h" /* @@ -40,6 +43,8 @@ #endif extern int errno; +void _thread_seterrno(pthread_t thread, int error); + void _thread_seterrno(pthread_t thread, int error) { diff --git a/lib/libkse/thread/thr_setprio.c b/lib/libkse/thread/thr_setprio.c index 2f67e81..2197722 100644 --- a/lib/libkse/thread/thr_setprio.c +++ b/lib/libkse/thread/thr_setprio.c @@ -28,9 +28,14 @@ * * $FreeBSD$ */ + +#include "namespace.h" #include <pthread.h> +#include "un-namespace.h" #include "thr_private.h" +int _pthread_setprio(pthread_t pthread, int prio); + LT10_COMPAT_PRIVATE(_pthread_setprio); LT10_COMPAT_DEFAULT(pthread_setprio); @@ -42,9 +47,9 @@ _pthread_setprio(pthread_t pthread, int prio) int ret, policy; struct sched_param param; - if ((ret = pthread_getschedparam(pthread, &policy, ¶m)) == 0) { + if ((ret = _pthread_getschedparam(pthread, &policy, ¶m)) == 0) { param.sched_priority = prio; - ret = pthread_setschedparam(pthread, policy, ¶m); + ret = _pthread_setschedparam(pthread, policy, ¶m); } /* Return the error status: */ diff --git a/lib/libkse/thread/thr_setschedparam.c b/lib/libkse/thread/thr_setschedparam.c index 8f5154c..14bef84 100644 --- a/lib/libkse/thread/thr_setschedparam.c +++ b/lib/libkse/thread/thr_setschedparam.c @@ -31,9 +31,12 @@ * * $FreeBSD$ */ + +#include "namespace.h" #include <errno.h> #include <sys/param.h> #include <pthread.h> +#include "un-namespace.h" #include "thr_private.h" LT10_COMPAT_PRIVATE(_pthread_setschedparam); diff --git a/lib/libkse/thread/thr_sig.c b/lib/libkse/thread/thr_sig.c index 2287221..ad1f728 100644 --- a/lib/libkse/thread/thr_sig.c +++ b/lib/libkse/thread/thr_sig.c @@ -28,6 +28,8 @@ * * $FreeBSD$ */ + +#include "namespace.h" #include <sys/param.h> #include <sys/types.h> #include <sys/signalvar.h> @@ -37,6 +39,7 @@ #include <unistd.h> #include <string.h> #include <pthread.h> +#include "un-namespace.h" #include "thr_private.h" /* Prototypes: */ @@ -169,7 +172,7 @@ static int sigproptbl[NSIG] = { #ifndef SYSTEM_SCOPE_ONLY static void * -sig_daemon(void *arg /* Unused */) +sig_daemon(void *arg __unused) { int i; kse_critical_t crit; @@ -224,15 +227,15 @@ _thr_start_sig_daemon(void) sigset_t sigset, oldset; SIGFILLSET(sigset); - pthread_sigmask(SIG_SETMASK, &sigset, &oldset); - pthread_attr_init(&attr); - pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM); + _pthread_sigmask(SIG_SETMASK, &sigset, &oldset); + _pthread_attr_init(&attr); + _pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM); attr->flags |= THR_SIGNAL_THREAD; /* sigmask will be inherited */ - if (pthread_create(&_thr_sig_daemon, &attr, sig_daemon, NULL)) + if (_pthread_create(&_thr_sig_daemon, &attr, sig_daemon, NULL)) PANIC("can not create signal daemon thread!\n"); - pthread_attr_destroy(&attr); - pthread_sigmask(SIG_SETMASK, &oldset, NULL); + _pthread_attr_destroy(&attr); + _pthread_sigmask(SIG_SETMASK, &oldset, NULL); return (0); } @@ -296,16 +299,18 @@ typedef void (*ohandler)(int sig, int code, struct sigcontext *scp, char *addr, __sighandler_t *catcher); void -_thr_sig_handler(int sig, siginfo_t *info, ucontext_t *ucp) +_thr_sig_handler(int sig, siginfo_t *info, void *ucp_arg) { struct pthread_sigframe psf; __siginfohandler_t *sigfunc; struct pthread *curthread; struct kse *curkse; + ucontext_t *ucp; struct sigaction act; int sa_flags, err_save; err_save = errno; + ucp = (ucontext_t *)ucp_arg; DBG_MSG(">>> _thr_sig_handler(%d)\n", sig); @@ -644,7 +649,7 @@ _thr_getprocsig_unlocked(int sig, siginfo_t *siginfo) * with upcalls disabled. */ struct pthread * -thr_sig_find(struct kse *curkse, int sig, siginfo_t *info) +thr_sig_find(struct kse *curkse, int sig, siginfo_t *info __unused) { struct kse_mailbox *kmbx = NULL; struct pthread *pthread; diff --git a/lib/libkse/thread/thr_sigaction.c b/lib/libkse/thread/thr_sigaction.c index bfb67fe..3cd7ea8 100644 --- a/lib/libkse/thread/thr_sigaction.c +++ b/lib/libkse/thread/thr_sigaction.c @@ -28,9 +28,12 @@ * * $FreeBSD$ */ + +#include "namespace.h" #include <signal.h> #include <errno.h> #include <pthread.h> +#include "un-namespace.h" #include "thr_private.h" LT10_COMPAT_PRIVATE(_sigaction); @@ -86,7 +89,7 @@ _sigaction(int sig, const struct sigaction * act, struct sigaction * oact) * Specify the thread kernel signal * handler: */ - newact.sa_handler = (void (*) ())_thr_sig_handler; + newact.sa_sigaction = _thr_sig_handler; } /* * Install libpthread signal handler wrapper @@ -95,8 +98,7 @@ _sigaction(int sig, const struct sigaction * act, struct sigaction * oact) * SIG_DFL or SIG_IGN. */ if (sig == SIGINFO && _thr_dump_enabled()) { - newact.sa_handler = - (void (*) ())_thr_sig_handler; + newact.sa_sigaction = _thr_sig_handler; } /* Change the signal action in the kernel: */ if (__sys_sigaction(sig, &newact, NULL) != 0) { diff --git a/lib/libkse/thread/thr_sigaltstack.c b/lib/libkse/thread/thr_sigaltstack.c index 8ebbdee..070b422 100644 --- a/lib/libkse/thread/thr_sigaltstack.c +++ b/lib/libkse/thread/thr_sigaltstack.c @@ -27,10 +27,14 @@ #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); +#include "namespace.h" #include <errno.h> #include <signal.h> +#include "un-namespace.h" #include "thr_private.h" +int _sigaltstack(stack_t *_ss, stack_t *_oss); + LT10_COMPAT_PRIVATE(_sigaltstack); LT10_COMPAT_DEFAULT(sigaltstack); diff --git a/lib/libkse/thread/thr_sigmask.c b/lib/libkse/thread/thr_sigmask.c index b08ba06..15fb1d7 100644 --- a/lib/libkse/thread/thr_sigmask.c +++ b/lib/libkse/thread/thr_sigmask.c @@ -28,6 +28,8 @@ * * $FreeBSD$ */ + +#include "namespace.h" #include <sys/param.h> #include <sys/types.h> #include <sys/signalvar.h> @@ -35,6 +37,7 @@ #include <signal.h> #include <string.h> #include <pthread.h> +#include "un-namespace.h" #include "thr_private.h" LT10_COMPAT_PRIVATE(_pthread_sigmask); diff --git a/lib/libkse/thread/thr_sigpending.c b/lib/libkse/thread/thr_sigpending.c index 5c666bf..b0bdaec 100644 --- a/lib/libkse/thread/thr_sigpending.c +++ b/lib/libkse/thread/thr_sigpending.c @@ -31,14 +31,19 @@ * * $FreeBSD$ */ + +#include "namespace.h" #include <sys/param.h> #include <sys/types.h> #include <sys/signalvar.h> #include <signal.h> #include <errno.h> #include <pthread.h> +#include "un-namespace.h" #include "thr_private.h" +int _sigpending(sigset_t *set); + LT10_COMPAT_PRIVATE(_sigpending); LT10_COMPAT_DEFAULT(sigpending); diff --git a/lib/libkse/thread/thr_sigprocmask.c b/lib/libkse/thread/thr_sigprocmask.c index f646834..8c5c17f 100644 --- a/lib/libkse/thread/thr_sigprocmask.c +++ b/lib/libkse/thread/thr_sigprocmask.c @@ -28,12 +28,15 @@ * * $FreeBSD$ */ + +#include "namespace.h" #include <sys/param.h> #include <sys/types.h> #include <sys/signalvar.h> #include <signal.h> #include <errno.h> #include <pthread.h> +#include "un-namespace.h" #include "thr_private.h" LT10_COMPAT_PRIVATE(_sigprocmask); @@ -46,7 +49,7 @@ _sigprocmask(int how, const sigset_t *set, sigset_t *oset) { int ret; - ret = pthread_sigmask(how, set, oset); + ret = _pthread_sigmask(how, set, oset); if (ret) { errno = ret; ret = -1; diff --git a/lib/libkse/thread/thr_sigsuspend.c b/lib/libkse/thread/thr_sigsuspend.c index 7e56eae..c233660 100644 --- a/lib/libkse/thread/thr_sigsuspend.c +++ b/lib/libkse/thread/thr_sigsuspend.c @@ -29,15 +29,18 @@ * $FreeBSD$ */ +#include "namespace.h" #include <sys/types.h> #include <sys/signalvar.h> #include <errno.h> #include <pthread.h> #include <signal.h> #include <string.h> - +#include "un-namespace.h" #include "thr_private.h" +int __sigsuspend(const sigset_t * set); + LT10_COMPAT_PRIVATE(__sigsuspend); LT10_COMPAT_PRIVATE(_sigsuspend); LT10_COMPAT_DEFAULT(sigsuspend); diff --git a/lib/libkse/thread/thr_sigwait.c b/lib/libkse/thread/thr_sigwait.c index 532251c..19c1cd7 100644 --- a/lib/libkse/thread/thr_sigwait.c +++ b/lib/libkse/thread/thr_sigwait.c @@ -29,13 +29,25 @@ * * $FreeBSD$ */ + +#include "namespace.h" #include <signal.h> #include <sys/param.h> #include <sys/signalvar.h> #include <errno.h> #include <pthread.h> +#include "un-namespace.h" #include "thr_private.h" +int __sigtimedwait(const sigset_t *set, siginfo_t *info, + const struct timespec *timeout); +int __sigwaitinfo(const sigset_t *set, siginfo_t *info); +int __sigwait(const sigset_t *set, int *sig); +int _sigtimedwait(const sigset_t *set, siginfo_t *info, + const struct timespec *timeout); +int _sigwaitinfo(const sigset_t *set, siginfo_t *info); +int _sigwait(const sigset_t *set, int *sig); + LT10_COMPAT_PRIVATE(__sigwait); LT10_COMPAT_PRIVATE(_sigwait); LT10_COMPAT_DEFAULT(sigwait); @@ -52,7 +64,7 @@ __weak_reference(__sigwaitinfo, sigwaitinfo); static int lib_sigtimedwait(const sigset_t *set, siginfo_t *info, - const struct timespec * timeout) + const struct timespec *timeout) { struct pthread *curthread = _get_curthread(); int ret = 0; @@ -65,8 +77,7 @@ lib_sigtimedwait(const sigset_t *set, siginfo_t *info, if (curthread->attr.flags & PTHREAD_SCOPE_SYSTEM) { if (info == NULL) info = &siginfo; - return (__sys_sigtimedwait((sigset_t *)set, info, - (struct timespec *)timeout)); + return (__sys_sigtimedwait(set, info, timeout)); } /* diff --git a/lib/libkse/thread/thr_single_np.c b/lib/libkse/thread/thr_single_np.c index 5720006..844adad 100644 --- a/lib/libkse/thread/thr_single_np.c +++ b/lib/libkse/thread/thr_single_np.c @@ -28,21 +28,25 @@ * * $FreeBSD$ */ + +#include "namespace.h" #include <pthread.h> #include <pthread_np.h> - +#include "un-namespace.h" #include "thr_private.h" LT10_COMPAT_PRIVATE(_pthread_single_np); LT10_COMPAT_DEFAULT(pthread_single_np); +int _pthread_single_np(void); + __weak_reference(_pthread_single_np, pthread_single_np); -int _pthread_single_np() +int _pthread_single_np(void) { /* Enter single-threaded (non-POSIX) scheduling mode: */ - pthread_suspend_all_np(); + _pthread_suspend_all_np(); /* * XXX - Do we want to do this? * __is_threaded = 0; diff --git a/lib/libkse/thread/thr_sleep.c b/lib/libkse/thread/thr_sleep.c index 0a11876..c271055 100644 --- a/lib/libkse/thread/thr_sleep.c +++ b/lib/libkse/thread/thr_sleep.c @@ -29,13 +29,17 @@ * $FreeBSD$ */ +#include "namespace.h" #include <unistd.h> #include <pthread.h> +#include "un-namespace.h" #include "thr_private.h" extern unsigned int __sleep(unsigned int); extern int __usleep(useconds_t); +unsigned int _sleep(unsigned int seconds); + LT10_COMPAT_PRIVATE(_sleep); LT10_COMPAT_DEFAULT(sleep); LT10_COMPAT_PRIVATE(_usleep); diff --git a/lib/libkse/thread/thr_spec.c b/lib/libkse/thread/thr_spec.c index f373d8e..a7c6c2c 100644 --- a/lib/libkse/thread/thr_spec.c +++ b/lib/libkse/thread/thr_spec.c @@ -28,12 +28,14 @@ * * $FreeBSD$ */ + +#include "namespace.h" #include <signal.h> #include <stdlib.h> #include <string.h> #include <errno.h> #include <pthread.h> - +#include "un-namespace.h" #include "thr_private.h" @@ -117,8 +119,8 @@ void _thread_cleanupspecific(void) { struct pthread *curthread = _get_curthread(); - void (*destructor)( void *); - void *data = NULL; + const_key_destructor_t destructor; + const void *data = NULL; int key; int i; @@ -137,9 +139,9 @@ _thread_cleanupspecific(void) (curthread->specific[key].data != NULL)) { if (curthread->specific[key].seqno == _thread_keytable[key].seqno) { - data = (void *) - curthread->specific[key].data; - destructor = _thread_keytable[key].destructor; + data = curthread->specific[key].data; + destructor = (const_key_destructor_t) + _thread_keytable[key].destructor; } curthread->specific[key].data = NULL; curthread->specific_data_count--; @@ -201,7 +203,7 @@ _pthread_setspecific(pthread_key_t key, const void *value) pthread->specific_data_count++; } else if (value == NULL) pthread->specific_data_count--; - pthread->specific[key].data = value; + *(const void **)&pthread->specific[key].data = value; pthread->specific[key].seqno = _thread_keytable[key].seqno; ret = 0; @@ -229,7 +231,7 @@ _pthread_getspecific(pthread_key_t key) if (_thread_keytable[key].allocated && (pthread->specific[key].seqno == _thread_keytable[key].seqno)) { /* Return the value: */ - data = (void *) pthread->specific[key].data; + data = pthread->specific[key].data; } else { /* * This key has not been used before, so return NULL diff --git a/lib/libkse/thread/thr_spinlock.c b/lib/libkse/thread/thr_spinlock.c index 8a6e0d6..c38f091 100644 --- a/lib/libkse/thread/thr_spinlock.c +++ b/lib/libkse/thread/thr_spinlock.c @@ -30,10 +30,12 @@ * */ +#include "namespace.h" #include <sys/types.h> #include <machine/atomic.h> - +#include <pthread.h> #include <libc_private.h> +#include "un-namespace.h" #include "spinlock.h" #include "thr_private.h" @@ -44,6 +46,14 @@ struct spinlock_extra { pthread_mutex_t lock; }; +struct nv_spinlock { + long access_lock; + long lock_owner; + struct spinlock_extra *extra; /* overlays fname in spinlock_t */ + int lineno; +}; +typedef struct nv_spinlock nv_spinlock_t; + static void init_spinlock(spinlock_t *lck); static struct pthread_mutex_attr static_mutex_attr = @@ -67,10 +77,10 @@ LT10_COMPAT_PRIVATE(_spinunlock); void _spinunlock(spinlock_t *lck) { - struct spinlock_extra *extra; + struct spinlock_extra *sl_extra; - extra = (struct spinlock_extra *)lck->fname; - _pthread_mutex_unlock(&extra->lock); + sl_extra = ((nv_spinlock_t *)lck)->extra; + _pthread_mutex_unlock(&sl_extra->lock); } /* @@ -82,7 +92,7 @@ _spinunlock(spinlock_t *lck) void _spinlock(spinlock_t *lck) { - struct spinlock_extra *extra; + struct spinlock_extra *sl_extra; if (!__isthreaded) PANIC("Spinlock called when not threaded."); @@ -94,8 +104,8 @@ _spinlock(spinlock_t *lck) */ if (lck->fname == NULL) init_spinlock(lck); - extra = (struct spinlock_extra *)lck->fname; - _pthread_mutex_lock(&extra->lock); + sl_extra = ((nv_spinlock_t *)lck)->extra; + _pthread_mutex_lock(&sl_extra->lock); } /* @@ -109,7 +119,7 @@ _spinlock(spinlock_t *lck) * returning. */ void -_spinlock_debug(spinlock_t *lck, char *fname, int lineno) +_spinlock_debug(spinlock_t *lck, char *fname __unused, int lineno __unused) { _spinlock(lck); } diff --git a/lib/libkse/thread/thr_stack.c b/lib/libkse/thread/thr_stack.c index f634055..6309e29 100644 --- a/lib/libkse/thread/thr_stack.c +++ b/lib/libkse/thread/thr_stack.c @@ -26,11 +26,14 @@ * * $FreeBSD$ */ + +#include "namespace.h" #include <sys/types.h> #include <sys/mman.h> #include <sys/queue.h> #include <stdlib.h> #include <pthread.h> +#include "un-namespace.h" #include "thr_private.h" /* Spare thread stack. */ @@ -123,7 +126,7 @@ round_up(size_t size) if (size % _thr_page_size != 0) size = ((size / _thr_page_size) + 1) * _thr_page_size; - return size; + return (size); } int @@ -191,11 +194,13 @@ _thr_stack_alloc(struct pthread_attr *attr) else { /* Allocate a stack from usrstack. */ if (last_stack == NULL) - last_stack = _usrstack - _thr_stack_initial - - _thr_guard_default; + last_stack = (void *)((uintptr_t)_usrstack - + (uintptr_t)_thr_stack_initial - + (uintptr_t)_thr_guard_default); /* Allocate a new stack. */ - stackaddr = last_stack - stacksize - guardsize; + stackaddr = (void *)((uintptr_t)last_stack - + (uintptr_t)stacksize - (uintptr_t)guardsize); /* * Even if stack allocation fails, we don't want to try to @@ -204,7 +209,8 @@ _thr_stack_alloc(struct pthread_attr *attr) * likely reason for an mmap() error is a stack overflow of * the adjacent thread stack. */ - last_stack -= (stacksize + guardsize); + last_stack = (void *)((uintptr_t)last_stack - + (uintptr_t)(stacksize + guardsize)); /* Release the lock before mmap'ing it. */ KSE_LOCK_RELEASE(curkse, &_thread_list_lock); @@ -239,8 +245,8 @@ _thr_stack_free(struct pthread_attr *attr) if ((attr != NULL) && ((attr->flags & THR_STACK_USER) == 0) && (attr->stackaddr_attr != NULL)) { - spare_stack = (attr->stackaddr_attr + attr->stacksize_attr - - sizeof(struct stack)); + spare_stack = (struct stack *)((uintptr_t)attr->stackaddr_attr + + (uintptr_t)attr->stacksize_attr - sizeof(struct stack)); spare_stack->stacksize = round_up(attr->stacksize_attr); spare_stack->guardsize = round_up(attr->guardsize_attr); spare_stack->stackaddr = attr->stackaddr_attr; diff --git a/lib/libkse/thread/thr_suspend_np.c b/lib/libkse/thread/thr_suspend_np.c index 37ca783..fa60d30 100644 --- a/lib/libkse/thread/thr_suspend_np.c +++ b/lib/libkse/thread/thr_suspend_np.c @@ -28,10 +28,16 @@ * * $FreeBSD$ */ + +#include "namespace.h" #include <errno.h> #include <pthread.h> +#include "un-namespace.h" #include "thr_private.h" +int _pthread_suspend_np(pthread_t thread); +void _pthread_suspend_all_np(void); + static void suspend_common(struct pthread *thread); LT10_COMPAT_PRIVATE(_pthread_suspend_np); diff --git a/lib/libkse/thread/thr_switch_np.c b/lib/libkse/thread/thr_switch_np.c index 247b879..cc9ae30 100644 --- a/lib/libkse/thread/thr_switch_np.c +++ b/lib/libkse/thread/thr_switch_np.c @@ -31,9 +31,12 @@ * * $FreeBSD$ */ + +#include "namespace.h" #include <errno.h> #include <pthread.h> #include <pthread_np.h> +#include "un-namespace.h" #include "thr_private.h" LT10_COMPAT_PRIVATE(_pthread_switch_add_np); @@ -45,13 +48,13 @@ __weak_reference(_pthread_switch_add_np, pthread_switch_add_np); __weak_reference(_pthread_switch_delete_np, pthread_switch_delete_np); int -_pthread_switch_add_np(pthread_switch_routine_t routine) +_pthread_switch_add_np(pthread_switch_routine_t routine __unused) { return (ENOTSUP); } int -_pthread_switch_delete_np(pthread_switch_routine_t routine) +_pthread_switch_delete_np(pthread_switch_routine_t routine __unused) { return (ENOTSUP); } diff --git a/lib/libkse/thread/thr_symbols.c b/lib/libkse/thread/thr_symbols.c index 248fad9..cbf2827 100644 --- a/lib/libkse/thread/thr_symbols.c +++ b/lib/libkse/thread/thr_symbols.c @@ -29,10 +29,12 @@ * $FreeBSD$ */ +#include "namespace.h" #include <sys/types.h> #include <stddef.h> #include <pthread.h> #include <rtld.h> +#include "un-namespace.h" #include "thr_private.h" diff --git a/lib/libkse/thread/thr_system.c b/lib/libkse/thread/thr_system.c index 5e4fe1c..1c10a70 100644 --- a/lib/libkse/thread/thr_system.c +++ b/lib/libkse/thread/thr_system.c @@ -29,10 +29,14 @@ * $FreeBSD$ */ +#include "namespace.h" #include <stdlib.h> #include <pthread.h> +#include "un-namespace.h" #include "thr_private.h" +int _system(const char *string); + extern int __system(const char *); LT10_COMPAT_PRIVATE(_system); diff --git a/lib/libkse/thread/thr_tcdrain.c b/lib/libkse/thread/thr_tcdrain.c index e231d52..146b1ab 100644 --- a/lib/libkse/thread/thr_tcdrain.c +++ b/lib/libkse/thread/thr_tcdrain.c @@ -29,10 +29,13 @@ * $FreeBSD$ */ +#include "namespace.h" #include <termios.h> #include <pthread.h> +#include "un-namespace.h" #include "thr_private.h" +int _tcdrain(int fd); extern int __tcdrain(int); LT10_COMPAT_PRIVATE(_tcdrain); diff --git a/lib/libkse/thread/thr_vfork.c b/lib/libkse/thread/thr_vfork.c index 428c129..7b2373e 100644 --- a/lib/libkse/thread/thr_vfork.c +++ b/lib/libkse/thread/thr_vfork.c @@ -1,13 +1,15 @@ /* * $FreeBSD$ */ -#include <unistd.h> +#include <unistd.h> #include "thr_private.h" LT10_COMPAT_PRIVATE(_vfork); LT10_COMPAT_DEFAULT(vfork); +int _vfork(void); + __weak_reference(_vfork, vfork); int diff --git a/lib/libkse/thread/thr_wait.c b/lib/libkse/thread/thr_wait.c index 8f61a0c..3c9567a 100644 --- a/lib/libkse/thread/thr_wait.c +++ b/lib/libkse/thread/thr_wait.c @@ -32,11 +32,13 @@ #include <pthread.h> #include "thr_private.h" -extern int __wait(int *); - LT10_COMPAT_PRIVATE(_wait); LT10_COMPAT_DEFAULT(wait); +extern int __wait(int *); + +pid_t _wait(int *istat); + __weak_reference(_wait, wait); pid_t diff --git a/lib/libkse/thread/thr_wait4.c b/lib/libkse/thread/thr_wait4.c index 6810e65..99230b6 100644 --- a/lib/libkse/thread/thr_wait4.c +++ b/lib/libkse/thread/thr_wait4.c @@ -28,9 +28,9 @@ * * $FreeBSD$ */ -#include <sys/types.h> #include "namespace.h" +#include <sys/types.h> #include <errno.h> #include <sys/wait.h> #include <pthread.h> @@ -41,6 +41,8 @@ LT10_COMPAT_PRIVATE(__wait4); LT10_COMPAT_DEFAULT(wait4); +pid_t __wait4(pid_t pid, int *istat, int options, struct rusage *rusage); + __weak_reference(__wait4, wait4); pid_t diff --git a/lib/libkse/thread/thr_waitpid.c b/lib/libkse/thread/thr_waitpid.c index 1244c12..5f6436f 100644 --- a/lib/libkse/thread/thr_waitpid.c +++ b/lib/libkse/thread/thr_waitpid.c @@ -39,6 +39,8 @@ LT10_COMPAT_DEFAULT(waitpid); extern int __waitpid(pid_t, int *, int); +pid_t _waitpid(pid_t wpid, int *status, int options); + __weak_reference(_waitpid, waitpid); pid_t @@ -51,5 +53,5 @@ _waitpid(pid_t wpid, int *status, int options) ret = __waitpid(wpid, status, options); _thr_cancel_leave(curthread, 1); - return ret; + return (ret); } diff --git a/lib/libkse/thread/thr_write.c b/lib/libkse/thread/thr_write.c index 6596540..303433f 100644 --- a/lib/libkse/thread/thr_write.c +++ b/lib/libkse/thread/thr_write.c @@ -40,6 +40,8 @@ LT10_COMPAT_PRIVATE(__write); LT10_COMPAT_DEFAULT(write); +__ssize_t __write(int fd, const void *buf, size_t nbytes); + __weak_reference(__write, write); ssize_t diff --git a/lib/libkse/thread/thr_writev.c b/lib/libkse/thread/thr_writev.c index 9cda908..bd6fb23 100644 --- a/lib/libkse/thread/thr_writev.c +++ b/lib/libkse/thread/thr_writev.c @@ -42,6 +42,8 @@ LT10_COMPAT_PRIVATE(__writev); LT10_COMPAT_DEFAULT(writev); +ssize_t __writev(int fd, const struct iovec *iov, int iovcnt); + __weak_reference(__writev, writev); ssize_t diff --git a/lib/libkse/thread/thr_yield.c b/lib/libkse/thread/thr_yield.c index 7665ac6..8060b66 100644 --- a/lib/libkse/thread/thr_yield.c +++ b/lib/libkse/thread/thr_yield.c @@ -36,6 +36,8 @@ LT10_COMPAT_DEFAULT(sched_yield); LT10_COMPAT_PRIVATE(_pthread_yield); LT10_COMPAT_DEFAULT(pthread_yield); +int _sched_yield(void); + __weak_reference(_sched_yield, sched_yield); __weak_reference(_pthread_yield, pthread_yield); |