summaryrefslogtreecommitdiffstats
path: root/lib/libc/include
diff options
context:
space:
mode:
authordeischen <deischen@FreeBSD.org>2002-11-13 18:12:09 +0000
committerdeischen <deischen@FreeBSD.org>2002-11-13 18:12:09 +0000
commitbf8788517dc3dbb62a46b61b9a2e31a4ba2d3dd4 (patch)
tree17bf495d45d13c8027b110379dd80aa876f77940 /lib/libc/include
parentf737ca00a463d77a4a5c24d8108a16f68b2a2f66 (diff)
downloadFreeBSD-src-bf8788517dc3dbb62a46b61b9a2e31a4ba2d3dd4.zip
FreeBSD-src-bf8788517dc3dbb62a46b61b9a2e31a4ba2d3dd4.tar.gz
Use a jump table (a la Solaris) for pthread routines with default
entries in the table being stubs. While I'm here, add macros to auto-generate the stubs. A conforming threads library can override the stub routines by filling in the jump table. Add some entries to namespace.h and sync un-namespace.h to it. Also add a comment to remind folks to update un-namespace.h when changing namespace.h.
Diffstat (limited to 'lib/libc/include')
-rw-r--r--lib/libc/include/libc_private.h42
-rw-r--r--lib/libc/include/namespace.h17
-rw-r--r--lib/libc/include/un-namespace.h25
3 files changed, 70 insertions, 14 deletions
diff --git a/lib/libc/include/libc_private.h b/lib/libc/include/libc_private.h
index e47e756..96ee8ad 100644
--- a/lib/libc/include/libc_private.h
+++ b/lib/libc/include/libc_private.h
@@ -64,6 +64,48 @@ extern int __isthreaded;
#define FUNLOCKFILE(fp) if (__isthreaded) _funlockfile(fp)
/*
+ * Indexes into the pthread jump table.
+ *
+ * Warning! If you change this type, you must also change the threads
+ * libraries that reference it (libc_r, libpthread).
+ */
+typedef enum {
+ PJT_COND_BROADCAST,
+ PJT_COND_DESTROY,
+ PJT_COND_INIT,
+ PJT_COND_SIGNAL,
+ PJT_COND_WAIT,
+ PJT_GETSPECIFIC,
+ PJT_KEY_CREATE,
+ PJT_KEY_DELETE,
+ PJT_MAIN_NP,
+ PJT_MUTEX_DESTROY,
+ PJT_MUTEX_INIT,
+ PJT_MUTEX_LOCK,
+ PJT_MUTEX_TRYLOCK,
+ PJT_MUTEX_UNLOCK,
+ PJT_MUTEXATTR_DESTROY,
+ PJT_MUTEXATTR_INIT,
+ PJT_MUTEXATTR_SETTYPE,
+ PJT_ONCE,
+ PJT_RWLOCK_DESTROY,
+ PJT_RWLOCK_INIT,
+ PJT_RWLOCK_RDLOCK,
+ PJT_RWLOCK_TRYRDLOCK,
+ PJT_RWLOCK_TRYWRLOCK,
+ PJT_RWLOCK_UNLOCK,
+ PJT_RWLOCK_WRLOCK,
+ PJT_SELF,
+ PJT_SETSPECIFIC,
+ PJT_SIGMASK,
+ PJT_MAX
+} pjt_index_t;
+
+typedef int (*pthread_func_t)();
+
+extern pthread_func_t __thr_jtable[][];
+
+/*
* This is a pointer in the C run-time startup code. It is used
* by getprogname() and setprogname().
*/
diff --git a/lib/libc/include/namespace.h b/lib/libc/include/namespace.h
index bfe49e2..00c034e 100644
--- a/lib/libc/include/namespace.h
+++ b/lib/libc/include/namespace.h
@@ -31,6 +31,9 @@
/*
* Adjust names so that headers declare "hidden" names.
+ *
+ * README: When modifying this file don't forget to make the appropriate
+ * changes in un-namespace.h!!!
*/
/*
@@ -76,10 +79,12 @@
#define nanosleep _nanosleep
#define open _open
#define poll _poll
-#define pthread_cond_signal _pthread_cond_signal
#define pthread_cond_broadcast _pthread_cond_broadcast
-#define pthread_cond_wait _pthread_cond_wait
+#define pthread_cond_destroy _pthread_cond_destroy
#define pthread_cond_init _pthread_cond_init
+#define pthread_cond_signal _pthread_cond_signal
+#define pthread_cond_timedwait _pthread_cond_timedwait
+#define pthread_cond_wait _pthread_cond_wait
#define pthread_exit _pthread_exit
#define pthread_getspecific _pthread_getspecific
#define pthread_key_create _pthread_key_create
@@ -90,13 +95,16 @@
#define pthread_mutex_lock _pthread_mutex_lock
#define pthread_mutex_trylock _pthread_mutex_trylock
#define pthread_mutex_unlock _pthread_mutex_unlock
-#define pthread_mutexattr_init _pthread_mutexattr_init
#define pthread_mutexattr_destroy _pthread_mutexattr_destroy
+#define pthread_mutexattr_init _pthread_mutexattr_init
#define pthread_mutexattr_settype _pthread_mutexattr_settype
#define pthread_once _pthread_once
+#define pthread_rwlock_destroy _pthread_rwlock_destroy
#define pthread_rwlock_init _pthread_rwlock_init
#define pthread_rwlock_rdlock _pthread_rwlock_rdlock
#define pthread_rwlock_wrlock _pthread_rwlock_wrlock
+#define pthread_rwlock_tryrdlock _pthread_rwlock_tryrdlock
+#define pthread_rwlock_trywrlock _pthread_rwlock_trywrlock
#define pthread_rwlock_unlock _pthread_rwlock_unlock
#define pthread_self _pthread_self
#define pthread_setspecific _pthread_setspecific
@@ -135,9 +143,6 @@
#define msync _msync
#define nfssvc _nfssvc
#define pause _pause
-#define pthread_rwlock_destroy _pthread_rwlock_destroy
-#define pthread_rwlock_tryrdlock _pthread_rwlock_tryrdlock
-#define pthread_rwlock_trywrlock _pthread_rwlock_trywrlock
#define pthread_rwlockattr_init _pthread_rwlockattr_init
#define pthread_rwlockattr_destroy _pthread_rwlockattr_destroy
#define sched_yield _sched_yield
diff --git a/lib/libc/include/un-namespace.h b/lib/libc/include/un-namespace.h
index 3b21900..2809e0d 100644
--- a/lib/libc/include/un-namespace.h
+++ b/lib/libc/include/un-namespace.h
@@ -60,9 +60,18 @@
#undef listen
#undef nanosleep
#undef open
+#undef poll
+#undef pthread_cond_broadcast
+#undef pthread_cond_destroy
+#undef pthread_cond_init
+#undef pthread_cond_signal
+#undef pthread_cond_timedwait
+#undef pthread_cond_wait
+#undef pthread_exit
#undef pthread_getspecific
#undef pthread_key_create
#undef pthread_key_delete
+#undef pthread_main_np
#undef pthread_mutex_destroy
#undef pthread_mutex_init
#undef pthread_mutex_lock
@@ -72,8 +81,16 @@
#undef pthread_mutexattr_destroy
#undef pthread_mutexattr_settype
#undef pthread_once
+#undef pthread_rwlock_destroy
+#undef pthread_rwlock_init
+#undef pthread_rwlock_rdlock
+#undef pthread_rwlock_wrlock
+#undef pthread_rwlock_tryrdlock
+#undef pthread_rwlock_trywrlock
+#undef pthread_rwlock_unlock
#undef pthread_self
#undef pthread_setspecific
+#undef pthread_sigmask
#undef read
#undef readv
#undef recvfrom
@@ -100,14 +117,6 @@
#undef msync
#undef nfssvc
#undef pause
-#undef poll
-#undef pthread_rwlock_destroy
-#undef pthread_rwlock_init
-#undef pthread_rwlock_rdlock
-#undef pthread_rwlock_tryrdlock
-#undef pthread_rwlock_trywrlock
-#undef pthread_rwlock_unlock
-#undef pthread_rwlock_wrlock
#undef pthread_rwlockattr_init
#undef pthread_rwlockattr_destroy
#undef sched_yield
OpenPOWER on IntegriCloud