summaryrefslogtreecommitdiff
path: root/src/thread
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2018-09-10 23:26:40 -0400
committerRich Felker <dalias@aerifal.cx>2018-09-12 14:34:33 -0400
commit13d1afa46f8098df290008c681816c9eb89ffbdb (patch)
tree01ec1581298b49f20848f9c5ce61bfa9bccd7e1a /src/thread
parent8c1ac426e15b27d2879afa26a500fd80010b33b9 (diff)
downloadmusl-13d1afa46f8098df290008c681816c9eb89ffbdb.tar.gz
overhaul internally-public declarations using wrapper headers
commits leading up to this one have moved the vast majority of libc-internal interface declarations to appropriate internal headers, allowing them to be type-checked and setting the stage to limit their visibility. the ones that have not yet been moved are mostly namespace-protected aliases for standard/public interfaces, which exist to facilitate implementing plain C functions in terms of POSIX functionality, or C or POSIX functionality in terms of extensions that are not standardized. some don't quite fit this description, but are "internally public" interfacs between subsystems of libc. rather than create a number of newly-named headers to declare these functions, and having to add explicit include directives for them to every source file where they're needed, I have introduced a method of wrapping the corresponding public headers. parallel to the public headers in $(srcdir)/include, we now have wrappers in $(srcdir)/src/include that come earlier in the include path order. they include the public header they're wrapping, then add declarations for namespace-protected versions of the same interfaces and any "internally public" interfaces for the subsystem they correspond to. along these lines, the wrapper for features.h is now responsible for the definition of the hidden, weak, and weak_alias macros. this means source files will no longer need to include any special headers to access these features. over time, it is my expectation that the scope of what is "internally public" will expand, reducing the number of source files which need to include *_impl.h and related headers down to those which are actually implementing the corresponding subsystems, not just using them.
Diffstat (limited to 'src/thread')
-rw-r--r--src/thread/__timedwait.c3
-rw-r--r--src/thread/call_once.c3
-rw-r--r--src/thread/cnd_broadcast.c2
-rw-r--r--src/thread/cnd_signal.c2
-rw-r--r--src/thread/cnd_timedwait.c2
-rw-r--r--src/thread/mtx_timedlock.c2
-rw-r--r--src/thread/mtx_trylock.c2
-rw-r--r--src/thread/mtx_unlock.c2
-rw-r--r--src/thread/pthread_cond_broadcast.c2
-rw-r--r--src/thread/pthread_cond_signal.c2
-rw-r--r--src/thread/pthread_cond_timedwait.c5
-rw-r--r--src/thread/pthread_create.c4
-rw-r--r--src/thread/pthread_detach.c2
-rw-r--r--src/thread/pthread_join.c4
-rw-r--r--src/thread/pthread_mutex_lock.c2
-rw-r--r--src/thread/pthread_mutex_timedlock.c2
-rw-r--r--src/thread/sem_open.c2
-rw-r--r--src/thread/thrd_create.c2
-rw-r--r--src/thread/thrd_exit.c5
-rw-r--r--src/thread/thrd_join.c3
-rw-r--r--src/thread/tss_create.c3
-rw-r--r--src/thread/tss_delete.c3
22 files changed, 6 insertions, 53 deletions
diff --git a/src/thread/__timedwait.c b/src/thread/__timedwait.c
index d2079c88..229db313 100644
--- a/src/thread/__timedwait.c
+++ b/src/thread/__timedwait.c
@@ -5,9 +5,6 @@
#include "syscall.h"
#include "pthread_impl.h"
-int __pthread_setcancelstate(int, int *);
-int __clock_gettime(clockid_t, struct timespec *);
-
int __timedwait_cp(volatile int *addr, int val,
clockid_t clk, const struct timespec *at, int priv)
{
diff --git a/src/thread/call_once.c b/src/thread/call_once.c
index a7bc9353..5ed30183 100644
--- a/src/thread/call_once.c
+++ b/src/thread/call_once.c
@@ -1,6 +1,5 @@
#include <threads.h>
-
-int __pthread_once(once_flag *, void (*)(void));
+#include <pthread.h>
void call_once(once_flag *flag, void (*func)(void))
{
diff --git a/src/thread/cnd_broadcast.c b/src/thread/cnd_broadcast.c
index 0ad061a3..e76b5a81 100644
--- a/src/thread/cnd_broadcast.c
+++ b/src/thread/cnd_broadcast.c
@@ -1,8 +1,6 @@
#include <threads.h>
#include <pthread.h>
-int __private_cond_signal(pthread_cond_t *, int);
-
int cnd_broadcast(cnd_t *c)
{
/* This internal function never fails, and always returns zero,
diff --git a/src/thread/cnd_signal.c b/src/thread/cnd_signal.c
index 8165dae1..02cdc6c6 100644
--- a/src/thread/cnd_signal.c
+++ b/src/thread/cnd_signal.c
@@ -1,8 +1,6 @@
#include <threads.h>
#include <pthread.h>
-int __private_cond_signal(pthread_cond_t *, int);
-
int cnd_signal(cnd_t *c)
{
/* This internal function never fails, and always returns zero,
diff --git a/src/thread/cnd_timedwait.c b/src/thread/cnd_timedwait.c
index 7bfe1045..2802af52 100644
--- a/src/thread/cnd_timedwait.c
+++ b/src/thread/cnd_timedwait.c
@@ -2,8 +2,6 @@
#include <pthread.h>
#include <errno.h>
-int __pthread_cond_timedwait(pthread_cond_t *restrict, pthread_mutex_t *restrict, const struct timespec *restrict);
-
int cnd_timedwait(cnd_t *restrict c, mtx_t *restrict m, const struct timespec *restrict ts)
{
int ret = __pthread_cond_timedwait((pthread_cond_t *)c, (pthread_mutex_t *)m, ts);
diff --git a/src/thread/mtx_timedlock.c b/src/thread/mtx_timedlock.c
index d098053b..d22c8cf4 100644
--- a/src/thread/mtx_timedlock.c
+++ b/src/thread/mtx_timedlock.c
@@ -2,8 +2,6 @@
#include <pthread.h>
#include <errno.h>
-int __pthread_mutex_timedlock(pthread_mutex_t *restrict, const struct timespec *restrict);
-
int mtx_timedlock(mtx_t *restrict m, const struct timespec *restrict ts)
{
int ret = __pthread_mutex_timedlock((pthread_mutex_t *)m, ts);
diff --git a/src/thread/mtx_trylock.c b/src/thread/mtx_trylock.c
index 8d1fb07c..40a8b8c2 100644
--- a/src/thread/mtx_trylock.c
+++ b/src/thread/mtx_trylock.c
@@ -1,8 +1,6 @@
#include "pthread_impl.h"
#include <threads.h>
-int __pthread_mutex_trylock(pthread_mutex_t *);
-
int mtx_trylock(mtx_t *m)
{
if (m->_m_type == PTHREAD_MUTEX_NORMAL)
diff --git a/src/thread/mtx_unlock.c b/src/thread/mtx_unlock.c
index ac91f993..2e5c8cf6 100644
--- a/src/thread/mtx_unlock.c
+++ b/src/thread/mtx_unlock.c
@@ -1,8 +1,6 @@
#include <threads.h>
#include <pthread.h>
-int __pthread_mutex_unlock(pthread_mutex_t *);
-
int mtx_unlock(mtx_t *mtx)
{
/* The only cases where pthread_mutex_unlock can return an
diff --git a/src/thread/pthread_cond_broadcast.c b/src/thread/pthread_cond_broadcast.c
index 69f840fb..6bfab78f 100644
--- a/src/thread/pthread_cond_broadcast.c
+++ b/src/thread/pthread_cond_broadcast.c
@@ -1,7 +1,5 @@
#include "pthread_impl.h"
-int __private_cond_signal(pthread_cond_t *, int);
-
int pthread_cond_broadcast(pthread_cond_t *c)
{
if (!c->_c_shared) return __private_cond_signal(c, -1);
diff --git a/src/thread/pthread_cond_signal.c b/src/thread/pthread_cond_signal.c
index 119c00ab..575ad54b 100644
--- a/src/thread/pthread_cond_signal.c
+++ b/src/thread/pthread_cond_signal.c
@@ -1,7 +1,5 @@
#include "pthread_impl.h"
-int __private_cond_signal(pthread_cond_t *, int);
-
int pthread_cond_signal(pthread_cond_t *c)
{
if (!c->_c_shared) return __private_cond_signal(c, 1);
diff --git a/src/thread/pthread_cond_timedwait.c b/src/thread/pthread_cond_timedwait.c
index ed8569c2..d1501240 100644
--- a/src/thread/pthread_cond_timedwait.c
+++ b/src/thread/pthread_cond_timedwait.c
@@ -1,10 +1,5 @@
#include "pthread_impl.h"
-void __pthread_testcancel(void);
-int __pthread_mutex_lock(pthread_mutex_t *);
-int __pthread_mutex_unlock(pthread_mutex_t *);
-int __pthread_setcancelstate(int, int *);
-
/*
* struct waiter
*
diff --git a/src/thread/pthread_create.c b/src/thread/pthread_create.c
index dc869dc1..23dfe0ad 100644
--- a/src/thread/pthread_create.c
+++ b/src/thread/pthread_create.c
@@ -6,10 +6,6 @@
#include <string.h>
#include <stddef.h>
-void *__mmap(void *, size_t, int, int, int, off_t);
-int __munmap(void *, size_t);
-int __mprotect(void *, size_t, int);
-
static void dummy_0()
{
}
diff --git a/src/thread/pthread_detach.c b/src/thread/pthread_detach.c
index 9cee7a89..16b0552d 100644
--- a/src/thread/pthread_detach.c
+++ b/src/thread/pthread_detach.c
@@ -1,8 +1,6 @@
#include "pthread_impl.h"
#include <threads.h>
-int __pthread_join(pthread_t, void **);
-
static int __pthread_detach(pthread_t t)
{
/* If the cas fails, detach state is either already-detached
diff --git a/src/thread/pthread_join.c b/src/thread/pthread_join.c
index 551c3675..54d81039 100644
--- a/src/thread/pthread_join.c
+++ b/src/thread/pthread_join.c
@@ -1,10 +1,6 @@
#include "pthread_impl.h"
#include <sys/mman.h>
-int __munmap(void *, size_t);
-void __pthread_testcancel(void);
-int __pthread_setcancelstate(int, int *);
-
static int __pthread_timedjoin_np(pthread_t t, void **res, const struct timespec *at)
{
int state, cs, r = 0;
diff --git a/src/thread/pthread_mutex_lock.c b/src/thread/pthread_mutex_lock.c
index d0c93cab..638d4b86 100644
--- a/src/thread/pthread_mutex_lock.c
+++ b/src/thread/pthread_mutex_lock.c
@@ -1,7 +1,5 @@
#include "pthread_impl.h"
-int __pthread_mutex_timedlock(pthread_mutex_t *restrict, const struct timespec *restrict);
-
int __pthread_mutex_lock(pthread_mutex_t *m)
{
if ((m->_m_type&15) == PTHREAD_MUTEX_NORMAL
diff --git a/src/thread/pthread_mutex_timedlock.c b/src/thread/pthread_mutex_timedlock.c
index d2bd1960..9867f389 100644
--- a/src/thread/pthread_mutex_timedlock.c
+++ b/src/thread/pthread_mutex_timedlock.c
@@ -1,7 +1,5 @@
#include "pthread_impl.h"
-int __pthread_mutex_trylock(pthread_mutex_t *);
-
int __pthread_mutex_timedlock(pthread_mutex_t *restrict m, const struct timespec *restrict at)
{
if ((m->_m_type&15) == PTHREAD_MUTEX_NORMAL
diff --git a/src/thread/sem_open.c b/src/thread/sem_open.c
index dc0279e8..1bd8020a 100644
--- a/src/thread/sem_open.c
+++ b/src/thread/sem_open.c
@@ -13,8 +13,6 @@
#include <pthread.h>
#include "libc.h"
-char *__shm_mapname(const char *, char *);
-
static struct {
ino_t ino;
sem_t *sem;
diff --git a/src/thread/thrd_create.c b/src/thread/thrd_create.c
index e0336695..76a683db 100644
--- a/src/thread/thrd_create.c
+++ b/src/thread/thrd_create.c
@@ -1,8 +1,6 @@
#include "pthread_impl.h"
#include <threads.h>
-int __pthread_create(pthread_t *restrict, const pthread_attr_t *restrict, void *(*)(void *), void *restrict);
-
int thrd_create(thrd_t *thr, thrd_start_t func, void *arg)
{
int ret = __pthread_create(thr, __ATTRP_C11_THREAD, (void *(*)(void *))func, arg);
diff --git a/src/thread/thrd_exit.c b/src/thread/thrd_exit.c
index b66bd996..9b291ae3 100644
--- a/src/thread/thrd_exit.c
+++ b/src/thread/thrd_exit.c
@@ -1,7 +1,6 @@
-#include "pthread_impl.h"
#include <threads.h>
-
-_Noreturn void __pthread_exit(void *);
+#include <pthread.h>
+#include <stdint.h>
_Noreturn void thrd_exit(int result)
{
diff --git a/src/thread/thrd_join.c b/src/thread/thrd_join.c
index ac667893..0d5fd302 100644
--- a/src/thread/thrd_join.c
+++ b/src/thread/thrd_join.c
@@ -1,7 +1,6 @@
#include <stdint.h>
#include <threads.h>
-
-int __pthread_join(thrd_t, void**);
+#include <pthread.h>
int thrd_join(thrd_t t, int *res)
{
diff --git a/src/thread/tss_create.c b/src/thread/tss_create.c
index 251d22b9..6d6ef96b 100644
--- a/src/thread/tss_create.c
+++ b/src/thread/tss_create.c
@@ -1,6 +1,5 @@
#include <threads.h>
-
-int __pthread_key_create(tss_t *, void (*)(void *));
+#include <pthread.h>
int tss_create(tss_t *tss, tss_dtor_t dtor)
{
diff --git a/src/thread/tss_delete.c b/src/thread/tss_delete.c
index 35db1032..6f51b07e 100644
--- a/src/thread/tss_delete.c
+++ b/src/thread/tss_delete.c
@@ -1,6 +1,5 @@
#include <threads.h>
-
-int __pthread_key_delete(tss_t k);
+#include <pthread.h>
void tss_delete(tss_t key)
{