summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authordavidxu <davidxu@FreeBSD.org>2006-04-04 02:57:49 +0000
committerdavidxu <davidxu@FreeBSD.org>2006-04-04 02:57:49 +0000
commit31f2b819c68f20ff188724669d3044a0680e3ceb (patch)
tree3cbec5633c5b1de6974d08e11807ee0ce2110a82 /lib
parent2cacffb02b10bf82a1a5ee4d88c3092821839d16 (diff)
downloadFreeBSD-src-31f2b819c68f20ff188724669d3044a0680e3ceb.zip
FreeBSD-src-31f2b819c68f20ff188724669d3044a0680e3ceb.tar.gz
WARNS level 4 cleanup.
Diffstat (limited to 'lib')
-rw-r--r--lib/libthr/pthread.map21
-rw-r--r--lib/libthr/thread/Makefile.inc1
-rw-r--r--lib/libthr/thread/thr_attr.c2
-rw-r--r--lib/libthr/thread/thr_barrier.c6
-rw-r--r--lib/libthr/thread/thr_barrierattr.c2
-rw-r--r--lib/libthr/thread/thr_cancel.c6
-rw-r--r--lib/libthr/thread/thr_clean.c2
-rw-r--r--lib/libthr/thread/thr_concurrency.c2
-rw-r--r--lib/libthr/thread/thr_cond.c5
-rw-r--r--lib/libthr/thread/thr_condattr.c2
-rw-r--r--lib/libthr/thread/thr_create.c4
-rw-r--r--lib/libthr/thread/thr_detach.c2
-rw-r--r--lib/libthr/thread/thr_equal.c2
-rw-r--r--lib/libthr/thread/thr_exit.c6
-rw-r--r--lib/libthr/thread/thr_fork.c4
-rw-r--r--lib/libthr/thread/thr_getprio.c4
-rw-r--r--lib/libthr/thread/thr_getschedparam.c2
-rw-r--r--lib/libthr/thread/thr_info.c7
-rw-r--r--lib/libthr/thread/thr_init.c32
-rw-r--r--lib/libthr/thread/thr_join.c4
-rw-r--r--lib/libthr/thread/thr_kill.c2
-rw-r--r--lib/libthr/thread/thr_list.c5
-rw-r--r--lib/libthr/thread/thr_main_np.c4
-rw-r--r--lib/libthr/thread/thr_multi_np.c5
-rw-r--r--lib/libthr/thread/thr_mutex.c33
-rw-r--r--lib/libthr/thread/thr_mutexattr.c4
-rw-r--r--lib/libthr/thread/thr_private.h100
-rw-r--r--lib/libthr/thread/thr_pspinlock.c3
-rw-r--r--lib/libthr/thread/thr_resume_np.c3
-rw-r--r--lib/libthr/thread/thr_rtld.c4
-rw-r--r--lib/libthr/thread/thr_rwlock.c2
-rw-r--r--lib/libthr/thread/thr_rwlockattr.c4
-rw-r--r--lib/libthr/thread/thr_self.c2
-rw-r--r--lib/libthr/thread/thr_setprio.c8
-rw-r--r--lib/libthr/thread/thr_setschedparam.c4
-rw-r--r--lib/libthr/thread/thr_sig.c10
-rw-r--r--lib/libthr/thread/thr_single_np.c4
-rw-r--r--lib/libthr/thread/thr_spec.c15
-rw-r--r--lib/libthr/thread/thr_spinlock.c9
-rw-r--r--lib/libthr/thread/thr_stack.c7
-rw-r--r--lib/libthr/thread/thr_suspend_np.c3
-rw-r--r--lib/libthr/thread/thr_switch_np.c6
-rw-r--r--lib/libthr/thread/thr_syscalls.c76
-rw-r--r--lib/libthr/thread/thr_umtx.c17
-rw-r--r--lib/libthr/thread/thr_yield.c5
45 files changed, 252 insertions, 199 deletions
diff --git a/lib/libthr/pthread.map b/lib/libthr/pthread.map
index d6d1fcd..62456ab 100644
--- a/lib/libthr/pthread.map
+++ b/lib/libthr/pthread.map
@@ -16,8 +16,8 @@ global:
__pthread_cond_wait;
__pthread_mutex_init;
__pthread_mutex_lock;
- __pthread_mutex_trylock;
__pthread_mutex_timedlock;
+ __pthread_mutex_trylock;
__read;
__readv;
__recvfrom;
@@ -26,6 +26,9 @@ global:
__sendmsg;
__sendto;
__sigsuspend;
+ __sigtimedwait;
+ __sigwait;
+ __sigwaitinfo;
__wait4;
__write;
__writev;
@@ -43,7 +46,6 @@ global:
_pthread_barrierattr_getpshared;
_pthread_barrierattr_init;
_pthread_barrierattr_setpshared;
- _pthread_attr_default;
_pthread_attr_destroy;
_pthread_attr_get_np;
_pthread_attr_getdetachstate;
@@ -75,7 +77,6 @@ global:
_pthread_cond_signal;
_pthread_cond_timedwait;
_pthread_cond_wait;
- _pthread_condattr_default;
_pthread_condattr_destroy;
_pthread_condattr_getclock;
_pthread_condattr_getpshared;
@@ -104,7 +105,6 @@ global:
_pthread_mutex_timedlock;
_pthread_mutex_trylock;
_pthread_mutex_unlock;
- _pthread_mutexattr_default;
_pthread_mutexattr_destroy;
_pthread_mutexattr_getkind_np;
_pthread_mutexattr_getprioceiling;
@@ -156,21 +156,18 @@ global:
_pthread_timedjoin_np;
_pthread_yield;
_raise;
- _sem_close;
_sem_destroy;
_sem_getvalue;
_sem_init;
- _sem_open;
_sem_post;
_sem_timedwait;
_sem_trywait;
- _sem_unlink;
_sem_wait;
_sigaction;
_sigprocmask;
_sigsuspend;
- _sigwait;
_sigtimedwait;
+ _sigwait;
_sigwaitinfo;
_sleep;
_spinlock;
@@ -181,7 +178,10 @@ global:
_usleep;
_vfork;
_wait;
+ _wait4;
_waitpid;
+ _write;
+ _writev;
accept;
aio_suspend;
close;
@@ -320,21 +320,16 @@ global:
recvfrom;
recvmsg;
select;
- sem_close;
sem_destroy;
sem_getvalue;
sem_init;
- sem_open;
sem_post;
sem_timedwait;
sem_trywait;
- sem_unlink;
sem_wait;
sendmsg;
sendto;
sigaction;
- sigaltstack;
- sigpending;
sigprocmask;
sigsuspend;
sigwait;
diff --git a/lib/libthr/thread/Makefile.inc b/lib/libthr/thread/Makefile.inc
index 51d5ad7..bdae92e 100644
--- a/lib/libthr/thread/Makefile.inc
+++ b/lib/libthr/thread/Makefile.inc
@@ -39,7 +39,6 @@ SRCS+= \
thr_rwlockattr.c \
thr_self.c \
thr_sem.c \
- thr_seterrno.c \
thr_setprio.c \
thr_setschedparam.c \
thr_sig.c \
diff --git a/lib/libthr/thread/thr_attr.c b/lib/libthr/thread/thr_attr.c
index 342d457..906f45c 100644
--- a/lib/libthr/thread/thr_attr.c
+++ b/lib/libthr/thread/thr_attr.c
@@ -96,11 +96,13 @@
* $FreeBSD$
*/
+#include "namespace.h"
#include <errno.h>
#include <pthread.h>
#include <stdlib.h>
#include <string.h>
#include <pthread_np.h>
+#include "un-namespace.h"
#include "thr_private.h"
diff --git a/lib/libthr/thread/thr_barrier.c b/lib/libthr/thread/thr_barrier.c
index 113fce0..8d65d9f 100644
--- a/lib/libthr/thread/thr_barrier.c
+++ b/lib/libthr/thread/thr_barrier.c
@@ -26,9 +26,11 @@
* $FreeBSD$
*/
+#include "namespace.h"
#include <errno.h>
#include <stdlib.h>
#include <pthread.h>
+#include "un-namespace.h"
#include "thr_private.h"
@@ -54,10 +56,12 @@ _pthread_barrier_destroy(pthread_barrier_t *barrier)
int
_pthread_barrier_init(pthread_barrier_t *barrier,
- const pthread_barrierattr_t *attr, int count)
+ const pthread_barrierattr_t *attr, unsigned count)
{
pthread_barrier_t bar;
+ (void)attr;
+
if (barrier == NULL || count <= 0)
return (EINVAL);
diff --git a/lib/libthr/thread/thr_barrierattr.c b/lib/libthr/thread/thr_barrierattr.c
index 6785937..32b9723 100644
--- a/lib/libthr/thread/thr_barrierattr.c
+++ b/lib/libthr/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"
diff --git a/lib/libthr/thread/thr_cancel.c b/lib/libthr/thread/thr_cancel.c
index bedfaa9..1047eb2 100644
--- a/lib/libthr/thread/thr_cancel.c
+++ b/lib/libthr/thread/thr_cancel.c
@@ -27,7 +27,9 @@
*
*/
+#include "namespace.h"
#include <pthread.h>
+#include "un-namespace.h"
#include "thr_private.h"
@@ -36,8 +38,6 @@ __weak_reference(_pthread_setcancelstate, pthread_setcancelstate);
__weak_reference(_pthread_setcanceltype, pthread_setcanceltype);
__weak_reference(_pthread_testcancel, pthread_testcancel);
-int _pthread_setcanceltype(int type, int *oldtype);
-
int
_pthread_cancel(pthread_t pthread)
{
@@ -78,7 +78,7 @@ testcancel(struct pthread *curthread)
newval = curthread->cancelflags;
if (SHOULD_CANCEL(newval) && !THR_IN_CRITICAL(curthread))
- pthread_exit(PTHREAD_CANCELED);
+ _pthread_exit(PTHREAD_CANCELED);
}
int
diff --git a/lib/libthr/thread/thr_clean.c b/lib/libthr/thread/thr_clean.c
index 33fec2e..a5e9378 100644
--- a/lib/libthr/thread/thr_clean.c
+++ b/lib/libthr/thread/thr_clean.c
@@ -32,10 +32,12 @@
* $FreeBSD$
*/
+#include "namespace.h"
#include <signal.h>
#include <errno.h>
#include <stdlib.h>
#include <pthread.h>
+#include "un-namespace.h"
#include "thr_private.h"
diff --git a/lib/libthr/thread/thr_concurrency.c b/lib/libthr/thread/thr_concurrency.c
index 7f019fe..61f0c4a 100644
--- a/lib/libthr/thread/thr_concurrency.c
+++ b/lib/libthr/thread/thr_concurrency.c
@@ -32,8 +32,10 @@
* $FreeBSD$
*/
+#include "namespace.h"
#include <errno.h>
#include <pthread.h>
+#include "un-namespace.h"
#include "thr_private.h"
diff --git a/lib/libthr/thread/thr_cond.c b/lib/libthr/thread/thr_cond.c
index cd50c4d..108047d 100644
--- a/lib/libthr/thread/thr_cond.c
+++ b/lib/libthr/thread/thr_cond.c
@@ -26,17 +26,22 @@
* $FreeBSD$
*/
+#include "namespace.h"
#include <stdlib.h>
#include <errno.h>
#include <string.h>
#include <pthread.h>
#include <limits.h>
+#include "un-namespace.h"
#include "thr_private.h"
/*
* Prototypes
*/
+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);
static int cond_init(pthread_cond_t *cond, const pthread_condattr_t *attr);
static int cond_wait_common(pthread_cond_t *cond, pthread_mutex_t *mutex,
const struct timespec *abstime, int cancel);
diff --git a/lib/libthr/thread/thr_condattr.c b/lib/libthr/thread/thr_condattr.c
index 46b9ec0..9e14dc2 100644
--- a/lib/libthr/thread/thr_condattr.c
+++ b/lib/libthr/thread/thr_condattr.c
@@ -32,10 +32,12 @@
* $FreeBSD$
*/
+#include "namespace.h"
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <pthread.h>
+#include "un-namespace.h"
#include "thr_private.h"
diff --git a/lib/libthr/thread/thr_create.c b/lib/libthr/thread/thr_create.c
index b35f6b7..bb5724a 100644
--- a/lib/libthr/thread/thr_create.c
+++ b/lib/libthr/thread/thr_create.c
@@ -27,6 +27,7 @@
* $FreeBSD$
*/
+#include "namespace.h"
#include <sys/types.h>
#include <sys/signalvar.h>
#include <errno.h>
@@ -34,6 +35,7 @@
#include <string.h>
#include <stddef.h>
#include <pthread.h>
+#include "un-namespace.h"
#include "thr_private.h"
@@ -242,7 +244,7 @@ thread_start(struct pthread *curthread)
THR_UNLOCK(curthread);
/* Run the current thread's start routine with argument: */
- pthread_exit(curthread->start_routine(curthread->arg));
+ _pthread_exit(curthread->start_routine(curthread->arg));
/* This point should never be reached. */
PANIC("Thread has resumed after exit");
diff --git a/lib/libthr/thread/thr_detach.c b/lib/libthr/thread/thr_detach.c
index 385ea7b..bfcb6e6 100644
--- a/lib/libthr/thread/thr_detach.c
+++ b/lib/libthr/thread/thr_detach.c
@@ -28,9 +28,11 @@
*
*/
+#include "namespace.h"
#include <sys/types.h>
#include <errno.h>
#include <pthread.h>
+#include "un-namespace.h"
#include "thr_private.h"
diff --git a/lib/libthr/thread/thr_equal.c b/lib/libthr/thread/thr_equal.c
index f8882f5..f9f4916 100644
--- a/lib/libthr/thread/thr_equal.c
+++ b/lib/libthr/thread/thr_equal.c
@@ -31,7 +31,9 @@
*
* $FreeBSD$
*/
+#include "namespace.h"
#include <pthread.h>
+#include "un-namespace.h"
#include "thr_private.h"
__weak_reference(_pthread_equal, pthread_equal);
diff --git a/lib/libthr/thread/thr_exit.c b/lib/libthr/thread/thr_exit.c
index f6147054..d438ac5 100644
--- a/lib/libthr/thread/thr_exit.c
+++ b/lib/libthr/thread/thr_exit.c
@@ -44,7 +44,7 @@ void _pthread_exit(void *status);
__weak_reference(_pthread_exit, pthread_exit);
void
-_thread_exit(char *fname, int lineno, char *msg)
+_thread_exit(const char *fname, int lineno, const char *msg)
{
/* Write an error message to the standard error file descriptor: */
@@ -105,9 +105,7 @@ _pthread_exit(void *status)
while (curthread->cleanup != NULL) {
pthread_cleanup_pop(1);
}
- if (curthread->attr.cleanup_attr != NULL) {
- curthread->attr.cleanup_attr(curthread->attr.arg_attr);
- }
+
/* Check if there is thread specific data: */
if (curthread->specific != NULL) {
/* Run the thread-specific data destructors: */
diff --git a/lib/libthr/thread/thr_fork.c b/lib/libthr/thread/thr_fork.c
index 3a6ba51..558a036 100644
--- a/lib/libthr/thread/thr_fork.c
+++ b/lib/libthr/thread/thr_fork.c
@@ -60,12 +60,14 @@
*
*/
+#include "namespace.h"
#include <errno.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <pthread.h>
#include <spinlock.h>
+#include "un-namespace.h"
#include "libc_private.h"
#include "thr_private.h"
@@ -96,6 +98,8 @@ _pthread_atfork(void (*prepare)(void), void (*parent)(void),
__weak_reference(_fork, fork);
+pid_t _fork(void);
+
pid_t
_fork(void)
{
diff --git a/lib/libthr/thread/thr_getprio.c b/lib/libthr/thread/thr_getprio.c
index fa95ef9..e2cac2f 100644
--- a/lib/libthr/thread/thr_getprio.c
+++ b/lib/libthr/thread/thr_getprio.c
@@ -31,8 +31,10 @@
*
* $FreeBSD$
*/
+#include "namespace.h"
#include <errno.h>
#include <pthread.h>
+#include "un-namespace.h"
#include "thr_private.h"
__weak_reference(_pthread_getprio, pthread_getprio);
@@ -43,7 +45,7 @@ _pthread_getprio(pthread_t pthread)
int policy, ret;
struct sched_param param;
- if ((ret = pthread_getschedparam(pthread, &policy, &param)) == 0)
+ if ((ret = _pthread_getschedparam(pthread, &policy, &param)) == 0)
ret = param.sched_priority;
else {
/* Invalid thread: */
diff --git a/lib/libthr/thread/thr_getschedparam.c b/lib/libthr/thread/thr_getschedparam.c
index 907174c..88d8524 100644
--- a/lib/libthr/thread/thr_getschedparam.c
+++ b/lib/libthr/thread/thr_getschedparam.c
@@ -32,8 +32,10 @@
* $FreeBSD$
*/
+#include "namespace.h"
#include <errno.h>
#include <pthread.h>
+#include "un-namespace.h"
#include "thr_private.h"
diff --git a/lib/libthr/thread/thr_info.c b/lib/libthr/thread/thr_info.c
index 7605741..804ce98 100644
--- a/lib/libthr/thread/thr_info.c
+++ b/lib/libthr/thread/thr_info.c
@@ -32,9 +32,12 @@
* $FreeBSD$
*/
-#include <stdio.h>
+#include "namespace.h"
#include <stdlib.h>
#include <string.h>
+#include <pthread.h>
+#include <pthread_np.h>
+#include "un-namespace.h"
#include "thr_private.h"
@@ -42,7 +45,7 @@ __weak_reference(_pthread_set_name_np, pthread_set_name_np);
/* Set the thread name for debug. */
void
-_pthread_set_name_np(pthread_t thread, char *name)
+_pthread_set_name_np(pthread_t thread, const char *name)
{
struct pthread *curthread = _get_curthread();
int ret = 0;
diff --git a/lib/libthr/thread/thr_init.c b/lib/libthr/thread/thr_init.c
index 725ea4e..05006dc 100644
--- a/lib/libthr/thread/thr_init.c
+++ b/lib/libthr/thread/thr_init.c
@@ -55,7 +55,7 @@
#include "libc_private.h"
#include "thr_private.h"
-void *_usrstack;
+char *_usrstack;
struct pthread *_thr_initial;
int _thr_scope_system;
int _libthr_debug;
@@ -75,7 +75,6 @@ struct pthread_attr _pthread_attr_default = {
.suspend = THR_CREATE_RUNNING,
.flags = PTHREAD_SCOPE_SYSTEM,
.arg_attr = NULL,
- .cleanup_attr = NULL,
.stackaddr_attr = NULL,
.stacksize_attr = THR_STACK_DEFAULT,
.guardsize_attr = 0
@@ -95,9 +94,9 @@ struct pthread_cond_attr _pthread_condattr_default = {
};
pid_t _thr_pid;
-int _thr_guard_default;
-int _thr_stack_default = THR_STACK_DEFAULT;
-int _thr_stack_initial = THR_STACK_INITIAL;
+size_t _thr_guard_default;
+size_t _thr_stack_default = THR_STACK_DEFAULT;
+size_t _thr_stack_initial = THR_STACK_INITIAL;
int _thr_page_size;
int _gc_count;
umtx_t _mutex_static_lock;
@@ -120,26 +119,10 @@ static void init_main_thread(struct pthread *thread);
* This is so that static libraries will work.
*/
STATIC_LIB_REQUIRE(_accept);
-STATIC_LIB_REQUIRE(_bind);
STATIC_LIB_REQUIRE(_close);
STATIC_LIB_REQUIRE(_connect);
-STATIC_LIB_REQUIRE(_dup);
-STATIC_LIB_REQUIRE(_dup2);
-STATIC_LIB_REQUIRE(_execve);
STATIC_LIB_REQUIRE(_fcntl);
-STATIC_LIB_REQUIRE(_flock);
-STATIC_LIB_REQUIRE(_flockfile);
-STATIC_LIB_REQUIRE(_fstat);
-STATIC_LIB_REQUIRE(_fstatfs);
STATIC_LIB_REQUIRE(_fsync);
-STATIC_LIB_REQUIRE(_getdirentries);
-STATIC_LIB_REQUIRE(_getlogin);
-STATIC_LIB_REQUIRE(_getpeername);
-STATIC_LIB_REQUIRE(_getsockname);
-STATIC_LIB_REQUIRE(_getsockopt);
-STATIC_LIB_REQUIRE(_ioctl);
-STATIC_LIB_REQUIRE(_kevent);
-STATIC_LIB_REQUIRE(_listen);
STATIC_LIB_REQUIRE(_nanosleep);
STATIC_LIB_REQUIRE(_open);
STATIC_LIB_REQUIRE(_pthread_getspecific);
@@ -162,7 +145,6 @@ STATIC_LIB_REQUIRE(_recvmsg);
STATIC_LIB_REQUIRE(_select);
STATIC_LIB_REQUIRE(_sendmsg);
STATIC_LIB_REQUIRE(_sendto);
-STATIC_LIB_REQUIRE(_setsockopt);
STATIC_LIB_REQUIRE(_sigaction);
STATIC_LIB_REQUIRE(_sigprocmask);
STATIC_LIB_REQUIRE(_sigsuspend);
@@ -332,7 +314,7 @@ _libpthread_init(struct pthread *curthread)
PANIC("Can't open console");
if (setlogin("root") == -1)
PANIC("Can't set login to root");
- if (__sys_ioctl(fd, TIOCSCTTY, (char *) NULL) == -1)
+ if (_ioctl(fd, TIOCSCTTY, (char *) NULL) == -1)
PANIC("Can't set controlling terminal");
}
@@ -389,7 +371,7 @@ 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 -
+ if (mmap(_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");
@@ -403,7 +385,7 @@ 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 = _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/libthr/thread/thr_join.c b/lib/libthr/thread/thr_join.c
index 2f22cbe..de27074 100644
--- a/lib/libthr/thread/thr_join.c
+++ b/lib/libthr/thread/thr_join.c
@@ -27,11 +27,15 @@
*
*/
+#include "namespace.h"
#include <errno.h>
#include <pthread.h>
+#include "un-namespace.h"
#include "thr_private.h"
+int _pthread_timedjoin_np(pthread_t pthread, void **thread_return,
+ const struct timespec *abstime);
static int join_common(pthread_t, void **, const struct timespec *);
__weak_reference(_pthread_join, pthread_join);
diff --git a/lib/libthr/thread/thr_kill.c b/lib/libthr/thread/thr_kill.c
index 38ec80f..e55681a 100644
--- a/lib/libthr/thread/thr_kill.c
+++ b/lib/libthr/thread/thr_kill.c
@@ -32,9 +32,11 @@
* $FreeBSD$
*/
+#include "namespace.h"
#include <errno.h>
#include <signal.h>
#include <pthread.h>
+#include "un-namespace.h"
#include "thr_private.h"
diff --git a/lib/libthr/thread/thr_list.c b/lib/libthr/thread/thr_list.c
index 1c62a21..d46b5ea 100644
--- a/lib/libthr/thread/thr_list.c
+++ b/lib/libthr/thread/thr_list.c
@@ -310,7 +310,8 @@ _thr_ref_delete(struct pthread *curthread, struct pthread *thread)
}
void
-_thr_ref_delete_unlocked(struct pthread *curthread, struct pthread *thread)
+_thr_ref_delete_unlocked(struct pthread *curthread __unused,
+ struct pthread *thread)
{
if (thread != NULL) {
thread->refcount--;
@@ -321,7 +322,7 @@ _thr_ref_delete_unlocked(struct pthread *curthread, struct pthread *thread)
}
int
-_thr_find_thread(struct pthread *curthread, struct pthread *thread,
+_thr_find_thread(struct pthread *curthread __unused, struct pthread *thread,
int include_dead)
{
struct pthread *pthread;
diff --git a/lib/libthr/thread/thr_main_np.c b/lib/libthr/thread/thr_main_np.c
index 6b4626e..bfa8b87 100644
--- a/lib/libthr/thread/thr_main_np.c
+++ b/lib/libthr/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"
@@ -44,5 +46,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/libthr/thread/thr_multi_np.c b/lib/libthr/thread/thr_multi_np.c
index bd42365..3ea2cb4 100644
--- a/lib/libthr/thread/thr_multi_np.c
+++ b/lib/libthr/thread/thr_multi_np.c
@@ -31,8 +31,11 @@
*
* $FreeBSD$
*/
+
+#include "namespace.h"
#include <pthread.h>
#include <pthread_np.h>
+#include "un-namespace.h"
__weak_reference(_pthread_multi_np, pthread_multi_np);
@@ -45,6 +48,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/libthr/thread/thr_mutex.c b/lib/libthr/thread/thr_mutex.c
index 67b4760..fdceadf 100644
--- a/lib/libthr/thread/thr_mutex.c
+++ b/lib/libthr/thread/thr_mutex.c
@@ -33,12 +33,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)
@@ -64,8 +67,15 @@
/*
* Prototypes
*/
-static int mutex_self_trylock(struct pthread *, pthread_mutex_t);
-static int mutex_self_lock(struct pthread *, pthread_mutex_t,
+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 *mutex);
+int __pthread_mutex_timedlock(pthread_mutex_t *mutex,
+ const struct timespec *abstime);
+
+static int mutex_self_trylock(pthread_mutex_t);
+static int mutex_self_lock(pthread_mutex_t,
const struct timespec *abstime);
static int mutex_unlock_common(pthread_mutex_t *, int);
@@ -265,7 +275,7 @@ mutex_trylock_common(struct pthread *curthread, pthread_mutex_t *mutex)
MUTEX_ASSERT_NOT_OWNED(m);
TAILQ_INSERT_TAIL(&curthread->mutexq, m, m_qe);
} else if (m->m_owner == curthread) {
- ret = mutex_self_trylock(curthread, m);
+ ret = mutex_self_trylock(m);
} /* else {} */
return (ret);
@@ -321,7 +331,7 @@ mutex_lock_common(struct pthread *curthread, pthread_mutex_t *mutex,
MUTEX_ASSERT_NOT_OWNED(m);
TAILQ_INSERT_TAIL(&curthread->mutexq, m, m_qe);
} else if (m->m_owner == curthread) {
- ret = mutex_self_lock(curthread, m, abstime);
+ ret = mutex_self_lock(m, abstime);
} else {
if (abstime == NULL) {
THR_UMTX_LOCK(curthread, &m->m_lock);
@@ -461,7 +471,7 @@ _mutex_cv_lock(pthread_mutex_t *m)
}
static int
-mutex_self_trylock(struct pthread *curthread, pthread_mutex_t m)
+mutex_self_trylock(pthread_mutex_t m)
{
int ret;
@@ -489,8 +499,7 @@ mutex_self_trylock(struct pthread *curthread, pthread_mutex_t m)
}
static int
-mutex_self_lock(struct pthread *curthread, pthread_mutex_t m,
- const struct timespec *abstime)
+mutex_self_lock(pthread_mutex_t m, const struct timespec *abstime)
{
struct timespec ts1, ts2;
int ret;
@@ -607,8 +616,10 @@ _pthread_mutex_getprioceiling(pthread_mutex_t *mutex,
ret = EINVAL;
else if ((*mutex)->m_protocol != PTHREAD_PRIO_PROTECT)
ret = EINVAL;
- else
- ret = (*mutex)->m_prio;
+ else {
+ *prioceiling = (*mutex)->m_prio;
+ ret = 0;
+ }
return(ret);
}
@@ -624,10 +635,10 @@ _pthread_mutex_setprioceiling(pthread_mutex_t *mutex,
ret = EINVAL;
else if ((*mutex)->m_protocol != PTHREAD_PRIO_PROTECT)
ret = EINVAL;
- else if ((ret = pthread_mutex_lock(mutex)) == 0) {
+ else if ((ret = _pthread_mutex_lock(mutex)) == 0) {
tmp = (*mutex)->m_prio;
(*mutex)->m_prio = prioceiling;
- ret = pthread_mutex_unlock(mutex);
+ ret = _pthread_mutex_unlock(mutex);
/* Return the old ceiling. */
*old_ceiling = tmp;
diff --git a/lib/libthr/thread/thr_mutexattr.c b/lib/libthr/thread/thr_mutexattr.c
index e60ec67..c77d946 100644
--- a/lib/libthr/thread/thr_mutexattr.c
+++ b/lib/libthr/thread/thr_mutexattr.c
@@ -65,10 +65,14 @@
*
*/
+#include "namespace.h"
#include <string.h>
#include <stdlib.h>
#include <errno.h>
#include <pthread.h>
+#include <pthread_np.h>
+#include "un-namespace.h"
+
#include "thr_private.h"
__weak_reference(_pthread_mutexattr_init, pthread_mutexattr_init);
diff --git a/lib/libthr/thread/thr_private.h b/lib/libthr/thread/thr_private.h
index c3f2c9f..f7fa9ab 100644
--- a/lib/libthr/thread/thr_private.h
+++ b/lib/libthr/thread/thr_private.h
@@ -45,7 +45,6 @@
#include <signal.h>
#include <stddef.h>
#include <stdio.h>
-#include <sched.h>
#include <unistd.h>
#include <ucontext.h>
#include <sys/thr.h>
@@ -203,7 +202,7 @@ struct pthread_spinlock {
*/
struct pthread_cleanup {
struct pthread_cleanup *next;
- void (*routine)();
+ void (*routine)(void *args);
void *routine_arg;
int onstack;
};
@@ -239,7 +238,6 @@ struct pthread_attr {
#define THR_STACK_USER 0x100 /* 0xFF reserved for <pthread.h> */
int flags;
void *arg_attr;
- void (*cleanup_attr)();
void *stackaddr_attr;
size_t stacksize_attr;
size_t guardsize_attr;
@@ -596,7 +594,7 @@ extern int __isthreaded;
* Global variables for the pthread kernel.
*/
-extern void *_usrstack __hidden;
+extern char *_usrstack __hidden;
extern struct pthread *_thr_initial __hidden;
extern int _thr_scope_system __hidden;
@@ -625,9 +623,9 @@ extern struct pthread_mutex_attr _pthread_mutexattr_default __hidden;
extern struct pthread_cond_attr _pthread_condattr_default __hidden;
extern pid_t _thr_pid __hidden;
-extern int _thr_guard_default __hidden;
-extern int _thr_stack_default __hidden;
-extern int _thr_stack_initial __hidden;
+extern size_t _thr_guard_default __hidden;
+extern size_t _thr_stack_default __hidden;
+extern size_t _thr_stack_initial __hidden;
extern int _thr_page_size __hidden;
/* Garbage thread count. */
extern int _gc_count __hidden;
@@ -650,37 +648,8 @@ int _mutex_reinit(pthread_mutex_t *) __hidden;
void _mutex_fork(struct pthread *curthread) __hidden;
void _mutex_unlock_private(struct pthread *) __hidden;
void _libpthread_init(struct pthread *) __hidden;
-void *_pthread_getspecific(pthread_key_t);
-int _pthread_cond_init(pthread_cond_t *, const pthread_condattr_t *);
-int _pthread_cond_destroy(pthread_cond_t *);
-int _pthread_cond_wait(pthread_cond_t *, pthread_mutex_t *);
-int _pthread_cond_timedwait(pthread_cond_t *, pthread_mutex_t *,
- const struct timespec *);
-int _pthread_cond_signal(pthread_cond_t *);
-int _pthread_cond_broadcast(pthread_cond_t *);
-int _pthread_create(pthread_t * thread, const pthread_attr_t * attr,
- void *(*start_routine) (void *), void *arg);
-int _pthread_key_create(pthread_key_t *, void (*) (void *));
-int _pthread_key_delete(pthread_key_t);
-int _pthread_mutex_destroy(pthread_mutex_t *);
-int _pthread_mutex_init(pthread_mutex_t *, const pthread_mutexattr_t *);
-int _pthread_mutex_lock(pthread_mutex_t *);
-int _pthread_mutex_trylock(pthread_mutex_t *);
-int _pthread_mutex_unlock(pthread_mutex_t *);
-int _pthread_mutexattr_init(pthread_mutexattr_t *);
-int _pthread_mutexattr_destroy(pthread_mutexattr_t *);
-int _pthread_mutexattr_settype(pthread_mutexattr_t *, int);
-int _pthread_once(pthread_once_t *, void (*) (void));
-int _pthread_rwlock_init(pthread_rwlock_t *, const pthread_rwlockattr_t *);
-int _pthread_rwlock_destroy (pthread_rwlock_t *);
-struct pthread *_pthread_self(void);
-int _pthread_setspecific(pthread_key_t, const void *);
-void _pthread_testcancel(void);
-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 *) __hidden;
-void _thread_exit(char *, int, char *) __hidden __dead2;
+void _thread_exit(const char *, int, const char *) __hidden __dead2;
void _thr_exit_cleanup(void) __hidden;
int _thr_ref_add(struct pthread *, struct pthread *, int) __hidden;
void _thr_ref_delete(struct pthread *, struct pthread *) __hidden;
@@ -714,32 +683,17 @@ void _thr_assert_lock_level(void) __hidden __dead2;
void _thr_ast(struct pthread *) __hidden;
void _thr_once_init(void) __hidden;
void _thr_report_creation(struct pthread *curthread,
- struct pthread *newthread) __hidden;
+ struct pthread *newthread) __hidden;
void _thr_report_death(struct pthread *curthread) __hidden;
void _thread_bp_create(void);
void _thread_bp_death(void);
-/* #include <sys/aio.h> */
-#ifdef _SYS_AIO_H_
-int __sys_aio_suspend(const struct aiocb * const[], int, const struct timespec *);
-#endif
-
/* #include <fcntl.h> */
#ifdef _SYS_FCNTL_H_
int __sys_fcntl(int, int, ...);
int __sys_open(const char *, int, ...);
#endif
-/* #include <sys/ioctl.h> */
-#ifdef _SYS_IOCTL_H_
-int __sys_ioctl(int, unsigned long, ...);
-#endif
-
-/* #inclde <sched.h> */
-#ifdef _SCHED_H_
-int __sys_sched_yield(void);
-#endif
-
/* #include <signal.h> */
#ifdef _SIGNAL_H_
int __sys_kill(pid_t, int);
@@ -749,25 +703,10 @@ int __sys_sigprocmask(int, const sigset_t *, sigset_t *);
int __sys_sigsuspend(const sigset_t *);
int __sys_sigreturn(ucontext_t *);
int __sys_sigaltstack(const struct sigaltstack *, struct sigaltstack *);
-#endif
-
-/* #include <sys/socket.h> */
-#ifdef _SYS_SOCKET_H_
-int __sys_accept(int, struct sockaddr *, socklen_t *);
-int __sys_connect(int, const struct sockaddr *, socklen_t);
-ssize_t __sys_recv(int, void *, size_t, int);
-ssize_t __sys_recvfrom(int, void *, size_t, int, struct sockaddr *, socklen_t *);
-ssize_t __sys_recvmsg(int, struct msghdr *, int);
-int __sys_sendfile(int, int, off_t, size_t, struct sf_hdtr *,
- off_t *, int);
-ssize_t __sys_sendmsg(int, const struct msghdr *, int);
-ssize_t __sys_sendto(int, const void *,size_t, int, const struct sockaddr *, socklen_t);
-#endif
-
-/* #include <sys/uio.h> */
-#ifdef _SYS_UIO_H_
-ssize_t __sys_readv(int, const struct iovec *, int);
-ssize_t __sys_writev(int, const struct iovec *, int);
+int __sys_sigwait(const sigset_t *, int *);
+int __sys_sigtimedwait(const sigset_t *, siginfo_t *,
+ const struct timespec *);
+int __sys_sigwaitinfo(const sigset_t *set, siginfo_t *info);
#endif
/* #include <time.h> */
@@ -778,28 +717,11 @@ int __sys_nanosleep(const struct timespec *, struct timespec *);
/* #include <unistd.h> */
#ifdef _UNISTD_H_
int __sys_close(int);
-int __sys_execve(const char *, char * const *, char * const *);
int __sys_fork(void);
-int __sys_fsync(int);
pid_t __sys_getpid(void);
-int __sys_select(int, fd_set *, fd_set *, fd_set *, struct timeval *);
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(const sigset_t *, siginfo_t *,
- const struct timespec *);
-int __sys_sigwaitinfo(const sigset_t *set, siginfo_t *info);
-#endif
-
-/* #include <poll.h> */
-#ifdef _SYS_POLL_H_
-int __sys_poll(struct pollfd *, unsigned, int);
-#endif
-
-/* #include <sys/mman.h> */
-#ifdef _SYS_MMAN_H_
-int __sys_msync(void *, size_t, int);
#endif
static inline int
diff --git a/lib/libthr/thread/thr_pspinlock.c b/lib/libthr/thread/thr_pspinlock.c
index 9343fdc..ec3d68b 100644
--- a/lib/libthr/thread/thr_pspinlock.c
+++ b/lib/libthr/thread/thr_pspinlock.c
@@ -26,9 +26,12 @@
* $FreeBSD$
*/
+#include "namespace.h"
#include <errno.h>
#include <stdlib.h>
#include <pthread.h>
+#include "un-namespace.h"
+
#include "thr_private.h"
#define SPIN_COUNT 100000
diff --git a/lib/libthr/thread/thr_resume_np.c b/lib/libthr/thread/thr_resume_np.c
index 2cea2d6..7fd3733 100644
--- a/lib/libthr/thread/thr_resume_np.c
+++ b/lib/libthr/thread/thr_resume_np.c
@@ -32,8 +32,11 @@
* $FreeBSD$
*/
+#include "namespace.h"
#include <errno.h>
#include <pthread.h>
+#include <pthread_np.h>
+#include "un-namespace.h"
#include "thr_private.h"
diff --git a/lib/libthr/thread/thr_rtld.c b/lib/libthr/thread/thr_rtld.c
index 7dbd910..827b962 100644
--- a/lib/libthr/thread/thr_rtld.c
+++ b/lib/libthr/thread/thr_rtld.c
@@ -165,7 +165,7 @@ _thr_rtld_lock_release(void *lock)
}
static int
-_thr_rtld_set_flag(int mask)
+_thr_rtld_set_flag(int mask __unused)
{
/*
* The caller's code in rtld-elf is broken, it is not signal safe,
@@ -175,7 +175,7 @@ _thr_rtld_set_flag(int mask)
}
static int
-_thr_rtld_clr_flag(int mask)
+_thr_rtld_clr_flag(int mask __unused)
{
return (0);
}
diff --git a/lib/libthr/thread/thr_rwlock.c b/lib/libthr/thread/thr_rwlock.c
index 6881ef8..ea2c763 100644
--- a/lib/libthr/thread/thr_rwlock.c
+++ b/lib/libthr/thread/thr_rwlock.c
@@ -53,7 +53,7 @@ __weak_reference(_pthread_rwlock_timedwrlock, pthread_rwlock_timedwrlock);
*/
static int
-rwlock_init(pthread_rwlock_t *rwlock, const pthread_rwlockattr_t *attr)
+rwlock_init(pthread_rwlock_t *rwlock, const pthread_rwlockattr_t *attr __unused)
{
pthread_rwlock_t prwlock;
int ret;
diff --git a/lib/libthr/thread/thr_rwlockattr.c b/lib/libthr/thread/thr_rwlockattr.c
index 8c0697b..b47d167 100644
--- a/lib/libthr/thread/thr_rwlockattr.c
+++ b/lib/libthr/thread/thr_rwlockattr.c
@@ -26,10 +26,12 @@
* $FreeBSD$
*/
+#include "namespace.h"
#include <errno.h>
#include <stdlib.h>
-
#include <pthread.h>
+#include "un-namespace.h"
+
#include "thr_private.h"
__weak_reference(_pthread_rwlockattr_destroy, pthread_rwlockattr_destroy);
diff --git a/lib/libthr/thread/thr_self.c b/lib/libthr/thread/thr_self.c
index baaf44c..85fb54e 100644
--- a/lib/libthr/thread/thr_self.c
+++ b/lib/libthr/thread/thr_self.c
@@ -32,7 +32,9 @@
* $FreeBSD$
*/
+#include "namespace.h"
#include <pthread.h>
+#include "un-namespace.h"
#include "thr_private.h"
diff --git a/lib/libthr/thread/thr_setprio.c b/lib/libthr/thread/thr_setprio.c
index c5a9506..bb9a9bf 100644
--- a/lib/libthr/thread/thr_setprio.c
+++ b/lib/libthr/thread/thr_setprio.c
@@ -31,7 +31,11 @@
*
* $FreeBSD$
*/
+
+#include "namespace.h"
#include <pthread.h>
+#include "un-namespace.h"
+
#include "thr_private.h"
__weak_reference(_pthread_setprio, pthread_setprio);
@@ -42,9 +46,9 @@ _pthread_setprio(pthread_t pthread, int prio)
int ret, policy;
struct sched_param param;
- if ((ret = pthread_getschedparam(pthread, &policy, &param)) == 0) {
+ if ((ret = _pthread_getschedparam(pthread, &policy, &param)) == 0) {
param.sched_priority = prio;
- ret = pthread_setschedparam(pthread, policy, &param);
+ ret = _pthread_setschedparam(pthread, policy, &param);
}
/* Return the error status: */
diff --git a/lib/libthr/thread/thr_setschedparam.c b/lib/libthr/thread/thr_setschedparam.c
index 1006849..9cbebbf 100644
--- a/lib/libthr/thread/thr_setschedparam.c
+++ b/lib/libthr/thread/thr_setschedparam.c
@@ -32,9 +32,11 @@
* $FreeBSD$
*/
-#include <errno.h>
+#include "namespace.h"
#include <sys/param.h>
+#include <errno.h>
#include <pthread.h>
+#include "un-namespace.h"
#include "thr_private.h"
diff --git a/lib/libthr/thread/thr_sig.c b/lib/libthr/thread/thr_sig.c
index 71f97a0..865fb72 100644
--- a/lib/libthr/thread/thr_sig.c
+++ b/lib/libthr/thread/thr_sig.c
@@ -26,6 +26,7 @@
* $FreeBSD$
*/
+#include "namespace.h"
#include <sys/param.h>
#include <sys/types.h>
#include <sys/signalvar.h>
@@ -35,6 +36,7 @@
#include <unistd.h>
#include <string.h>
#include <pthread.h>
+#include "un-namespace.h"
#include "thr_private.h"
@@ -45,8 +47,14 @@
#define DBG_MSG(x...)
#endif
+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);
+
static void
-sigcancel_handler(int sig, siginfo_t *info, ucontext_t *ucp)
+sigcancel_handler(int sig __unused,
+ siginfo_t *info __unused, ucontext_t *ucp __unused)
{
struct pthread *curthread = _get_curthread();
diff --git a/lib/libthr/thread/thr_single_np.c b/lib/libthr/thread/thr_single_np.c
index c8e5a94..c74fc55 100644
--- a/lib/libthr/thread/thr_single_np.c
+++ b/lib/libthr/thread/thr_single_np.c
@@ -32,8 +32,10 @@
* $FreeBSD$
*/
+#include "namespace.h"
#include <pthread.h>
#include <pthread_np.h>
+#include "un-namespace.h"
__weak_reference(_pthread_single_np, pthread_single_np);
@@ -41,7 +43,7 @@ int _pthread_single_np()
{
/* 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/libthr/thread/thr_spec.c b/lib/libthr/thread/thr_spec.c
index c5464b5..cd4d49f 100644
--- a/lib/libthr/thread/thr_spec.c
+++ b/lib/libthr/thread/thr_spec.c
@@ -32,11 +32,13 @@
* $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"
@@ -103,7 +105,7 @@ _thread_cleanupspecific(void)
{
struct pthread *curthread = _get_curthread();
void (*destructor)( void *);
- void *data = NULL;
+ const void *data = NULL;
int key;
int i;
@@ -122,8 +124,7 @@ _thread_cleanupspecific(void)
(curthread->specific[key].data != NULL)) {
if (curthread->specific[key].seqno ==
_thread_keytable[key].seqno) {
- data = (void *)
- curthread->specific[key].data;
+ data = curthread->specific[key].data;
destructor = _thread_keytable[key].destructor;
}
curthread->specific[key].data = NULL;
@@ -140,7 +141,7 @@ _thread_cleanupspecific(void)
* destructor:
*/
THR_LOCK_RELEASE(curthread, &_keytable_lock);
- destructor(data);
+ destructor(__DECONST(void *, data));
THR_LOCK_ACQUIRE(curthread, &_keytable_lock);
}
}
@@ -203,7 +204,7 @@ void *
_pthread_getspecific(pthread_key_t key)
{
struct pthread *pthread;
- void *data;
+ const void *data;
/* Point to the running thread: */
pthread = _get_curthread();
@@ -214,7 +215,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
@@ -225,5 +226,5 @@ _pthread_getspecific(pthread_key_t key)
} else
/* No specific data has been created, so just return NULL: */
data = NULL;
- return (data);
+ return (__DECONST(void *, data));
}
diff --git a/lib/libthr/thread/thr_spinlock.c b/lib/libthr/thread/thr_spinlock.c
index 25f6337..b9d2279 100644
--- a/lib/libthr/thread/thr_spinlock.c
+++ b/lib/libthr/thread/thr_spinlock.c
@@ -65,7 +65,7 @@ static void init_spinlock(spinlock_t *lck);
void
_spinunlock(spinlock_t *lck)
{
- THR_UMTX_UNLOCK(_get_curthread(), (umtx_t *)&lck->access_lock);
+ THR_UMTX_UNLOCK(_get_curthread(), (volatile umtx_t *)&lck->access_lock);
}
void
@@ -77,11 +77,11 @@ _spinlock(spinlock_t *lck)
PANIC("Spinlocks not initialized.");
if (lck->fname == NULL)
init_spinlock(lck);
- THR_UMTX_LOCK(_get_curthread(), (umtx_t *)&lck->access_lock);
+ THR_UMTX_LOCK(_get_curthread(), (volatile umtx_t *)&lck->access_lock);
}
void
-_spinlock_debug(spinlock_t *lck, char *fname, int lineno)
+_spinlock_debug(spinlock_t *lck, char *fname __unused, int lineno __unused)
{
_spinlock(lck);
}
@@ -118,7 +118,8 @@ _thr_spinlock_init(void)
* it is better to do pthread_atfork in libc.
*/
for (i = 0; i < spinlock_count; i++)
- _thr_umtx_init((umtx_t *)&extra[i].owner->access_lock);
+ _thr_umtx_init((volatile umtx_t *)
+ &extra[i].owner->access_lock);
} else {
initialized = 1;
}
diff --git a/lib/libthr/thread/thr_stack.c b/lib/libthr/thread/thr_stack.c
index 3c5503f..9376086 100644
--- a/lib/libthr/thread/thr_stack.c
+++ b/lib/libthr/thread/thr_stack.c
@@ -113,7 +113,7 @@ static LIST_HEAD(, stack) mstackq = LIST_HEAD_INITIALIZER(mstackq);
* high memory
*
*/
-static void *last_stack = NULL;
+static char *last_stack = NULL;
/*
* Round size up to the nearest multiple of
@@ -236,8 +236,9 @@ _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 *)
+ ((char *)attr->stackaddr_attr +
+ 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/libthr/thread/thr_suspend_np.c b/lib/libthr/thread/thr_suspend_np.c
index 7dbe539..ec34029 100644
--- a/lib/libthr/thread/thr_suspend_np.c
+++ b/lib/libthr/thread/thr_suspend_np.c
@@ -32,8 +32,11 @@
* $FreeBSD$
*/
+#include "namespace.h"
#include <errno.h>
#include <pthread.h>
+#include <pthread_np.h>
+#include "un-namespace.h"
#include "thr_private.h"
diff --git a/lib/libthr/thread/thr_switch_np.c b/lib/libthr/thread/thr_switch_np.c
index 98497b7..f6ffb07 100644
--- a/lib/libthr/thread/thr_switch_np.c
+++ b/lib/libthr/thread/thr_switch_np.c
@@ -32,9 +32,11 @@
* $FreeBSD$
*/
+#include "namespace.h"
#include <errno.h>
#include <pthread.h>
#include <pthread_np.h>
+#include "un-namespace.h"
#include "thr_private.h"
@@ -43,13 +45,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/libthr/thread/thr_syscalls.c b/lib/libthr/thread/thr_syscalls.c
index fec3dba..a36849a 100644
--- a/lib/libthr/thread/thr_syscalls.c
+++ b/lib/libthr/thread/thr_syscalls.c
@@ -64,6 +64,7 @@
*
*/
+#include "namespace.h"
#include <sys/types.h>
#include <sys/mman.h>
#include <sys/param.h>
@@ -87,22 +88,75 @@
#include <termios.h>
#include <unistd.h>
#include <pthread.h>
+#include "un-namespace.h"
#include "thr_private.h"
-extern int __creat(const char *, mode_t);
-extern int __pause(void);
-extern int __pselect(int count, fd_set *rfds, fd_set *wfds, fd_set *efds,
- const struct timespec *timo, const sigset_t *mask);
-extern unsigned int __sleep(unsigned int);
-extern int __system(const char *);
-extern int __tcdrain(int);
-extern int __usleep(useconds_t);
-extern pid_t __wait(int *);
-extern pid_t __sys_wait4(pid_t, int *, int, struct rusage *);
-extern pid_t __waitpid(pid_t, int *, int);
+extern int __creat(const char *, mode_t);
+extern int __pause(void);
+extern int __pselect(int, fd_set *, fd_set *, fd_set *,
+ const struct timespec *, const sigset_t *);
+extern unsigned __sleep(unsigned int);
+extern int __system(const char *);
+extern int __tcdrain(int);
+extern int __usleep(useconds_t);
+extern pid_t __wait(int *);
+extern pid_t __waitpid(pid_t, int *, int);
+extern int __sys_aio_suspend(const struct aiocb * const[], int,
+ const struct timespec *);
+extern int __sys_accept(int, struct sockaddr *, socklen_t *);
+extern int __sys_connect(int, const struct sockaddr *, socklen_t);
+extern int __sys_fsync(int);
+extern int __sys_msync(void *, size_t, int);
+extern int __sys_poll(struct pollfd *, unsigned, int);
+extern ssize_t __sys_recv(int, void *, size_t, int);
+extern ssize_t __sys_recvfrom(int, void *, size_t, int, struct sockaddr *, socklen_t *);
+extern ssize_t __sys_recvmsg(int, struct msghdr *, int);
+extern int __sys_select(int, fd_set *, fd_set *, fd_set *, struct timeval *);
+extern int __sys_sendfile(int, int, off_t, size_t, struct sf_hdtr *,
+ off_t *, int);
+extern ssize_t __sys_sendmsg(int, const struct msghdr *, int);
+extern ssize_t __sys_sendto(int, const void *,size_t, int, const struct sockaddr *, socklen_t);
+extern ssize_t __sys_readv(int, const struct iovec *, int);
+extern pid_t __sys_wait4(pid_t, int *, int, struct rusage *);
+extern ssize_t __sys_writev(int, const struct iovec *, int);
+
+int ___creat(const char *, mode_t);
+int __accept(int, struct sockaddr *, socklen_t *);
+int __close(int);
+int __connect(int, const struct sockaddr *, socklen_t);
+int __fcntl(int, int,...);
+int __fsync(int);
+int __msync(void *, size_t, int);
+int __nanosleep(const struct timespec *, struct timespec *);
+int __open(const char *, int,...);
+int __poll(struct pollfd *, unsigned int, int);
+ssize_t __read(int, void *buf, size_t);
+ssize_t __readv(int, const struct iovec *, int);
+ssize_t __recvfrom(int, void *, size_t, int f, struct sockaddr *, socklen_t *);
+ssize_t __recvmsg(int, struct msghdr *, int);
+int __select(int, fd_set *, fd_set *, fd_set *, struct timeval *);
+ssize_t __sendmsg(int, const struct msghdr *, int);
+ssize_t __sendto(int, const void *, size_t, int,
+ const struct sockaddr *, socklen_t);
+pid_t __wait4(pid_t, int *, int, struct rusage *);
+ssize_t __write(int, const void *, size_t);
+ssize_t __writev(int, const struct iovec *, int);
+int _aio_suspend(const struct aiocb * const iocbs[], int,
+ const struct timespec *);
+int _pause(void);
+int _pselect(int, fd_set *, fd_set *, fd_set *,
+ const struct timespec *, const sigset_t *);
+int _raise(int);
+unsigned _sleep(unsigned);
+int _system(const char *);
+int _tcdrain(int);
+int _vfork(void);
+pid_t _wait(int *);
+
__weak_reference(__accept, accept);
+
int
__accept(int s, struct sockaddr *addr, socklen_t *addrlen)
{
diff --git a/lib/libthr/thread/thr_umtx.c b/lib/libthr/thread/thr_umtx.c
index ba73de8..cba6942 100644
--- a/lib/libthr/thread/thr_umtx.c
+++ b/lib/libthr/thread/thr_umtx.c
@@ -33,7 +33,8 @@
int
__thr_umtx_lock(volatile umtx_t *mtx, long id)
{
- while (_umtx_op((struct umtx *)mtx, UMTX_OP_LOCK, id, 0, 0))
+ while (_umtx_op(__DEVOLATILE(struct umtx *, mtx),
+ UMTX_OP_LOCK, id, 0, 0))
;
return (0);
}
@@ -45,8 +46,8 @@ __thr_umtx_timedlock(volatile umtx_t *mtx, long id,
if (timeout && (timeout->tv_sec < 0 || (timeout->tv_sec == 0 &&
timeout->tv_nsec <= 0)))
return (ETIMEDOUT);
- if (_umtx_op((struct umtx *)mtx, UMTX_OP_LOCK, id, 0,
- (void *)timeout) == 0)
+ if (_umtx_op(__DEVOLATILE(struct umtx *, mtx), UMTX_OP_LOCK, id, 0,
+ __DECONST(void *, timeout)) == 0)
return (0);
return (errno);
}
@@ -54,7 +55,8 @@ __thr_umtx_timedlock(volatile umtx_t *mtx, long id,
int
__thr_umtx_unlock(volatile umtx_t *mtx, long id)
{
- if (_umtx_op((struct umtx *)mtx, UMTX_OP_UNLOCK, id, 0, 0) == 0)
+ if (_umtx_op(__DEVOLATILE(struct umtx *, mtx), UMTX_OP_UNLOCK,
+ id, 0, 0) == 0)
return (0);
return (errno);
}
@@ -65,8 +67,8 @@ _thr_umtx_wait(volatile umtx_t *mtx, long id, const struct timespec *timeout)
if (timeout && (timeout->tv_sec < 0 || (timeout->tv_sec == 0 &&
timeout->tv_nsec <= 0)))
return (ETIMEDOUT);
- if (_umtx_op((struct umtx *)mtx, UMTX_OP_WAIT, id, 0,
- (void*) timeout) == 0)
+ if (_umtx_op(__DEVOLATILE(struct umtx *, mtx), UMTX_OP_WAIT, id, 0,
+ __DECONST(void*, timeout)) == 0)
return (0);
return (errno);
}
@@ -74,7 +76,8 @@ _thr_umtx_wait(volatile umtx_t *mtx, long id, const struct timespec *timeout)
int
_thr_umtx_wake(volatile umtx_t *mtx, int nr_wakeup)
{
- if (_umtx_op((struct umtx *)mtx, UMTX_OP_WAKE, nr_wakeup, 0, 0) == 0)
+ if (_umtx_op(__DEVOLATILE(struct umtx *, mtx), UMTX_OP_WAKE,
+ nr_wakeup, 0, 0) == 0)
return (0);
return (errno);
}
diff --git a/lib/libthr/thread/thr_yield.c b/lib/libthr/thread/thr_yield.c
index 2c96820..300504b 100644
--- a/lib/libthr/thread/thr_yield.c
+++ b/lib/libthr/thread/thr_yield.c
@@ -31,8 +31,11 @@
*
* $FreeBSD$
*/
+
+#include "namespace.h"
#include <pthread.h>
-#include "thr_private.h"
+#include <sched.h>
+#include "un-namespace.h"
__weak_reference(_pthread_yield, pthread_yield);
OpenPOWER on IntegriCloud