From ea6390b2f20a03b7d504bc68a1c95e645d271149 Mon Sep 17 00:00:00 2001 From: Pino Toscano Date: Wed, 2 Nov 2011 17:38:46 +0100 Subject: Remove all the values when deleting a key When deleting a key using `pthread_key_delete', delete all the values associated to that key in all the threads available. Otherwise, the key reuse in `pthread_key_create' can cause new keys to have thread specific data of the previously used key with the same index. Add a test for this case, which creates and deletes pairs of keys checking that they have a NULL thread specific data after creation. * sysdeps/hurd/pt-key-delete.c (pthread_key_delete): Remove all the values of the key in all the threads. * tests/Makefile (CHECK_SRC): Add test-17.c. * tests/test-17.c: New file. --- sysdeps/hurd/pt-key-delete.c | 19 +++++++++++++++ tests/Makefile | 2 +- tests/test-17.c | 57 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 77 insertions(+), 1 deletion(-) create mode 100644 tests/test-17.c diff --git a/sysdeps/hurd/pt-key-delete.c b/sysdeps/hurd/pt-key-delete.c index 2426bb1..9d88647 100644 --- a/sysdeps/hurd/pt-key-delete.c +++ b/sysdeps/hurd/pt-key-delete.c @@ -35,8 +35,27 @@ pthread_key_delete (pthread_key_t key) err = EINVAL; else { + int i; + __pthread_key_destructors[key] = PTHREAD_KEY_INVALID; __pthread_key_invalid_count ++; + + pthread_rwlock_rdlock (&__pthread_threads_lock); + for (i = 0; i < __pthread_num_threads; ++i) + { + struct __pthread *t; + + t = __pthread_threads[i]; + + if (t == NULL) + continue; + + /* Just remove the key, no need to care whether it was + already there. */ + if (t->thread_specifics) + hurd_ihash_remove (t->thread_specifics, key); + } + pthread_rwlock_unlock (&__pthread_threads_lock); } __pthread_mutex_unlock (&__pthread_key_lock); diff --git a/tests/Makefile b/tests/Makefile index 9509c95..4e2a4a8 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -4,7 +4,7 @@ LDLIBS = -lpthread CHECK_SRC := test-1.c test-2.c test-3.c test-6.c test-7.c test-8.c \ test-9.c test-10.c test-11.c test-12.c test-13.c test-14.c \ - test-15.c test-16.c + test-15.c test-16.c test-17.c CHECK_OBJS := $(addsuffix .o,$(basename $(notdir $(CHECK_SRC)))) CHECK_PROGS := $(basename $(notdir $(CHECK_SRC))) \ diff --git a/tests/test-17.c b/tests/test-17.c new file mode 100644 index 0000000..a8bd150 --- /dev/null +++ b/tests/test-17.c @@ -0,0 +1,57 @@ +/* Test that the key reuse inside libpthread does not cause thread + specific values to persist. */ + +#define _GNU_SOURCE 1 + +#include +#include +#include +#include + +void +work (int iter) +{ + error_t err; + pthread_key_t key1; + pthread_key_t key2; + void *value1; + void *value2; + + printf ("work/%d: start\n", iter); + err = pthread_key_create (&key1, NULL); + assert (err == 0); + err = pthread_key_create (&key2, NULL); + assert (err == 0); + + value1 = pthread_getspecific (key1); + value2 = pthread_getspecific (key2); + printf ("work/%d: pre-setspecific: %p,%p\n", iter, value1, value2); + assert (value1 == NULL); + assert (value2 == NULL); + err = pthread_setspecific (key1, (void *)(0x100 + iter)); + assert (err == 0); + err = pthread_setspecific (key2, (void *)(0x200 + iter)); + assert (err == 0); + + value1 = pthread_getspecific (key1); + value2 = pthread_getspecific (key2); + printf ("work/%d: post-setspecific: %p,%p\n", iter, value1, value2); + assert (value1 == (void *)(0x100 + iter)); + assert (value2 == (void *)(0x200 + iter)); + + err = pthread_key_delete (key1); + assert (err == 0); + err = pthread_key_delete (key2); + assert (err == 0); +} + +int +main (int argc, char *argv[]) +{ + int i; + + for (i = 0; i < 8; ++i) + work (i + 1); + + return 0; +} -- cgit v1.2.3 From 76af844177c2bacd7a39e865cf0bbe484a68ddb8 Mon Sep 17 00:00:00 2001 From: Thomas Schwinge Date: Sat, 5 Nov 2011 01:16:41 +0100 Subject: Correct logic for PTHREAD_KEY_INVALID slots. * sysdeps/hurd/pt-destroy-specific.c (__pthread_destroy_specific): Correct logic for PTHREAD_KEY_INVALID slots. * tests/test-__pthread_destroy_specific-skip.c: New file. * tests/Makefile (CHECK_SRC): Add test-__pthread_destroy_specific-skip.c. --- sysdeps/hurd/pt-destroy-specific.c | 2 +- tests/Makefile | 2 +- tests/test-__pthread_destroy_specific-skip.c | 83 ++++++++++++++++++++++++++++ 3 files changed, 85 insertions(+), 2 deletions(-) create mode 100644 tests/test-__pthread_destroy_specific-skip.c diff --git a/sysdeps/hurd/pt-destroy-specific.c b/sysdeps/hurd/pt-destroy-specific.c index 23c7fbc..f7896e5 100644 --- a/sysdeps/hurd/pt-destroy-specific.c +++ b/sysdeps/hurd/pt-destroy-specific.c @@ -48,7 +48,7 @@ __pthread_destroy_specific (struct __pthread *thread) void *value; if (__pthread_key_destructors[i] == PTHREAD_KEY_INVALID) - break; + continue; value = hurd_ihash_find (thread->thread_specifics, i); if (value) diff --git a/tests/Makefile b/tests/Makefile index 9509c95..343a644 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -4,7 +4,7 @@ LDLIBS = -lpthread CHECK_SRC := test-1.c test-2.c test-3.c test-6.c test-7.c test-8.c \ test-9.c test-10.c test-11.c test-12.c test-13.c test-14.c \ - test-15.c test-16.c + test-15.c test-16.c test-__pthread_destroy_specific-skip.c CHECK_OBJS := $(addsuffix .o,$(basename $(notdir $(CHECK_SRC)))) CHECK_PROGS := $(basename $(notdir $(CHECK_SRC))) \ diff --git a/tests/test-__pthread_destroy_specific-skip.c b/tests/test-__pthread_destroy_specific-skip.c new file mode 100644 index 0000000..b2c4c0b --- /dev/null +++ b/tests/test-__pthread_destroy_specific-skip.c @@ -0,0 +1,83 @@ +/* Check that __pthread_destroy_specific works correctly if it has to skip + unused slots. */ + +#define _GNU_SOURCE + +#include +#include +#include + + +#define N_k 42 + +static volatile int v; + +static void +d (void *x) +{ + int *i = (int *) x; + + if (v != *i) + error (1, 0, "FAILED %d %d", v, *i); + v += 2; + + printf ("%s %d\n", __FUNCTION__, *i); + fflush (stdout); +} + +static void * +test (void *x) +{ + pthread_key_t k[N_k]; + static int k_v[N_k]; + + int err, i; + + for (i = 0; i < N_k; i += 1) + { + err = pthread_key_create (&k[i], &d); + if (err != 0) + error (1, err, "pthread_key_create %d", i); + } + + for (i = 0; i < N_k; i += 1) + { + k_v[i] = i; + err = pthread_setspecific (k[i], &k_v[i]); + if (err != 0) + error (1, err, "pthread_setspecific %d", i); + } + + /* Delete every even key. */ + for (i = 0; i < N_k; i += 2) + { + err = pthread_key_delete (k[i]); + if (err != 0) + error (1, err, "pthread_key_delete %d", i); + } + + v = 1; + pthread_exit (NULL); + + return NULL; +} + + +int main(void) +{ + pthread_t tid; + int err; + + err = pthread_create (&tid, 0, test, NULL); + if (err != 0) + error (1, err, "pthread_create"); + + err = pthread_join(tid, NULL); + if (err) + error (1, err, "pthread_join"); + + if (v != N_k + 1) + error (1, 0, "FAILED END %d %d", v, N_k + 1); + + return 0; +} -- cgit v1.2.3 From 56e25a91e9e25eba8da099efa89c3c487c3490cf Mon Sep 17 00:00:00 2001 From: Pino Toscano Date: Sun, 6 Nov 2011 12:39:04 +0100 Subject: pthread_getspecific, pthread_setspecific: check the key validity When getting a TSD, handle gracefully the case of an invalid key. When setting a TSD, check for the validity of the key as recommended (although not required) by POSIX. This also avoids potentially filling the `thread_specifics' hash of threads with TSD of invalid keys. Add two simple checks in test-7.c for the two situations above. * sysdeps/hurd/pt-getspecific.c (pthread_getspecific): Check the validity of the specified key. * sysdeps/hurd/pt-setspecific.c (pthread_setspecific): Likewise. * tests/test-7.c (main): Add two assertions. --- sysdeps/hurd/pt-getspecific.c | 4 +++- sysdeps/hurd/pt-setspecific.c | 4 ++++ tests/test-7.c | 3 +++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/sysdeps/hurd/pt-getspecific.c b/sysdeps/hurd/pt-getspecific.c index 3060598..71ec63c 100644 --- a/sysdeps/hurd/pt-getspecific.c +++ b/sysdeps/hurd/pt-getspecific.c @@ -27,7 +27,9 @@ pthread_getspecific (pthread_key_t key) { struct __pthread *self; - assert (key < __pthread_key_count); + if (key < 0 || key >= __pthread_key_count + || __pthread_key_destructors[key] == PTHREAD_KEY_INVALID) + return NULL; self = _pthread_self (); if (! self->thread_specifics) diff --git a/sysdeps/hurd/pt-setspecific.c b/sysdeps/hurd/pt-setspecific.c index 89ca4d7..d0b7302 100644 --- a/sysdeps/hurd/pt-setspecific.c +++ b/sysdeps/hurd/pt-setspecific.c @@ -28,6 +28,10 @@ pthread_setspecific (pthread_key_t key, const void *value) error_t err; struct __pthread *self = _pthread_self (); + if (key < 0 || key >= __pthread_key_count + || __pthread_key_destructors[key] == PTHREAD_KEY_INVALID) + return EINVAL; + if (! self->thread_specifics) { err = hurd_ihash_create (&self->thread_specifics, HURD_IHASH_NO_LOCP); diff --git a/tests/test-7.c b/tests/test-7.c index 8159be3..22fb1ca 100644 --- a/tests/test-7.c +++ b/tests/test-7.c @@ -42,6 +42,9 @@ main (int argc, char **argv) assert ((pthread_t) val == pthread_self ()); } + assert (pthread_getspecific ((pthread_key_t) 0) == NULL); + assert (pthread_setspecific ((pthread_key_t) 0, (void *) 0x1) == EINVAL); + for (i = 0; i < KEYS; i ++) err = pthread_key_create (&key[i], des); -- cgit v1.2.3 From 1d5bf69f1abd4bb556688b5af9ec2973fd5b3943 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Mon, 7 Nov 2011 12:38:46 +0100 Subject: Add XOpen 2008 visibility * include/pthread/pthread.h [__USE_XOPEN2K8] (PTHREAD_MUTEX_NORMAL, PTHREAD_MUTEX_ERRORCHECK, PTHREAD_MUTEX_RECURSIVE, PTHREAD_MUTEX_DEFAULT, pthread_mutexattr_gettype, pthread_mutexattr_settype): Expose. --- include/pthread/pthread.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/pthread/pthread.h b/include/pthread/pthread.h index 4dbcb0c..cd32fb2 100644 --- a/include/pthread/pthread.h +++ b/include/pthread/pthread.h @@ -240,7 +240,7 @@ extern pthread_t pthread_self (void); #define PTHREAD_MUTEX_TIMED_NP __PTHREAD_MUTEX_TIMED #define PTHREAD_MUTEX_ERRORCHECK_NP __PTHREAD_MUTEX_ERRORCHECK #define PTHREAD_MUTEX_RECURSIVE_NP __PTHREAD_MUTEX_RECURSIVE -#ifdef __USE_UNIX98 +#if defined __USE_UNIX98 || defined __USE_XOPEN2K8 #define PTHREAD_MUTEX_NORMAL PTHREAD_MUTEX_TIMED_NP #define PTHREAD_MUTEX_ERRORCHECK PTHREAD_MUTEX_ERRORCHECK_NP #define PTHREAD_MUTEX_RECURSIVE PTHREAD_MUTEX_RECURSIVE_NP @@ -295,7 +295,7 @@ extern int pthread_mutexattr_setpshared(pthread_mutexattr_t *attr, int pshared); -#ifdef __USE_UNIX98 +#if defined __USE_UNIX98 || defined __USE_XOPEN2K8 /* Return the value of the type attribute in *ATTR in *TYPE. */ extern int pthread_mutexattr_gettype(const pthread_mutexattr_t *__restrict attr, int *__restrict type); -- cgit v1.2.3 From db7bf9590dc08a72de9a9c46db7937188156fa2e Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Sun, 27 Nov 2011 18:39:25 +0100 Subject: Fix __mutex_unlock_solid safety libc releases the spinlock before calling __mutex_unlock_solid, so we have to try to reacquire it before possibly giving it to some blocked thread. * pthread/cthreads-compat.c (__mutex_unlock_solid): Call __pthread_spin_trylock before calling __pthread_mutex_unlock. --- pthread/cthreads-compat.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pthread/cthreads-compat.c b/pthread/cthreads-compat.c index e0536ef..cbe8170 100644 --- a/pthread/cthreads-compat.c +++ b/pthread/cthreads-compat.c @@ -100,5 +100,8 @@ __mutex_lock_solid (void *lock) void __mutex_unlock_solid (void *lock) { + if (__pthread_spin_trylock (lock) != 0) + /* Somebody already got the lock, that one will manage waking up others */ + return; __pthread_mutex_unlock (lock); } -- cgit v1.2.3 From 51feb14bff6b4aa70e2f13a54e26a6b270de3e4d Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Sat, 21 Apr 2012 22:07:49 +0000 Subject: Rename pthread functions to be used for forwarding Libc will need to be able to call them, so they need to have a different name. * pthread/pt-exit.c (pthread_exit): Rename with __ prefix and add strong alias. * pthread/pt-self.c (pthread_self): Likewise. * pthread/pt-setcancelstate.c (pthread_setcancelstate): Likewise * pthread/pt-setcanceltype.c (pthread_setcanceltype): Likewise * sysdeps/generic/pt-attr-destroy.c (pthread_attr_destroy): Likewise * sysdeps/generic/pt-attr-getdetachstate.c (pthread_attr_getdetachstate): Likewise * sysdeps/generic/pt-attr-getinheritsched.c (pthread_attr_getinheritsched): Likewise * sysdeps/generic/pt-attr-getschedparam.c (pthread_attr_getschedparam): Likewise * sysdeps/generic/pt-attr-getschedpolicy.c (pthread_attr_getschedpolicy): Likewise * sysdeps/generic/pt-attr-getscope.c (pthread_attr_getscope): Likewise * sysdeps/generic/pt-attr-init.c (pthread_attr_init): Likewise * sysdeps/generic/pt-attr-setdetachstate.c (pthread_attr_setdetachstate): Likewise * sysdeps/generic/pt-attr-setinheritsched.c (pthread_attr_setinheritsched): Likewise * sysdeps/generic/pt-attr-setschedparam.c (pthread_attr_setschedparam): Likewise * sysdeps/generic/pt-attr-setschedpolicy.c (pthread_attr_setschedpolicy): Likewise * sysdeps/generic/pt-attr-setscope.c (pthread_attr_setscope): Likewise * sysdeps/generic/pt-cond-brdcast.c (pthread_cond_broadcast): Likewise * sysdeps/generic/pt-cond-destroy.c (pthread_cond_destroy): Likewise * sysdeps/generic/pt-cond-init.c (pthread_cond_init): Likewise * sysdeps/generic/pt-cond-signal.c (pthread_cond_signal): Likewise * sysdeps/generic/pt-cond-timedwait.c (pthread_cond_timedwait): Likewise * sysdeps/generic/pt-cond-wait.c (pthread_cond_wait): Likewise * sysdeps/generic/pt-condattr-destroy.c (pthread_condattr_destroy): Likewise * sysdeps/generic/pt-condattr-init.c (pthread_condattr_init): Likewise * sysdeps/generic/pt-equal.c (pthread_equal): Likewise * sysdeps/generic/pt-getschedparam.c (pthread_getschedparam): Likewise * sysdeps/generic/pt-setschedparam.c (pthread_setschedparam): Likewise --- pthread/pt-exit.c | 4 +++- pthread/pt-self.c | 4 +++- pthread/pt-setcancelstate.c | 4 +++- pthread/pt-setcanceltype.c | 4 +++- sysdeps/generic/pt-attr-destroy.c | 3 ++- sysdeps/generic/pt-attr-getdetachstate.c | 4 +++- sysdeps/generic/pt-attr-getinheritsched.c | 4 +++- sysdeps/generic/pt-attr-getschedparam.c | 4 +++- sysdeps/generic/pt-attr-getschedpolicy.c | 4 +++- sysdeps/generic/pt-attr-getscope.c | 4 +++- sysdeps/generic/pt-attr-init.c | 3 ++- sysdeps/generic/pt-attr-setdetachstate.c | 4 +++- sysdeps/generic/pt-attr-setinheritsched.c | 4 +++- sysdeps/generic/pt-attr-setschedparam.c | 4 +++- sysdeps/generic/pt-attr-setschedpolicy.c | 4 +++- sysdeps/generic/pt-attr-setscope.c | 4 +++- sysdeps/generic/pt-cond-brdcast.c | 4 +++- sysdeps/generic/pt-cond-destroy.c | 4 +++- sysdeps/generic/pt-cond-init.c | 4 +++- sysdeps/generic/pt-cond-signal.c | 4 +++- sysdeps/generic/pt-cond-timedwait.c | 4 +++- sysdeps/generic/pt-cond-wait.c | 4 +++- sysdeps/generic/pt-condattr-destroy.c | 4 +++- sysdeps/generic/pt-condattr-init.c | 4 +++- sysdeps/generic/pt-equal.c | 4 +++- sysdeps/generic/pt-getschedparam.c | 4 +++- sysdeps/generic/pt-setschedparam.c | 4 +++- 27 files changed, 79 insertions(+), 27 deletions(-) diff --git a/pthread/pt-exit.c b/pthread/pt-exit.c index c01efda..53a0427 100644 --- a/pthread/pt-exit.c +++ b/pthread/pt-exit.c @@ -30,7 +30,7 @@ /* Terminate the current thread and make STATUS available to any thread that might join it. */ void -pthread_exit (void *status) +__pthread_exit (void *status) { struct __pthread *self = _pthread_self (); struct __pthread_cancelation_handler **handlers; @@ -120,3 +120,5 @@ pthread_exit (void *status) /* NOTREACHED */ abort (); } + +strong_alias (__pthread_exit, pthread_exit); diff --git a/pthread/pt-self.c b/pthread/pt-self.c index 4976864..deb57c0 100644 --- a/pthread/pt-self.c +++ b/pthread/pt-self.c @@ -23,10 +23,12 @@ /* Return the thread ID of the calling thread. */ pthread_t -pthread_self (void) +__pthread_self (void) { struct __pthread *self = _pthread_self (); assert (self); return self->thread; } + +strong_alias (__pthread_self, pthread_self); diff --git a/pthread/pt-setcancelstate.c b/pthread/pt-setcancelstate.c index e2d8183..38550ee 100644 --- a/pthread/pt-setcancelstate.c +++ b/pthread/pt-setcancelstate.c @@ -22,7 +22,7 @@ #include int -pthread_setcancelstate (int state, int *oldstate) +__pthread_setcancelstate (int state, int *oldstate) { struct __pthread *p = _pthread_self (); @@ -41,3 +41,5 @@ pthread_setcancelstate (int state, int *oldstate) return 0; } + +strong_alias (__pthread_setcancelstate, pthread_setcancelstate); diff --git a/pthread/pt-setcanceltype.c b/pthread/pt-setcanceltype.c index 3ce4259..7226a3a 100644 --- a/pthread/pt-setcanceltype.c +++ b/pthread/pt-setcanceltype.c @@ -22,7 +22,7 @@ #include int -pthread_setcanceltype (int type, int *oldtype) +__pthread_setcanceltype (int type, int *oldtype) { struct __pthread *p = _pthread_self (); @@ -41,3 +41,5 @@ pthread_setcanceltype (int type, int *oldtype) return 0; } + +strong_alias (__pthread_setcanceltype, pthread_setcanceltype); diff --git a/sysdeps/generic/pt-attr-destroy.c b/sysdeps/generic/pt-attr-destroy.c index c4b9aa5..b9bd374 100644 --- a/sysdeps/generic/pt-attr-destroy.c +++ b/sysdeps/generic/pt-attr-destroy.c @@ -21,7 +21,8 @@ #include int -pthread_attr_destroy (pthread_attr_t *attr) +__pthread_attr_destroy (pthread_attr_t *attr) { return 0; } +strong_alias (__pthread_attr_destroy, pthread_attr_destroy); diff --git a/sysdeps/generic/pt-attr-getdetachstate.c b/sysdeps/generic/pt-attr-getdetachstate.c index be406f1..b50f913 100644 --- a/sysdeps/generic/pt-attr-getdetachstate.c +++ b/sysdeps/generic/pt-attr-getdetachstate.c @@ -21,9 +21,11 @@ #include int -pthread_attr_getdetachstate (const pthread_attr_t *attr, +__pthread_attr_getdetachstate (const pthread_attr_t *attr, int *detachstate) { *detachstate = attr->detachstate; return 0; } + +strong_alias (__pthread_attr_getdetachstate, pthread_attr_getdetachstate); diff --git a/sysdeps/generic/pt-attr-getinheritsched.c b/sysdeps/generic/pt-attr-getinheritsched.c index cca4e3d..7f1f601 100644 --- a/sysdeps/generic/pt-attr-getinheritsched.c +++ b/sysdeps/generic/pt-attr-getinheritsched.c @@ -21,9 +21,11 @@ #include int -pthread_attr_getinheritsched (const pthread_attr_t *attr, +__pthread_attr_getinheritsched (const pthread_attr_t *attr, int *inheritsched) { *inheritsched = attr->inheritsched; return 0; } + +strong_alias (__pthread_attr_getinheritsched, pthread_attr_getinheritsched); diff --git a/sysdeps/generic/pt-attr-getschedparam.c b/sysdeps/generic/pt-attr-getschedparam.c index 190cf9d..4519b69 100644 --- a/sysdeps/generic/pt-attr-getschedparam.c +++ b/sysdeps/generic/pt-attr-getschedparam.c @@ -24,9 +24,11 @@ #include int -pthread_attr_getschedparam (const pthread_attr_t *attr, +__pthread_attr_getschedparam (const pthread_attr_t *attr, struct sched_param *param) { memcpy (param, &attr->schedparam, sizeof *param); return 0; } + +strong_alias (__pthread_attr_getschedparam, pthread_attr_getschedparam); diff --git a/sysdeps/generic/pt-attr-getschedpolicy.c b/sysdeps/generic/pt-attr-getschedpolicy.c index 4349a23..0980bdd 100644 --- a/sysdeps/generic/pt-attr-getschedpolicy.c +++ b/sysdeps/generic/pt-attr-getschedpolicy.c @@ -21,9 +21,11 @@ #include int -pthread_attr_getschedpolicy (const pthread_attr_t *attr, +__pthread_attr_getschedpolicy (const pthread_attr_t *attr, int *policy) { *policy = attr->schedpolicy; return 0; } + +strong_alias (__pthread_attr_getschedpolicy, pthread_attr_getschedpolicy); diff --git a/sysdeps/generic/pt-attr-getscope.c b/sysdeps/generic/pt-attr-getscope.c index 97198fa..46eb604 100644 --- a/sysdeps/generic/pt-attr-getscope.c +++ b/sysdeps/generic/pt-attr-getscope.c @@ -21,9 +21,11 @@ #include int -pthread_attr_getscope (const pthread_attr_t *attr, +__pthread_attr_getscope (const pthread_attr_t *attr, int *contentionscope) { *contentionscope = attr->contentionscope; return 0; } + +strong_alias (__pthread_attr_getscope, pthread_attr_getscope); diff --git a/sysdeps/generic/pt-attr-init.c b/sysdeps/generic/pt-attr-init.c index 6a930e3..f9eb361 100644 --- a/sysdeps/generic/pt-attr-init.c +++ b/sysdeps/generic/pt-attr-init.c @@ -21,8 +21,9 @@ #include int -pthread_attr_init (pthread_attr_t *attr) +__pthread_attr_init (pthread_attr_t *attr) { *attr = __pthread_default_attr; return 0; } +strong_alias (__pthread_attr_init, pthread_attr_init); diff --git a/sysdeps/generic/pt-attr-setdetachstate.c b/sysdeps/generic/pt-attr-setdetachstate.c index 688ba5d..abd6bbb 100644 --- a/sysdeps/generic/pt-attr-setdetachstate.c +++ b/sysdeps/generic/pt-attr-setdetachstate.c @@ -21,7 +21,7 @@ #include int -pthread_attr_setdetachstate (pthread_attr_t *attr, +__pthread_attr_setdetachstate (pthread_attr_t *attr, int detachstate) { switch (detachstate) @@ -36,3 +36,5 @@ pthread_attr_setdetachstate (pthread_attr_t *attr, return 0; } + +strong_alias (__pthread_attr_setdetachstate, pthread_attr_setdetachstate); diff --git a/sysdeps/generic/pt-attr-setinheritsched.c b/sysdeps/generic/pt-attr-setinheritsched.c index e9012c5..9fdbd4e 100644 --- a/sysdeps/generic/pt-attr-setinheritsched.c +++ b/sysdeps/generic/pt-attr-setinheritsched.c @@ -21,7 +21,7 @@ #include int -pthread_attr_setinheritsched (pthread_attr_t *attr, +__pthread_attr_setinheritsched (pthread_attr_t *attr, int inheritsched) { switch (inheritsched) @@ -36,3 +36,5 @@ pthread_attr_setinheritsched (pthread_attr_t *attr, return 0; } + +strong_alias (__pthread_attr_setinheritsched, pthread_attr_setinheritsched); diff --git a/sysdeps/generic/pt-attr-setschedparam.c b/sysdeps/generic/pt-attr-setschedparam.c index 5459f10..2fd1d3a 100644 --- a/sysdeps/generic/pt-attr-setschedparam.c +++ b/sysdeps/generic/pt-attr-setschedparam.c @@ -24,7 +24,7 @@ #include int -pthread_attr_setschedparam (pthread_attr_t *attr, +__pthread_attr_setschedparam (pthread_attr_t *attr, const struct sched_param *param) { if (memcmp (param, &__pthread_default_attr.schedparam, @@ -36,3 +36,5 @@ pthread_attr_setschedparam (pthread_attr_t *attr, return ENOTSUP; } + +strong_alias (__pthread_attr_setschedparam, pthread_attr_setschedparam); diff --git a/sysdeps/generic/pt-attr-setschedpolicy.c b/sysdeps/generic/pt-attr-setschedpolicy.c index e481d04..04e93c9 100644 --- a/sysdeps/generic/pt-attr-setschedpolicy.c +++ b/sysdeps/generic/pt-attr-setschedpolicy.c @@ -21,7 +21,7 @@ #include int -pthread_attr_setschedpolicy (pthread_attr_t *attr, +__pthread_attr_setschedpolicy (pthread_attr_t *attr, int policy) { switch (policy) @@ -40,3 +40,5 @@ pthread_attr_setschedpolicy (pthread_attr_t *attr, return 0; } + +strong_alias (__pthread_attr_setschedpolicy, pthread_attr_setschedpolicy); diff --git a/sysdeps/generic/pt-attr-setscope.c b/sysdeps/generic/pt-attr-setscope.c index c74a4f6..d86d7b5 100644 --- a/sysdeps/generic/pt-attr-setscope.c +++ b/sysdeps/generic/pt-attr-setscope.c @@ -21,7 +21,7 @@ #include int -pthread_attr_setscope (pthread_attr_t *attr, +__pthread_attr_setscope (pthread_attr_t *attr, int contentionscope) { if (contentionscope == __pthread_default_attr.contentionscope) @@ -39,3 +39,5 @@ pthread_attr_setscope (pthread_attr_t *attr, return EINVAL; } } + +strong_alias (__pthread_attr_setscope, pthread_attr_setscope); diff --git a/sysdeps/generic/pt-cond-brdcast.c b/sysdeps/generic/pt-cond-brdcast.c index 3f55e33..999cc2d 100644 --- a/sysdeps/generic/pt-cond-brdcast.c +++ b/sysdeps/generic/pt-cond-brdcast.c @@ -23,7 +23,7 @@ /* Unblock all threads that are blocked on condition variable COND. */ int -pthread_cond_broadcast (pthread_cond_t *cond) +__pthread_cond_broadcast (pthread_cond_t *cond) { struct __pthread *wakeup; @@ -40,3 +40,5 @@ pthread_cond_broadcast (pthread_cond_t *cond) return 0; } + +strong_alias (__pthread_cond_broadcast, pthread_cond_broadcast); diff --git a/sysdeps/generic/pt-cond-destroy.c b/sysdeps/generic/pt-cond-destroy.c index eba4778..d72ea75 100644 --- a/sysdeps/generic/pt-cond-destroy.c +++ b/sysdeps/generic/pt-cond-destroy.c @@ -21,7 +21,9 @@ #include int -pthread_cond_destroy (pthread_cond_t *cond) +__pthread_cond_destroy (pthread_cond_t *cond) { return 0; } + +strong_alias (__pthread_cond_destroy, pthread_cond_destroy); diff --git a/sysdeps/generic/pt-cond-init.c b/sysdeps/generic/pt-cond-init.c index b9e9fb7..350f2eb 100644 --- a/sysdeps/generic/pt-cond-init.c +++ b/sysdeps/generic/pt-cond-init.c @@ -24,7 +24,7 @@ #include int -pthread_cond_init (pthread_cond_t *cond, +__pthread_cond_init (pthread_cond_t *cond, const pthread_condattr_t *attr) { *cond = (pthread_cond_t) __PTHREAD_COND_INITIALIZER; @@ -43,3 +43,5 @@ pthread_cond_init (pthread_cond_t *cond, *cond->__attr = *attr; return 0; } + +strong_alias (__pthread_cond_init, pthread_cond_init); diff --git a/sysdeps/generic/pt-cond-signal.c b/sysdeps/generic/pt-cond-signal.c index c5e1bc1..d7c91e6 100644 --- a/sysdeps/generic/pt-cond-signal.c +++ b/sysdeps/generic/pt-cond-signal.c @@ -46,9 +46,11 @@ cond_signal (struct __pthread_cond *cond, int *unblocked) /* Unblock at least one of the threads that are blocked on condition variable COND. */ int -pthread_cond_signal (pthread_cond_t *cond) +__pthread_cond_signal (pthread_cond_t *cond) { int unblocked = 0; return cond_signal (cond, &unblocked); } + +strong_alias (__pthread_cond_signal, pthread_cond_signal); diff --git a/sysdeps/generic/pt-cond-timedwait.c b/sysdeps/generic/pt-cond-timedwait.c index c10bdb3..483f277 100644 --- a/sysdeps/generic/pt-cond-timedwait.c +++ b/sysdeps/generic/pt-cond-timedwait.c @@ -26,13 +26,15 @@ extern int __pthread_cond_timedwait_internal (pthread_cond_t *cond, const struct timespec *abstime); int -pthread_cond_timedwait (pthread_cond_t *cond, +__pthread_cond_timedwait (pthread_cond_t *cond, pthread_mutex_t *mutex, const struct timespec *abstime) { return __pthread_cond_timedwait_internal (cond, mutex, abstime); } +strong_alias (__pthread_cond_timedwait, pthread_cond_timedwait); + /* Block on condition variable COND until ABSTIME. As a GNU extension, if ABSTIME is NULL, then wait forever. MUTEX should be held by the calling thread. On return, MUTEX will be held by the diff --git a/sysdeps/generic/pt-cond-wait.c b/sysdeps/generic/pt-cond-wait.c index a03476d..38a2ae6 100644 --- a/sysdeps/generic/pt-cond-wait.c +++ b/sysdeps/generic/pt-cond-wait.c @@ -31,7 +31,9 @@ extern int __pthread_cond_timedwait_internal (pthread_cond_t *cond, calling thread. On return, MUTEX will be held by the calling thread. */ int -pthread_cond_wait (pthread_cond_t *cond, pthread_mutex_t *mutex) +__pthread_cond_wait (pthread_cond_t *cond, pthread_mutex_t *mutex) { return __pthread_cond_timedwait_internal (cond, mutex, 0); } + +strong_alias (__pthread_cond_wait, pthread_cond_wait); diff --git a/sysdeps/generic/pt-condattr-destroy.c b/sysdeps/generic/pt-condattr-destroy.c index c8fd71b..9fd55b1 100644 --- a/sysdeps/generic/pt-condattr-destroy.c +++ b/sysdeps/generic/pt-condattr-destroy.c @@ -21,7 +21,9 @@ #include int -pthread_condattr_destroy (pthread_condattr_t *cond) +__pthread_condattr_destroy (pthread_condattr_t *cond) { return 0; } + +strong_alias (__pthread_condattr_destroy, pthread_condattr_destroy); diff --git a/sysdeps/generic/pt-condattr-init.c b/sysdeps/generic/pt-condattr-init.c index cf9e198..8570fd1 100644 --- a/sysdeps/generic/pt-condattr-init.c +++ b/sysdeps/generic/pt-condattr-init.c @@ -21,8 +21,10 @@ #include int -pthread_condattr_init (pthread_condattr_t *attr) +__pthread_condattr_init (pthread_condattr_t *attr) { *attr = __pthread_default_condattr; return 0; } + +strong_alias (__pthread_condattr_init, pthread_condattr_init); diff --git a/sysdeps/generic/pt-equal.c b/sysdeps/generic/pt-equal.c index 8fbc519..72fc7e6 100644 --- a/sysdeps/generic/pt-equal.c +++ b/sysdeps/generic/pt-equal.c @@ -23,7 +23,9 @@ /* Return true if __T1 and __T2 both name the same thread. Otherwise, false. */ int -pthread_equal (pthread_t __t1, pthread_t __t2) +__pthread_equal (pthread_t __t1, pthread_t __t2) { return __t1 == __t2; } + +strong_alias (__pthread_equal, pthread_equal); diff --git a/sysdeps/generic/pt-getschedparam.c b/sysdeps/generic/pt-getschedparam.c index c128d02..6ec45fe 100644 --- a/sysdeps/generic/pt-getschedparam.c +++ b/sysdeps/generic/pt-getschedparam.c @@ -21,8 +21,10 @@ #include int -pthread_getschedparam (pthread_t thread, int *policy, +__pthread_getschedparam (pthread_t thread, int *policy, struct sched_param *param) { return ENOSYS; } + +strong_alias (__pthread_getschedparam, pthread_getschedparam); diff --git a/sysdeps/generic/pt-setschedparam.c b/sysdeps/generic/pt-setschedparam.c index a70b079..14aeb0c 100644 --- a/sysdeps/generic/pt-setschedparam.c +++ b/sysdeps/generic/pt-setschedparam.c @@ -21,8 +21,10 @@ #include int -pthread_setschedparam (pthread_t thread, int policy, +__pthread_setschedparam (pthread_t thread, int policy, const struct sched_param *param) { return ENOSYS; } + +strong_alias (__pthread_setschedparam, pthread_setschedparam); -- cgit v1.2.3 From 608a12659f15d57abf42a972c1e56c6a24cfe244 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Sat, 21 Apr 2012 22:14:22 +0000 Subject: Rename bits/atomic.h to bits/pt-atomic.h This avoids a conflict with glibc-provided bits/atomic.h * sysdeps/ia32/bits/atomic.h: Rename to... * sysdeps/ia32/bits/pt-atomic.h: ... this. * pthread/pt-create.c: Include instead of * pthread/pt-exit.c: Likewise. * pthread/pt-internal.h: Likewise. --- pthread/pt-create.c | 2 +- pthread/pt-exit.c | 2 +- pthread/pt-internal.h | 2 +- sysdeps/ia32/bits/atomic.h | 66 ------------------------------------------- sysdeps/ia32/bits/pt-atomic.h | 66 +++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 69 insertions(+), 69 deletions(-) delete mode 100644 sysdeps/ia32/bits/atomic.h create mode 100644 sysdeps/ia32/bits/pt-atomic.h diff --git a/pthread/pt-create.c b/pthread/pt-create.c index 346c697..ca6b66c 100644 --- a/pthread/pt-create.c +++ b/pthread/pt-create.c @@ -22,7 +22,7 @@ #include #include -#include +#include #include diff --git a/pthread/pt-exit.c b/pthread/pt-exit.c index 53a0427..c47b604 100644 --- a/pthread/pt-exit.c +++ b/pthread/pt-exit.c @@ -24,7 +24,7 @@ #include -#include +#include /* Terminate the current thread and make STATUS available to any diff --git a/pthread/pt-internal.h b/pthread/pt-internal.h index 3f69d2d..94bc9a7 100644 --- a/pthread/pt-internal.h +++ b/pthread/pt-internal.h @@ -26,7 +26,7 @@ #include #include -#include +#include #include diff --git a/sysdeps/ia32/bits/atomic.h b/sysdeps/ia32/bits/atomic.h deleted file mode 100644 index 0dfc1f6..0000000 --- a/sysdeps/ia32/bits/atomic.h +++ /dev/null @@ -1,66 +0,0 @@ -/* Atomic operations. i386 version. - Copyright (C) 2000 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with the GNU C Library; see the file COPYING.LIB. If not, - write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. */ - -#ifndef _BITS_ATOMIC_H -#define _BITS_ATOMIC_H 1 - -typedef __volatile int __atomic_t; - -static inline void -__atomic_inc (__atomic_t *__var) -{ - __asm__ __volatile ("lock; incl %0" : "=m" (*__var) : "m" (*__var)); -} - -static inline void -__atomic_dec (__atomic_t *__var) -{ - __asm__ __volatile ("lock; decl %0" : "=m" (*__var) : "m" (*__var)); -} - -static inline int -__atomic_dec_and_test (__atomic_t *__var) -{ - unsigned char __ret; - - __asm__ __volatile ("lock; decl %0; sete %1" - : "=m" (*__var), "=qm" (__ret) : "m" (*__var)); - return __ret != 0; -} - -/* We assume that an __atomicptr_t is only used for pointers to - word-aligned objects, and use the lowest bit for a simple lock. */ -typedef __volatile int * __atomicptr_t; - -/* Actually we don't implement that yet, and assume that we run on - something that has the i486 instruction set. */ -static inline int -__atomicptr_compare_and_swap (__atomicptr_t *__ptr, void *__oldval, - void * __newval) -{ - char __ret; - int __dummy; - - __asm__ __volatile ("lock; cmpxchgl %3, %1; sete %0" - : "=q" (__ret), "=m" (*__ptr), "=a" (__dummy) - : "r" (__newval), "m" (*__ptr), "a" (__oldval)); - return __ret; -} - -#endif diff --git a/sysdeps/ia32/bits/pt-atomic.h b/sysdeps/ia32/bits/pt-atomic.h new file mode 100644 index 0000000..0dfc1f6 --- /dev/null +++ b/sysdeps/ia32/bits/pt-atomic.h @@ -0,0 +1,66 @@ +/* Atomic operations. i386 version. + Copyright (C) 2000 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#ifndef _BITS_ATOMIC_H +#define _BITS_ATOMIC_H 1 + +typedef __volatile int __atomic_t; + +static inline void +__atomic_inc (__atomic_t *__var) +{ + __asm__ __volatile ("lock; incl %0" : "=m" (*__var) : "m" (*__var)); +} + +static inline void +__atomic_dec (__atomic_t *__var) +{ + __asm__ __volatile ("lock; decl %0" : "=m" (*__var) : "m" (*__var)); +} + +static inline int +__atomic_dec_and_test (__atomic_t *__var) +{ + unsigned char __ret; + + __asm__ __volatile ("lock; decl %0; sete %1" + : "=m" (*__var), "=qm" (__ret) : "m" (*__var)); + return __ret != 0; +} + +/* We assume that an __atomicptr_t is only used for pointers to + word-aligned objects, and use the lowest bit for a simple lock. */ +typedef __volatile int * __atomicptr_t; + +/* Actually we don't implement that yet, and assume that we run on + something that has the i486 instruction set. */ +static inline int +__atomicptr_compare_and_swap (__atomicptr_t *__ptr, void *__oldval, + void * __newval) +{ + char __ret; + int __dummy; + + __asm__ __volatile ("lock; cmpxchgl %3, %1; sete %0" + : "=q" (__ret), "=m" (*__ptr), "=a" (__dummy) + : "r" (__newval), "m" (*__ptr), "a" (__oldval)); + return __ret; +} + +#endif -- cgit v1.2.3 From d21d530170abcaec33ba272b11cb6615eb2804de Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Sat, 21 Apr 2012 22:54:16 +0000 Subject: Do not redefine tcbhead_t in glibc * pthread/pt-internal.h (tcbhead_t): Define struct only if IS_IN_libpthread is not defined. --- pthread/pt-internal.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pthread/pt-internal.h b/pthread/pt-internal.h index 94bc9a7..6186c86 100644 --- a/pthread/pt-internal.h +++ b/pthread/pt-internal.h @@ -54,6 +54,7 @@ enum pthread_state # define PTHREAD_SYSDEP_MEMBERS #endif +#ifndef IS_IN_libpthread #ifdef ENABLE_TLS /* Type of the TCB. */ typedef struct @@ -63,6 +64,7 @@ typedef struct thread_t self; /* This thread's control port. */ } tcbhead_t; #endif /* ENABLE_TLS */ +#endif /* IS_IN_libpthread */ /* This structure describes a POSIX thread. */ struct __pthread -- cgit v1.2.3 From c310aa40efd3b2d954354e0550b1bbb6a8e7e349 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Sat, 21 Apr 2012 23:15:55 +0000 Subject: Add glibc build support * Makeconfig, Versions, configure.in, forward.c, libc_pthread_init.c, pthread/pthread-functions.h, shlib-versions, sysdeps/i386/Implies, sysdeps/mach/hurd/Implies, sysdeps/mach/hurd/i386/Implies: New files. * Makefile: Add glibc rules, enabled when IN_GLIBC is defined to yes, when $(..) is defined. * pthread/pt-initialize.c [IS_IN_libpthread] (pthread_functions): New variable. [IS_IN_libpthread] (__pthread_initialize): Call __libc_pthread_init. --- Makeconfig | 10 ++ Makefile | 299 +++++++++++++++++++++++++---------------- Versions | 132 ++++++++++++++++++ configure.in | 4 + forward.c | 127 +++++++++++++++++ libc_pthread_init.c | 34 +++++ pthread/pt-initialize.c | 50 +++++++ pthread/pthread-functions.h | 116 ++++++++++++++++ shlib-versions | 1 + sysdeps/i386/Implies | 1 + sysdeps/mach/hurd/Implies | 1 + sysdeps/mach/hurd/i386/Implies | 1 + 12 files changed, 662 insertions(+), 114 deletions(-) create mode 100644 Makeconfig create mode 100644 Versions create mode 100644 configure.in create mode 100644 forward.c create mode 100644 libc_pthread_init.c create mode 100644 pthread/pthread-functions.h create mode 100644 shlib-versions create mode 100644 sysdeps/i386/Implies create mode 100644 sysdeps/mach/hurd/Implies create mode 100644 sysdeps/mach/hurd/i386/Implies diff --git a/Makeconfig b/Makeconfig new file mode 100644 index 0000000..e7e567c --- /dev/null +++ b/Makeconfig @@ -0,0 +1,10 @@ +# Makeconfig fragment for Hurd libpthread add-on. +# This gets included at the end of the main glibc Makeconfig. + +have-thread-library = yes + +shared-thread-library = $(common-objpfx)libpthread/libpthread.so +static-thread-library = $(common-objpfx)libpthread/libpthread.a +bounded-thread-library = $(static-thread-library) + +rpath-dirs += libpthread diff --git a/Makefile b/Makefile index a1801f5..b291177 100644 --- a/Makefile +++ b/Makefile @@ -16,128 +16,147 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +ifeq ($(..),) +# non-glibc build +IN_GLIBC = no +else +# glibc build +IN_GLIBC = yes +endif + +ifeq ($(IN_GLIBC),no) dir := libpthread makemode := library +else +subdir := libpthread + +pthread-version := 0.3 + +srcdir = . +endif MICROKERNEL := mach -SYSDEPS := lockfile.c - -LCLHDRS := - -SRCS := pt-attr.c pt-attr-destroy.c pt-attr-getdetachstate.c \ - pt-attr-getguardsize.c pt-attr-getinheritsched.c \ - pt-attr-getschedparam.c pt-attr-getschedpolicy.c pt-attr-getscope.c \ - pt-attr-getstack.c pt-attr-getstackaddr.c pt-attr-getstacksize.c \ - pt-attr-init.c pt-attr-setdetachstate.c pt-attr-setguardsize.c \ - pt-attr-setinheritsched.c pt-attr-setschedparam.c \ - pt-attr-setschedpolicy.c pt-attr-setscope.c pt-attr-setstack.c \ - pt-attr-setstackaddr.c pt-attr-setstacksize.c \ - \ - pt-barrier-destroy.c pt-barrier-init.c pt-barrier-wait.c \ - pt-barrier.c pt-barrierattr-destroy.c pt-barrierattr-init.c \ - pt-barrierattr-getpshared.c pt-barrierattr-setpshared.c \ - \ - pt-destroy-specific.c pt-init-specific.c \ - pt-key-create.c pt-key-delete.c \ - pt-getspecific.c pt-setspecific.c \ - \ - pt-once.c \ - \ - pt-alloc.c \ - pt-create.c \ - pt-getattr.c \ - pt-equal.c \ - pt-dealloc.c \ - pt-detach.c \ - pt-exit.c \ - pt-initialize.c \ - pt-join.c \ - pt-self.c \ - pt-sigmask.c \ - pt-spin-inlines.c \ - pt-cleanup.c \ - pt-setcancelstate.c \ - pt-setcanceltype.c \ - pt-testcancel.c \ - pt-cancel.c \ - \ - pt-mutexattr.c \ - pt-mutexattr-destroy.c pt-mutexattr-init.c \ - pt-mutexattr-getprioceiling.c pt-mutexattr-getprotocol.c \ - pt-mutexattr-getpshared.c pt-mutexattr-gettype.c \ - pt-mutexattr-setprioceiling.c pt-mutexattr-setprotocol.c \ - pt-mutexattr-setpshared.c pt-mutexattr-settype.c \ - \ - pt-mutex-init.c pt-mutex-destroy.c \ - pt-mutex-lock.c pt-mutex-trylock.c pt-mutex-timedlock.c \ - pt-mutex-unlock.c \ - pt-mutex-transfer-np.c \ - pt-mutex-getprioceiling.c pt-mutex-setprioceiling.c \ - \ - pt-rwlock-attr.c \ - pt-rwlockattr-init.c pt-rwlockattr-destroy.c \ - pt-rwlockattr-getpshared.c pt-rwlockattr-setpshared.c \ - \ - pt-rwlock-init.c pt-rwlock-destroy.c \ - pt-rwlock-rdlock.c pt-rwlock-tryrdlock.c \ - pt-rwlock-trywrlock.c pt-rwlock-wrlock.c \ - pt-rwlock-timedrdlock.c pt-rwlock-timedwrlock.c \ - pt-rwlock-unlock.c \ - \ - pt-cond.c \ - pt-condattr-init.c pt-condattr-destroy.c \ - pt-condattr-getclock.c pt-condattr-getpshared.c \ - pt-condattr-setclock.c pt-condattr-setpshared.c \ - \ - pt-cond-destroy.c pt-cond-init.c \ - pt-cond-brdcast.c \ - pt-cond-signal.c \ - pt-cond-wait.c \ - pt-cond-timedwait.c \ - \ - pt-stack-alloc.c \ - pt-thread-alloc.c \ - pt-thread-dealloc.c \ - pt-thread-start.c \ - pt-thread-halt.c \ - pt-startup.c \ - \ - pt-getconcurrency.c pt-setconcurrency.c \ - \ - pt-block.c \ - pt-timedblock.c \ - pt-wakeup.c \ - pt-docancel.c \ - pt-sysdep.c \ - pt-setup.c \ - pt-machdep.c \ - pt-spin.c \ - \ - pt-sigstate-init.c \ - pt-sigstate-destroy.c \ - pt-sigstate.c \ - \ - pt-atfork.c \ - pt-kill.c \ - pt-getcpuclockid.c \ - \ - pt-getschedparam.c pt-setschedparam.c pt-setschedprio.c \ - pt-yield.c \ - \ - sem-close.c sem-destroy.c sem-getvalue.c sem-init.c sem-open.c \ - sem-post.c sem-timedwait.c sem-trywait.c sem-unlink.c \ - sem-wait.c \ - \ - cthreads-compat.c \ +SYSDEPS := lockfile + +LCLHDRS := + +libpthread-routines := pt-attr pt-attr-destroy pt-attr-getdetachstate \ + pt-attr-getguardsize pt-attr-getinheritsched \ + pt-attr-getschedparam pt-attr-getschedpolicy pt-attr-getscope \ + pt-attr-getstack pt-attr-getstackaddr pt-attr-getstacksize \ + pt-attr-init pt-attr-setdetachstate pt-attr-setguardsize \ + pt-attr-setinheritsched pt-attr-setschedparam \ + pt-attr-setschedpolicy pt-attr-setscope pt-attr-setstack \ + pt-attr-setstackaddr pt-attr-setstacksize \ + \ + pt-barrier-destroy pt-barrier-init pt-barrier-wait \ + pt-barrier pt-barrierattr-destroy pt-barrierattr-init \ + pt-barrierattr-getpshared pt-barrierattr-setpshared \ + \ + pt-destroy-specific pt-init-specific \ + pt-key-create pt-key-delete \ + pt-getspecific pt-setspecific \ + \ + pt-once \ + \ + pt-alloc \ + pt-create \ + pt-getattr \ + pt-equal \ + pt-dealloc \ + pt-detach \ + pt-exit \ + pt-initialize \ + pt-join \ + pt-self \ + pt-sigmask \ + pt-spin-inlines \ + pt-cleanup \ + pt-setcancelstate \ + pt-setcanceltype \ + pt-testcancel \ + pt-cancel \ + \ + pt-mutexattr \ + pt-mutexattr-destroy pt-mutexattr-init \ + pt-mutexattr-getprioceiling pt-mutexattr-getprotocol \ + pt-mutexattr-getpshared pt-mutexattr-gettype \ + pt-mutexattr-setprioceiling pt-mutexattr-setprotocol \ + pt-mutexattr-setpshared pt-mutexattr-settype \ + \ + pt-mutex-init pt-mutex-destroy \ + pt-mutex-lock pt-mutex-trylock pt-mutex-timedlock \ + pt-mutex-unlock \ + pt-mutex-transfer-np \ + pt-mutex-getprioceiling pt-mutex-setprioceiling \ + \ + pt-rwlock-attr \ + pt-rwlockattr-init pt-rwlockattr-destroy \ + pt-rwlockattr-getpshared pt-rwlockattr-setpshared \ + \ + pt-rwlock-init pt-rwlock-destroy \ + pt-rwlock-rdlock pt-rwlock-tryrdlock \ + pt-rwlock-trywrlock pt-rwlock-wrlock \ + pt-rwlock-timedrdlock pt-rwlock-timedwrlock \ + pt-rwlock-unlock \ + \ + pt-cond \ + pt-condattr-init pt-condattr-destroy \ + pt-condattr-getclock pt-condattr-getpshared \ + pt-condattr-setclock pt-condattr-setpshared \ + \ + pt-cond-destroy pt-cond-init \ + pt-cond-brdcast \ + pt-cond-signal \ + pt-cond-wait \ + pt-cond-timedwait \ + \ + pt-stack-alloc \ + pt-thread-alloc \ + pt-thread-dealloc \ + pt-thread-start \ + pt-thread-halt \ + pt-startup \ + \ + pt-getconcurrency pt-setconcurrency \ + \ + pt-block \ + pt-timedblock \ + pt-wakeup \ + pt-docancel \ + pt-sysdep \ + pt-setup \ + pt-machdep \ + pt-spin \ + \ + pt-sigstate-init \ + pt-sigstate-destroy \ + pt-sigstate \ + \ + pt-atfork \ + pt-kill \ + pt-getcpuclockid \ + \ + pt-getschedparam pt-setschedparam pt-setschedprio \ + pt-yield \ + \ + sem-close sem-destroy sem-getvalue sem-init sem-open \ + sem-post sem-timedwait sem-trywait sem-unlink \ + sem-wait \ + \ + cthreads-compat \ $(SYSDEPS) +ifeq ($(IN_GLIBC),no) +SRCS := $(addsuffix .c,$(libpthread-routines)) OBJS = $(addsuffix .o,$(basename $(notdir $(SRCS)))) OTHERTAGS = libname = libpthread +endif -sysdeps_headers = \ +headers := \ pthread.h \ pthread/pthread.h \ pthread/pthreadtypes.h \ @@ -161,6 +180,21 @@ sysdeps_headers = \ bits/rwlock-attr.h \ bits/semaphore.h +ifeq ($(IN_GLIBC),yes) +distribute := + +routines := forward libc_pthread_init +shared-only-routines = forward + +vpath %.c + +extra-libs := libpthread +extra-libs-others := $(extra-libs) +install-lib-ldscripts := libpthread.so + +include ../Makeconfig +endif + SYSDEP_PATH = $(srcdir)/sysdeps/$(MICROKERNEL)/hurd/ia32 \ $(srcdir)/sysdeps/$(MICROKERNEL)/ia32 \ $(srcdir)/sysdeps/ia32 \ @@ -174,22 +208,41 @@ SYSDEP_PATH = $(srcdir)/sysdeps/$(MICROKERNEL)/hurd/ia32 \ VPATH += $(SYSDEP_PATH) +ifeq ($(IN_GLIBC),no) HURDLIBS = ihash +else +LDLIBS-pthread.so = -lihash +endif +ifeq ($(IN_GLIBC),no) installhdrs := installhdrsubdir := . include ../Makeconf +endif CPPFLAGS += \ -DENABLE_TLS \ $(addprefix -I, $(SYSDEP_PATH)) \ - -imacros $(srcdir)/include/libc-symbols.h \ -imacros $(srcdir)/not-in-libc.h +ifeq ($(IN_GLIBC),no) +CPPFLAGS += \ + -imacros $(srcdir)/include/libc-symbols.h +else +CPPFLAGS += \ + -imacros libc-symbols.h +endif + +ifeq ($(IN_GLIBC),yes) +CFLAGS-lockfile.c = -D_IO_MTSAFE_IO +all: # Make this the default target; it will be defined in Rules. +endif + +ifeq ($(IN_GLIBC),no) install: install-headers $(libdir)/libpthread2.a $(libdir)/libpthread2_pic.a -install-headers: $(addprefix $(includedir)/, $(sysdeps_headers)) +install-headers: $(addprefix $(includedir)/, $(headers)) # XXX: If $(libdir)/libpthread2.a is installed and # $(libdir)/libpthread is not, we can have some issues. @@ -206,10 +259,27 @@ $(libdir)/libpthread2.a: $(libdir)/libpthread.a $(libdir)/libpthread2_pic.a: $(libdir)/libpthread_pic.a mv $< $@ $(INSTALL_DATA) $(srcdir)/libpthread_pic.a $< +endif + +ifeq ($(IN_GLIBC),yes) +libc-link.so = $(common-objpfx)libc.so + +include ../Rules + +# Depend on libc.so so a DT_NEEDED is generated in the shared objects. +# This ensures they will load libc.so for needed symbols if loaded by +# a statically-linked program that hasn't already loaded it. +# Depend on ld.so too to get proper versions of ld.so symbols. +$(objpfx)libpthread.so: $(libc-link.so) $(common-objpfx)libc_nonshared.a \ + $(if $(filter yes,$(elf)), $(elfobjdir)/ld.so) \ + $(common-objpfx)/mach/libmachuser.so \ + $(common-objpfx)/hurd/libhurduser.so +endif -.PHONY: $(addprefix $(includedir)/, $(sysdeps_headers)) +ifeq ($(IN_GLIBC),no) +.PHONY: $(addprefix $(includedir)/, $(headers)) -$(addprefix $(includedir)/, $(sysdeps_headers)): +$(addprefix $(includedir)/, $(headers)): @set -e; \ t="$@"; \ t=$${t#$(includedir)/}; \ @@ -247,3 +317,4 @@ maintainer.; \ # $(libname).so.$(hurd-version): $(srcdir)/$(libname).map # # endif +endif diff --git a/Versions b/Versions new file mode 100644 index 0000000..77eb870 --- /dev/null +++ b/Versions @@ -0,0 +1,132 @@ +libc { + GLIBC_2.13 { + pthread_attr_destroy; pthread_attr_getdetachstate; + pthread_attr_getinheritsched; pthread_attr_getschedparam; + pthread_attr_getschedpolicy; pthread_attr_getscope; pthread_attr_init; + pthread_attr_setdetachstate; pthread_attr_setinheritsched; + pthread_attr_setschedparam; pthread_attr_setschedpolicy; + pthread_attr_setscope; + pthread_condattr_destroy; pthread_condattr_init; + pthread_cond_broadcast; pthread_cond_destroy; + pthread_cond_init; pthread_cond_signal; pthread_cond_wait; + pthread_cond_timedwait; + pthread_equal; + pthread_exit; pthread_getschedparam; pthread_setschedparam; + pthread_mutex_destroy; pthread_mutex_init; + pthread_mutex_lock; pthread_mutex_trylock; pthread_mutex_unlock; + pthread_self; pthread_setcancelstate; pthread_setcanceltype; + __pthread_get_cleanup_stack; + GLIBC_PRIVATE { + __libc_pthread_init; + } +} + +libpthread { + GLIBC_2.12 { + __pthread_errorcheck_mutexattr; __pthread_recursive_mutexattr; + + _IO_flockfile; _IO_ftrylockfile; _IO_funlockfile; + + __pthread_get_cleanup_stack; + + __pthread_mutex_transfer_np; + + _pthread_mutex_destroy; _pthread_mutex_init; + _pthread_mutex_lock; _pthread_mutex_trylock; _pthread_mutex_unlock; + _pthread_rwlock_destroy; _pthread_rwlock_init; + + _cthread_init_routine; + + cthread_detach; + cthread_fork; + cthread_keycreate; + cthread_getspecific; + __libc_getspecific; + cthread_setspecific; + __mutex_lock_solid; + __mutex_unlock_solid; + _cthreads_flockfile; + _cthreads_ftrylockfile; + _cthreads_funlockfile; + + flockfile; ftrylockfile; funlockfile; + + pthread_atfork; + + pthread_attr_destroy; pthread_attr_getdetachstate; + pthread_attr_getguardsize; pthread_attr_getinheritsched; + pthread_attr_getschedparam; pthread_attr_getschedpolicy; + pthread_attr_getscope; pthread_attr_getstack; pthread_attr_getstackaddr; + pthread_attr_getstacksize; pthread_attr_init; pthread_attr_setdetachstate; + pthread_attr_setguardsize; pthread_attr_setinheritsched; + pthread_attr_setschedparam; pthread_attr_setschedpolicy; + pthread_attr_setscope; pthread_attr_setstack; pthread_attr_setstackaddr; + pthread_attr_setstacksize; + + pthread_barrier_destroy; pthread_barrier_init; pthread_barrier_wait; + pthread_barrierattr_destroy; pthread_barrierattr_getpshared; + pthread_barrierattr_init; pthread_barrierattr_setpshared; + + pthread_cancel; + + pthread_cond_broadcast; pthread_cond_destroy; pthread_cond_init; + pthread_cond_signal; pthread_cond_timedwait; pthread_cond_wait; + + pthread_condattr_destroy; pthread_condattr_getclock; + pthread_condattr_getpshared; pthread_condattr_init; + pthread_condattr_setclock; pthread_condattr_setpshared; + + pthread_create; pthread_detach; pthread_equal; pthread_exit; + + pthread_getattr_np; + + pthread_getconcurrency; pthread_getcpuclockid; + pthread_getschedparam; pthread_getspecific; + + pthread_join; + + pthread_key_create; pthread_key_delete; + + pthread_kill; + + pthread_mutex_destroy; pthread_mutex_getprioceiling; + pthread_mutex_init; pthread_mutex_lock; pthread_mutex_setprioceiling; + pthread_mutex_timedlock; pthread_mutex_transfer_np; + pthread_mutex_trylock; pthread_mutex_unlock; + + pthread_mutexattr_destroy; pthread_mutexattr_getprioceiling; + pthread_mutexattr_getprotocol; pthread_mutexattr_getpshared; + pthread_mutexattr_gettype; pthread_mutexattr_init; + pthread_mutexattr_setprioceiling; pthread_mutexattr_setprotocol; + pthread_mutexattr_setpshared; pthread_mutexattr_settype; + + pthread_once; + + pthread_rwlock_destroy; pthread_rwlock_init; pthread_rwlock_rdlock; + pthread_rwlock_timedrdlock; pthread_rwlock_timedwrlock; + pthread_rwlock_tryrdlock; pthread_rwlock_trywrlock; + pthread_rwlock_unlock; pthread_rwlock_wrlock; + + pthread_rwlockattr_destroy; pthread_rwlockattr_getpshared; + pthread_rwlockattr_init; pthread_rwlockattr_setpshared; + + pthread_self; + + pthread_setcancelstate; pthread_setcanceltype; + pthread_setconcurrency; pthread_setschedparam; + pthread_setschedprio; pthread_setspecific; + + pthread_sigmask; + pthread_testcancel; + pthread_yield; + + sem_close; sem_destroy; sem_getvalue; sem_init; sem_open; sem_post; + sem_timedwait; sem_trywait; sem_unlink; sem_wait; + + pthread_spin_destroy; pthread_spin_init; pthread_spin_lock; + pthread_spin_trylock; pthread_spin_unlock; + __pthread_spin_destroy; __pthread_spin_init; + __pthread_spin_lock; __pthread_spin_trylock; __pthread_spin_unlock; + _pthread_spin_lock; + } +} diff --git a/configure.in b/configure.in new file mode 100644 index 0000000..4e140b1 --- /dev/null +++ b/configure.in @@ -0,0 +1,4 @@ +GLIBC_PROVIDES + +libc_add_on_canonical=libpthread +libc_add_on_subdirs=. diff --git a/forward.c b/forward.c new file mode 100644 index 0000000..c07d7c0 --- /dev/null +++ b/forward.c @@ -0,0 +1,127 @@ +/* Copyright (C) 2002, 2003, 2012 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper , 2002. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include +#include +#include +#include + +/* Pointers to the libc functions. */ +struct pthread_functions __libc_pthread_functions attribute_hidden; + + +# define FORWARD2(name, rettype, decl, params, defaction) \ +rettype \ +name decl \ +{ \ + if (__libc_pthread_functions.ptr_##name == NULL) \ + defaction; \ + \ + return __libc_pthread_functions.ptr_##name params; \ +} + +# define FORWARD(name, decl, params, defretval) \ + FORWARD2 (name, int, decl, params, return defretval) + +FORWARD (pthread_attr_destroy, (pthread_attr_t *attr), (attr), 0) + +FORWARD (pthread_attr_init, (pthread_attr_t *attr), (attr), 0) + +FORWARD (pthread_attr_getdetachstate, + (const pthread_attr_t *attr, int *detachstate), (attr, detachstate), + 0) +FORWARD (pthread_attr_setdetachstate, (pthread_attr_t *attr, int detachstate), + (attr, detachstate), 0) + +FORWARD (pthread_attr_getinheritsched, + (const pthread_attr_t *attr, int *inherit), (attr, inherit), 0) +FORWARD (pthread_attr_setinheritsched, (pthread_attr_t *attr, int inherit), + (attr, inherit), 0) + +FORWARD (pthread_attr_getschedparam, + (const pthread_attr_t *attr, struct sched_param *param), + (attr, param), 0) +FORWARD (pthread_attr_setschedparam, + (pthread_attr_t *attr, const struct sched_param *param), + (attr, param), 0) + +FORWARD (pthread_attr_getschedpolicy, + (const pthread_attr_t *attr, int *policy), (attr, policy), 0) +FORWARD (pthread_attr_setschedpolicy, (pthread_attr_t *attr, int policy), + (attr, policy), 0) + +FORWARD (pthread_attr_getscope, + (const pthread_attr_t *attr, int *scope), (attr, scope), 0) +FORWARD (pthread_attr_setscope, (pthread_attr_t *attr, int scope), + (attr, scope), 0) + + +FORWARD (pthread_condattr_destroy, (pthread_condattr_t *attr), (attr), 0) +FORWARD (pthread_condattr_init, (pthread_condattr_t *attr), (attr), 0) + + +FORWARD (pthread_cond_broadcast, (pthread_cond_t *cond), (cond), 0) +FORWARD (pthread_cond_destroy, (pthread_cond_t *cond), (cond), 0) +FORWARD (pthread_cond_init, + (pthread_cond_t *cond, const pthread_condattr_t *cond_attr), + (cond, cond_attr), 0) +FORWARD (pthread_cond_signal, (pthread_cond_t *cond), (cond), 0) +FORWARD (pthread_cond_wait, (pthread_cond_t *cond, pthread_mutex_t *mutex), + (cond, mutex), 0) +FORWARD (pthread_cond_timedwait, + (pthread_cond_t *cond, pthread_mutex_t *mutex, + const struct timespec *abstime), (cond, mutex, abstime), 0) + +FORWARD (pthread_equal, (pthread_t thread1, pthread_t thread2), + (thread1, thread2), 1) + + +/* Use an alias to avoid warning, as pthread_exit is declared noreturn. */ +FORWARD2 (pthread_exit, void, (void *retval), (retval), exit (EXIT_SUCCESS)) + + +FORWARD (pthread_getschedparam, + (pthread_t target_thread, int *policy, struct sched_param *param), + (target_thread, policy, param), 0) +FORWARD (pthread_setschedparam, + (pthread_t target_thread, int policy, + const struct sched_param *param), (target_thread, policy, param), 0) + + +FORWARD (pthread_mutex_destroy, (pthread_mutex_t *mutex), (mutex), 0) + +FORWARD (pthread_mutex_init, + (pthread_mutex_t *mutex, const pthread_mutexattr_t *mutexattr), + (mutex, mutexattr), 0) + +FORWARD (pthread_mutex_lock, (pthread_mutex_t *mutex), (mutex), 0) + +FORWARD (pthread_mutex_unlock, (pthread_mutex_t *mutex), (mutex), 0) + + +FORWARD2 (pthread_self, pthread_t, (void), (), return 0) + + +FORWARD (pthread_setcancelstate, (int state, int *oldstate), (state, oldstate), + 0) + +FORWARD (pthread_setcanceltype, (int type, int *oldtype), (type, oldtype), 0) + +struct __pthread_cancelation_handler *dummy_list; +FORWARD2 (__pthread_get_cleanup_stack, struct __pthread_cancelation_handler **, (void), (), return &dummy_list); diff --git a/libc_pthread_init.c b/libc_pthread_init.c new file mode 100644 index 0000000..e6c8b9f --- /dev/null +++ b/libc_pthread_init.c @@ -0,0 +1,34 @@ +/* Copyright (C) 2002 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Jakub Jelinek , 2002. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include +#include + +void +__libc_pthread_init (functions) + const struct pthread_functions *functions; +{ +#ifdef SHARED + /* We copy the content of the variable pointed to by the FUNCTIONS + parameter to one in libc.so since this means access to the array + can be done with one memory access instead of two. */ + memcpy (&__libc_pthread_functions, functions, + sizeof (__libc_pthread_functions)); +#endif +} diff --git a/pthread/pt-initialize.c b/pthread/pt-initialize.c index cf32b8b..f0ef8f8 100644 --- a/pthread/pt-initialize.c +++ b/pthread/pt-initialize.c @@ -23,11 +23,61 @@ #include #include +#include +#include + DEFINE_HOOK (__pthread_init, (void)); +#ifdef IS_IN_libpthread +#ifdef SHARED +static const struct pthread_functions pthread_functions = + { + .ptr_pthread_attr_destroy = __pthread_attr_destroy, + .ptr_pthread_attr_init = __pthread_attr_init, + .ptr_pthread_attr_getdetachstate = __pthread_attr_getdetachstate, + .ptr_pthread_attr_setdetachstate = __pthread_attr_setdetachstate, + .ptr_pthread_attr_getinheritsched = __pthread_attr_getinheritsched, + .ptr_pthread_attr_setinheritsched = __pthread_attr_setinheritsched, + .ptr_pthread_attr_getschedparam = __pthread_attr_getschedparam, + .ptr_pthread_attr_setschedparam = __pthread_attr_setschedparam, + .ptr_pthread_attr_getschedpolicy = __pthread_attr_getschedpolicy, + .ptr_pthread_attr_setschedpolicy = __pthread_attr_setschedpolicy, + .ptr_pthread_attr_getscope = __pthread_attr_getscope, + .ptr_pthread_attr_setscope = __pthread_attr_setscope, + .ptr_pthread_condattr_destroy = __pthread_condattr_destroy, + .ptr_pthread_condattr_init = __pthread_condattr_init, + .ptr_pthread_cond_broadcast = __pthread_cond_broadcast, + .ptr_pthread_cond_destroy = __pthread_cond_destroy, + .ptr_pthread_cond_init = __pthread_cond_init, + .ptr_pthread_cond_signal = __pthread_cond_signal, + .ptr_pthread_cond_wait = __pthread_cond_wait, + .ptr_pthread_cond_timedwait = __pthread_cond_timedwait, + .ptr_pthread_equal = __pthread_equal, + .ptr_pthread_exit = __pthread_exit, + .ptr_pthread_getschedparam = __pthread_getschedparam, + .ptr_pthread_setschedparam = __pthread_setschedparam, + .ptr_pthread_mutex_destroy = _pthread_mutex_destroy, + .ptr_pthread_mutex_init = _pthread_mutex_init, + .ptr_pthread_mutex_lock = __pthread_mutex_lock, + .ptr_pthread_mutex_trylock = __pthread_mutex_trylock, + .ptr_pthread_mutex_unlock = __pthread_mutex_unlock, + .ptr_pthread_self = __pthread_self, + .ptr_pthread_setcancelstate = __pthread_setcancelstate, + .ptr_pthread_setcanceltype = __pthread_setcanceltype, + .ptr___pthread_get_cleanup_stack = __pthread_get_cleanup_stack, + }; +# define ptr_pthread_functions &pthread_functions +#else +# define ptr_pthread_functions NULL +#endif +#endif /* IS_IN_libpthread */ + /* Initialize the pthreads library. */ void __pthread_initialize (void) { +#ifdef IS_IN_libpthread + __libc_pthread_init(ptr_pthread_functions); +#endif RUN_HOOK (__pthread_init, ()); } diff --git a/pthread/pthread-functions.h b/pthread/pthread-functions.h new file mode 100644 index 0000000..c0ba858 --- /dev/null +++ b/pthread/pthread-functions.h @@ -0,0 +1,116 @@ +/* Copyright (C) 2003, 2012 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper , 2003. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _PTHREAD_FUNCTIONS_H +#define _PTHREAD_FUNCTIONS_H 1 + +#include + +int __pthread_attr_destroy (pthread_attr_t *); +int __pthread_attr_init (pthread_attr_t *); +int __pthread_attr_getdetachstate (const pthread_attr_t *, int *); +int __pthread_attr_setdetachstate (pthread_attr_t *, int); +int __pthread_attr_getinheritsched (const pthread_attr_t *, int *); +int __pthread_attr_setinheritsched (pthread_attr_t *, int); +int __pthread_attr_getschedparam (const pthread_attr_t *, + struct sched_param *); +int __pthread_attr_setschedparam (pthread_attr_t *, + const struct sched_param *); +int __pthread_attr_getschedpolicy (const pthread_attr_t *, int *); +int __pthread_attr_setschedpolicy (pthread_attr_t *, int); +int __pthread_attr_getscope (const pthread_attr_t *, int *); +int __pthread_attr_setscope (pthread_attr_t *, int); +int __pthread_condattr_destroy (pthread_condattr_t *); +int __pthread_condattr_init (pthread_condattr_t *); +int __pthread_cond_broadcast (pthread_cond_t *); +int __pthread_cond_destroy (pthread_cond_t *); +int __pthread_cond_init (pthread_cond_t *, + const pthread_condattr_t *); +int __pthread_cond_signal (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_equal (pthread_t, pthread_t); +void __pthread_exit (void *); +int __pthread_getschedparam (pthread_t, int *, struct sched_param *); +int __pthread_setschedparam (pthread_t, int, + const struct sched_param *); +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 *); +pthread_t __pthread_self (void); +int __pthread_setcancelstate (int, int *); +int __pthread_setcanceltype (int, int *); +struct __pthread_cancelation_handler **__pthread_get_cleanup_stack (void); + +/* Data type shared with libc. The libc uses it to pass on calls to + the thread functions. Wine pokes directly into this structure, + so if possible avoid breaking it and append new hooks to the end. */ +struct pthread_functions +{ + int (*ptr_pthread_attr_destroy) (pthread_attr_t *); + int (*ptr_pthread_attr_init) (pthread_attr_t *); + int (*ptr_pthread_attr_getdetachstate) (const pthread_attr_t *, int *); + int (*ptr_pthread_attr_setdetachstate) (pthread_attr_t *, int); + int (*ptr_pthread_attr_getinheritsched) (const pthread_attr_t *, int *); + int (*ptr_pthread_attr_setinheritsched) (pthread_attr_t *, int); + int (*ptr_pthread_attr_getschedparam) (const pthread_attr_t *, + struct sched_param *); + int (*ptr_pthread_attr_setschedparam) (pthread_attr_t *, + const struct sched_param *); + int (*ptr_pthread_attr_getschedpolicy) (const pthread_attr_t *, int *); + int (*ptr_pthread_attr_setschedpolicy) (pthread_attr_t *, int); + int (*ptr_pthread_attr_getscope) (const pthread_attr_t *, int *); + int (*ptr_pthread_attr_setscope) (pthread_attr_t *, int); + int (*ptr_pthread_condattr_destroy) (pthread_condattr_t *); + int (*ptr_pthread_condattr_init) (pthread_condattr_t *); + int (*ptr_pthread_cond_broadcast) (pthread_cond_t *); + int (*ptr_pthread_cond_destroy) (pthread_cond_t *); + int (*ptr_pthread_cond_init) (pthread_cond_t *, + const pthread_condattr_t *); + int (*ptr_pthread_cond_signal) (pthread_cond_t *); + int (*ptr_pthread_cond_wait) (pthread_cond_t *, pthread_mutex_t *); + int (*ptr_pthread_cond_timedwait) (pthread_cond_t *, pthread_mutex_t *, + const struct timespec *); + int (*ptr_pthread_equal) (pthread_t, pthread_t); + void (*ptr_pthread_exit) (void *); + int (*ptr_pthread_getschedparam) (pthread_t, int *, struct sched_param *); + int (*ptr_pthread_setschedparam) (pthread_t, int, + const struct sched_param *); + int (*ptr_pthread_mutex_destroy) (pthread_mutex_t *); + int (*ptr_pthread_mutex_init) (pthread_mutex_t *, + const pthread_mutexattr_t *); + int (*ptr_pthread_mutex_lock) (pthread_mutex_t *); + int (*ptr_pthread_mutex_trylock) (pthread_mutex_t *); + int (*ptr_pthread_mutex_unlock) (pthread_mutex_t *); + pthread_t (*ptr_pthread_self) (void); + int (*ptr_pthread_setcancelstate) (int, int *); + int (*ptr_pthread_setcanceltype) (int, int *); + struct __pthread_cancelation_handler **(*ptr___pthread_get_cleanup_stack) (void); +}; + +/* Variable in libc.so. */ +extern struct pthread_functions __libc_pthread_functions attribute_hidden; + +void __libc_pthread_init (const struct pthread_functions *functions); + +#endif /* pthread-functions.h */ diff --git a/shlib-versions b/shlib-versions new file mode 100644 index 0000000..b320be0 --- /dev/null +++ b/shlib-versions @@ -0,0 +1 @@ +.*-.*-.* libpthread=0.3 diff --git a/sysdeps/i386/Implies b/sysdeps/i386/Implies new file mode 100644 index 0000000..d799fa1 --- /dev/null +++ b/sysdeps/i386/Implies @@ -0,0 +1 @@ +ia32 diff --git a/sysdeps/mach/hurd/Implies b/sysdeps/mach/hurd/Implies new file mode 100644 index 0000000..16b8348 --- /dev/null +++ b/sysdeps/mach/hurd/Implies @@ -0,0 +1 @@ +hurd diff --git a/sysdeps/mach/hurd/i386/Implies b/sysdeps/mach/hurd/i386/Implies new file mode 100644 index 0000000..d799fa1 --- /dev/null +++ b/sysdeps/mach/hurd/i386/Implies @@ -0,0 +1 @@ +ia32 -- cgit v1.2.3 From dbaf5693972d2cbfad0ad48b966e5693b770127e Mon Sep 17 00:00:00 2001 From: Pino Toscano Date: Sun, 22 Apr 2012 00:22:47 +0200 Subject: __pthread_timedblock: add an argument for the clock id To make `__pthread_timedblock' properly measure time using the right clock, add a new argument representing the clock to use. * pthread/pt-internal.h (__pthread_timedblock): New argument CLOCK_ID. * sysdeps/l4/pt-timedblock.c (__pthread_timedblock): Likewise. * sysdeps/mach/pt-timedblock.c (__pthread_timedblock): Likewise. * sysdeps/generic/pt-cond-timedwait.c (__pthread_cond_timedwait_internal): Pass the clock of the `pthread_cond' to `__pthread_timedblock'. * sysdeps/generic/pt-mutex-timedlock.c (__pthread_mutex_timedlock_internal): Pass CLOCK_REALTIME to `__pthread_timedblock'. * sysdeps/generic/pt-rwlock-timedrdlock.c (__pthread_rwlock_timedrdlock_internal): Likewise. * sysdeps/generic/pt-rwlock-timedwrlock.c (__pthread_rwlock_timedwrlock_internal): Likewise. * sysdeps/generic/sem-timedwait.c (__sem_timedwait_internal): Likewise. --- pthread/pt-internal.h | 3 ++- sysdeps/generic/pt-cond-timedwait.c | 5 ++++- sysdeps/generic/pt-mutex-timedlock.c | 2 +- sysdeps/generic/pt-rwlock-timedrdlock.c | 2 +- sysdeps/generic/pt-rwlock-timedwrlock.c | 2 +- sysdeps/generic/sem-timedwait.c | 2 +- sysdeps/l4/pt-timedblock.c | 3 ++- sysdeps/mach/pt-timedblock.c | 3 ++- 8 files changed, 14 insertions(+), 8 deletions(-) diff --git a/pthread/pt-internal.h b/pthread/pt-internal.h index 6186c86..a1e90aa 100644 --- a/pthread/pt-internal.h +++ b/pthread/pt-internal.h @@ -254,7 +254,8 @@ extern void __pthread_block (struct __pthread *thread); /* Block THREAD until *ABSTIME is reached. */ extern error_t __pthread_timedblock (struct __pthread *__restrict thread, - const struct timespec *__restrict abstime); + const struct timespec *__restrict abstime, + clockid_t clock_id); /* Wakeup THREAD. */ extern void __pthread_wakeup (struct __pthread *thread); diff --git a/sysdeps/generic/pt-cond-timedwait.c b/sysdeps/generic/pt-cond-timedwait.c index 483f277..56eb1ec 100644 --- a/sysdeps/generic/pt-cond-timedwait.c +++ b/sysdeps/generic/pt-cond-timedwait.c @@ -46,6 +46,7 @@ __pthread_cond_timedwait_internal (pthread_cond_t *cond, { error_t err; int canceltype; + clockid_t clock_id = __pthread_default_condattr.clock; void cleanup (void *arg) { @@ -68,6 +69,8 @@ __pthread_cond_timedwait_internal (pthread_cond_t *cond, /* Add ourselves to the list of waiters. */ __pthread_spin_lock (&cond->__lock); __pthread_enqueue (&cond->__queue, self); + if (cond->__attr) + clock_id = cond->__attr->clock; __pthread_spin_unlock (&cond->__lock); __pthread_mutex_unlock (mutex); @@ -79,7 +82,7 @@ __pthread_cond_timedwait_internal (pthread_cond_t *cond, if (abstime) { - err = __pthread_timedblock (self, abstime); + err = __pthread_timedblock (self, abstime, clock_id); if (err) /* We timed out. We may need to disconnect ourself from the waiter queue. diff --git a/sysdeps/generic/pt-mutex-timedlock.c b/sysdeps/generic/pt-mutex-timedlock.c index 883e50a..48bffaf 100644 --- a/sysdeps/generic/pt-mutex-timedlock.c +++ b/sysdeps/generic/pt-mutex-timedlock.c @@ -130,7 +130,7 @@ __pthread_mutex_timedlock_internal (struct __pthread_mutex *mutex, { error_t err; - err = __pthread_timedblock (self, abstime); + err = __pthread_timedblock (self, abstime, CLOCK_REALTIME); if (err) /* We timed out. We may need to disconnect ourself from the waiter queue. diff --git a/sysdeps/generic/pt-rwlock-timedrdlock.c b/sysdeps/generic/pt-rwlock-timedrdlock.c index ba610fa..a110213 100644 --- a/sysdeps/generic/pt-rwlock-timedrdlock.c +++ b/sysdeps/generic/pt-rwlock-timedrdlock.c @@ -73,7 +73,7 @@ __pthread_rwlock_timedrdlock_internal (struct __pthread_rwlock *rwlock, { error_t err; - err = __pthread_timedblock (self, abstime); + err = __pthread_timedblock (self, abstime, CLOCK_REALTIME); if (err) /* We timed out. We may need to disconnect ourself from the waiter queue. diff --git a/sysdeps/generic/pt-rwlock-timedwrlock.c b/sysdeps/generic/pt-rwlock-timedwrlock.c index 04eab51..a5cc579 100644 --- a/sysdeps/generic/pt-rwlock-timedwrlock.c +++ b/sysdeps/generic/pt-rwlock-timedwrlock.c @@ -59,7 +59,7 @@ __pthread_rwlock_timedwrlock_internal (struct __pthread_rwlock *rwlock, { error_t err; - err = __pthread_timedblock (self, abstime); + err = __pthread_timedblock (self, abstime, CLOCK_REALTIME); if (err) /* We timed out. We may need to disconnect ourself from the waiter queue. diff --git a/sysdeps/generic/sem-timedwait.c b/sysdeps/generic/sem-timedwait.c index e34539a..94e6dee 100644 --- a/sysdeps/generic/sem-timedwait.c +++ b/sysdeps/generic/sem-timedwait.c @@ -55,7 +55,7 @@ __sem_timedwait_internal (sem_t *restrict sem, { error_t err; - err = __pthread_timedblock (self, timeout); + err = __pthread_timedblock (self, timeout, CLOCK_REALTIME); if (err) /* We timed out. We may need to disconnect ourself from the waiter queue. diff --git a/sysdeps/l4/pt-timedblock.c b/sysdeps/l4/pt-timedblock.c index ce7972b..951644f 100644 --- a/sysdeps/l4/pt-timedblock.c +++ b/sysdeps/l4/pt-timedblock.c @@ -27,7 +27,8 @@ /* Block THREAD. */ error_t __pthread_timedblock (struct __pthread *thread, - const struct timespec *abstime) + const struct timespec *abstime, + clockid_t clock_id) { #warning Need gettimeofday to implement properly. __pthread_block (thread); diff --git a/sysdeps/mach/pt-timedblock.c b/sysdeps/mach/pt-timedblock.c index 6f54726..88beaa2 100644 --- a/sysdeps/mach/pt-timedblock.c +++ b/sysdeps/mach/pt-timedblock.c @@ -30,7 +30,8 @@ /* Block THREAD. */ error_t __pthread_timedblock (struct __pthread *thread, - const struct timespec *abstime) + const struct timespec *abstime, + clockid_t clock_id) { error_t err; mach_msg_header_t msg; -- cgit v1.2.3 From 69e89a859882e4f675dd5491edc969159d8a4002 Mon Sep 17 00:00:00 2001 From: Pino Toscano Date: Sun, 22 Apr 2012 00:38:26 +0200 Subject: __pthread_timedblock: switch to clock_gettime Use `clock_gettime' with the provided clock instead of `gettimeofday', linking to rt. * sysdeps/mach/pt-timedblock.c (__pthread_timedblock): Switch to `clock_gettime'. * Makefile [!IN_GLIBC] (LDLIBS): Link to rt. [IN_GLIBC] ($(objpfx)libpthread.so): Likewise. * Makefile.am (libpthread_a_LDADD): Likewise. --- Makefile | 2 ++ Makefile.am | 2 ++ sysdeps/mach/pt-timedblock.c | 13 ++++++------- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index b291177..bee4e3c 100644 --- a/Makefile +++ b/Makefile @@ -210,8 +210,10 @@ VPATH += $(SYSDEP_PATH) ifeq ($(IN_GLIBC),no) HURDLIBS = ihash +LDLIBS = -lrt else LDLIBS-pthread.so = -lihash +$(objpfx)libpthread.so: $(common-objpfx)rt/librt.so endif ifeq ($(IN_GLIBC),no) diff --git a/Makefile.am b/Makefile.am index e1c062c..36ede54 100644 --- a/Makefile.am +++ b/Makefile.am @@ -166,3 +166,5 @@ libpthread_a_SOURCES = pt-attr.c pt-attr-destroy.c pt-attr-getdetachstate.c \ sigwaitinfo.c \ signal-dispatch-lowlevel.c \ sigprocmask.c + +libpthread_a_LDADD = -lrt diff --git a/sysdeps/mach/pt-timedblock.c b/sysdeps/mach/pt-timedblock.c index 88beaa2..d72ef73 100644 --- a/sysdeps/mach/pt-timedblock.c +++ b/sysdeps/mach/pt-timedblock.c @@ -36,27 +36,26 @@ __pthread_timedblock (struct __pthread *thread, error_t err; mach_msg_header_t msg; mach_msg_timeout_t timeout; - struct timeval now; + struct timespec now; /* We have an absolute time and now we have to convert it to a relative time. Arg. */ - err = gettimeofday(&now, NULL); + err = clock_gettime (clock_id, &now); assert (! err); if (now.tv_sec > abstime->tv_sec || (now.tv_sec == abstime->tv_sec - && now.tv_usec > ((abstime->tv_nsec + 999) / 1000))) + && now.tv_nsec > abstime->tv_nsec)) return ETIMEDOUT; timeout = (abstime->tv_sec - now.tv_sec) * 1000; - if (((abstime->tv_nsec + 999) / 1000) >= now.tv_usec) - timeout += (((abstime->tv_nsec + 999) / 1000) - now.tv_usec + 999) / 1000; + if (abstime->tv_nsec >= now.tv_nsec) + timeout += (abstime->tv_nsec - now.tv_nsec + 999999) / 1000000; else /* Need to do a carry. */ - timeout -= (now.tv_usec + 999) / 1000 - - ((abstime->tv_nsec + 999999) / 1000000); + timeout -= (now.tv_nsec - abstime->tv_nsec + 999999) / 1000000; err = __mach_msg (&msg, MACH_RCV_MSG | MACH_RCV_TIMEOUT, 0, sizeof msg, thread->wakeupmsg.msgh_remote_port, -- cgit v1.2.3 From 581b822ea36002817f4c22b9ea715b72a0647166 Mon Sep 17 00:00:00 2001 From: Pino Toscano Date: Sun, 22 Apr 2012 00:44:24 +0200 Subject: pthread_condattr_setclock: allow a monotonic clock, if present If CLOCK_MONOTONIC is requested, check (only once) for the availability of a monotonic clock using `clock_getres'. If it is not, reject CLOCK_MONOTONIC with EINVAL (as before). * sysdeps/generic/pt-condattr-setclock.c (pthread_condattr_setclock): Check for monotonic clock if requested. --- sysdeps/generic/pt-condattr-setclock.c | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/sysdeps/generic/pt-condattr-setclock.c b/sysdeps/generic/pt-condattr-setclock.c index 984c17e..c5a78ef 100644 --- a/sysdeps/generic/pt-condattr-setclock.c +++ b/sysdeps/generic/pt-condattr-setclock.c @@ -23,11 +23,30 @@ int pthread_condattr_setclock (pthread_condattr_t *attr, clockid_t clock) { - if (__pthread_default_condattr.clock == clock) + /* Only a few clocks are allowed. CLOCK_REALTIME is always allowed. + CLOCK_MONOTONIC only if the kernel has the necessary support. */ + if (clock == CLOCK_MONOTONIC) { - attr->clock = clock; - return 0; + /* Check whether the clock is available. */ + static int avail; + + if (avail == 0) + { + struct timespec ts; + int res; + + res = clock_getres (CLOCK_MONOTONIC, &ts); + avail = res < 0 ? -1 : 1; + } + + if (avail < 0) + /* Not available. */ + return EINVAL; } + else if (clock != CLOCK_REALTIME) + return EINVAL; + + attr->clock = clock; - return EINVAL; + return 0; } -- cgit v1.2.3 From 23e100abfe088d846df479ab176cba28f43a7814 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Sun, 22 Apr 2012 00:50:37 +0000 Subject: Set -B option to find libpthread.so * Makefile (extra-B-pthread.so): Define. --- Makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Makefile b/Makefile index b291177..73f90da 100644 --- a/Makefile +++ b/Makefile @@ -264,6 +264,8 @@ endif ifeq ($(IN_GLIBC),yes) libc-link.so = $(common-objpfx)libc.so +extra-B-pthread.so = -B$(common-objpfx)libpthread/ + include ../Rules # Depend on libc.so so a DT_NEEDED is generated in the shared objects. -- cgit v1.2.3 From cf4bfa4a4c5216e2d07a7fec4aa6487fa56003c9 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Sun, 22 Apr 2012 16:52:46 +0000 Subject: Install bits/pthreadtypes.h And make it expose only types, not the rest of the pthread API. * Makefile (headers): Add bits/pthreadtypes.h. * sysdeps/generic/bits/pthreadtypes.h: Include instead of --- Makefile | 1 + sysdeps/generic/bits/pthreadtypes.h | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 73f90da..4bc0101 100644 --- a/Makefile +++ b/Makefile @@ -164,6 +164,7 @@ headers := \ \ bits/pthread.h \ bits/pthread-np.h \ + bits/pthreadtypes.h \ bits/mutex.h \ bits/condition.h \ bits/condition-attr.h \ diff --git a/sysdeps/generic/bits/pthreadtypes.h b/sysdeps/generic/bits/pthreadtypes.h index e5cbfd2..70368ff 100644 --- a/sysdeps/generic/bits/pthreadtypes.h +++ b/sysdeps/generic/bits/pthreadtypes.h @@ -24,6 +24,6 @@ #ifndef _BITS_PTHREADTYPES_H #define _BITS_PTHREADTYPES_H 1 -#include +#include #endif /* bits/pthreadtypes.h */ -- cgit v1.2.3 From 9741579ea63731ff5651cd3185d04c71bae2fe14 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Sun, 22 Apr 2012 16:55:40 +0000 Subject: Fix glibc add-on installation rules * Makefile [IN_GLIBC=no] (inst_libdir): Define to $(libdir). (install, .PHONY, libpthread2.a, libpthread2_pic.a): Use $(inst_libdir) instead of $(libdir), enable in IN_GLIBC=yes too. [IN_GLIBC=yes] ($(inst_libdir)/libpthread.so): Define to create symlink. --- Makefile | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index 4bc0101..153d66b 100644 --- a/Makefile +++ b/Makefile @@ -242,27 +242,39 @@ all: # Make this the default target; it will be defined in Rules. endif ifeq ($(IN_GLIBC),no) -install: install-headers $(libdir)/libpthread2.a $(libdir)/libpthread2_pic.a +$(inst_libdir) = $(libdir) +endif + +ifeq ($(IN_GLIBC),no) +install: install-headers install-headers: $(addprefix $(includedir)/, $(headers)) -# XXX: If $(libdir)/libpthread2.a is installed and -# $(libdir)/libpthread is not, we can have some issues. -.PHONY: $(libdir)/libpthread.a $(libdir)/libpthread_pic.a +install: $(inst_libdir)/libpthread2.a $(inst_libdir)/libpthread2_pic.a +else +subdir_install: $(inst_libdir)/libpthread2.a +endif + +# XXX: If $(inst_libdir)/libpthread2.a is installed and +# $(inst_libdir)/libpthread is not, we can have some issues. +.PHONY: $(inst_libdir)/libpthread.a $(inst_libdir)/libpthread_pic.a # XXX: These rules are a hack. But it is better than messing with # ../Makeconf at the moment. Note that the linker scripts # $(srcdir)/libpthread.a and $(srcdir)/libpthread_pic.a get overwritten # when building in $(srcdir) and not a seperate build directory. -$(libdir)/libpthread2.a: $(libdir)/libpthread.a +$(inst_libdir)/libpthread2.a: $(inst_libdir)/libpthread.a mv $< $@ $(INSTALL_DATA) $(srcdir)/libpthread.a $< -$(libdir)/libpthread2_pic.a: $(libdir)/libpthread_pic.a +$(inst_libdir)/libpthread2_pic.a: $(inst_libdir)/libpthread_pic.a mv $< $@ $(INSTALL_DATA) $(srcdir)/libpthread_pic.a $< -endif ifeq ($(IN_GLIBC),yes) +$(inst_libdir)/libpthread.so: $(objpfx)libpthread.so$(libpthread.so-version) \ + $(+force) + ln -sf libpthread.so$(libpthread.so-version) $@ + libc-link.so = $(common-objpfx)libc.so extra-B-pthread.so = -B$(common-objpfx)libpthread/ -- cgit v1.2.3 From ccebcf4e6d0b42681cc78edbfd2d2adec674f7c7 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Mon, 23 Apr 2012 17:59:18 +0000 Subject: Fix access to libpthread headers from glibc * Makeconfig (+includes): Add our include/ directory in the header include path, for the rest of glibc. --- Makeconfig | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Makeconfig b/Makeconfig index e7e567c..9ce18d3 100644 --- a/Makeconfig +++ b/Makeconfig @@ -8,3 +8,5 @@ static-thread-library = $(common-objpfx)libpthread/libpthread.a bounded-thread-library = $(static-thread-library) rpath-dirs += libpthread + ++includes += -I$(..)libpthread/include -- cgit v1.2.3 From 71dcdb6d0189761ecc27691932502eacdf7e6b2c Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Mon, 23 Apr 2012 18:00:21 +0000 Subject: Rename __pthread_initialize into __pthread_init The former conflicts with usage in glibc. * pthread/pt-initialize.c (__pthread_initialize): Rename into __pthread_init. * pthread/pt-internal.h (__pthread_initialize): Likewise. * sysdeps/l4/hurd/pt-sysdep.c (init_routine): Likewise. * sysdeps/mach/hurd/pt-sysdep.c (init_routine): Likewise. --- pthread/pt-initialize.c | 2 +- pthread/pt-internal.h | 2 +- sysdeps/l4/hurd/pt-sysdep.c | 2 +- sysdeps/mach/hurd/pt-sysdep.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pthread/pt-initialize.c b/pthread/pt-initialize.c index f0ef8f8..39f1aed 100644 --- a/pthread/pt-initialize.c +++ b/pthread/pt-initialize.c @@ -74,7 +74,7 @@ static const struct pthread_functions pthread_functions = /* Initialize the pthreads library. */ void -__pthread_initialize (void) +__pthread_init (void) { #ifdef IS_IN_libpthread __libc_pthread_init(ptr_pthread_functions); diff --git a/pthread/pt-internal.h b/pthread/pt-internal.h index a1e90aa..a1da377 100644 --- a/pthread/pt-internal.h +++ b/pthread/pt-internal.h @@ -188,7 +188,7 @@ extern struct __pthread *_pthread_self (void); /* Initialize the pthreads library. */ -extern void __pthread_initialize (void); +extern void __pthread_init (void); /* Internal version of pthread_create. Rather than return the new tid, we return the whole __pthread structure in *PTHREAD. */ diff --git a/sysdeps/l4/hurd/pt-sysdep.c b/sysdeps/l4/hurd/pt-sysdep.c index c23364c..1df6c2e 100644 --- a/sysdeps/l4/hurd/pt-sysdep.c +++ b/sysdeps/l4/hurd/pt-sysdep.c @@ -45,7 +45,7 @@ static void init_routine (void (*entry) (void *), void *arg) { /* Initialize the library. */ - __pthread_initialize (); + __pthread_init(); struct __pthread *thread; int err; diff --git a/sysdeps/mach/hurd/pt-sysdep.c b/sysdeps/mach/hurd/pt-sysdep.c index 5e07006..95a4d36 100644 --- a/sysdeps/mach/hurd/pt-sysdep.c +++ b/sysdeps/mach/hurd/pt-sysdep.c @@ -45,7 +45,7 @@ init_routine (void) int err; /* Initialize the library. */ - __pthread_initialize (); + __pthread_init (); /* Create the pthread structure for the main thread (i.e. us). */ err = __pthread_create_internal (&thread, 0, 0, 0); -- cgit v1.2.3 From e84c82a43e671c7506401936ac097b55d0fb47bf Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Fri, 27 Apr 2012 01:28:16 +0000 Subject: Always pass the pthread_functions structure * pthread/pt-initialize.c (pthread_functions): Always define. (__pthread_init): Always pass address of pthread_functions. --- pthread/pt-initialize.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/pthread/pt-initialize.c b/pthread/pt-initialize.c index 39f1aed..831a63d 100644 --- a/pthread/pt-initialize.c +++ b/pthread/pt-initialize.c @@ -29,7 +29,6 @@ DEFINE_HOOK (__pthread_init, (void)); #ifdef IS_IN_libpthread -#ifdef SHARED static const struct pthread_functions pthread_functions = { .ptr_pthread_attr_destroy = __pthread_attr_destroy, @@ -66,10 +65,6 @@ static const struct pthread_functions pthread_functions = .ptr_pthread_setcanceltype = __pthread_setcanceltype, .ptr___pthread_get_cleanup_stack = __pthread_get_cleanup_stack, }; -# define ptr_pthread_functions &pthread_functions -#else -# define ptr_pthread_functions NULL -#endif #endif /* IS_IN_libpthread */ /* Initialize the pthreads library. */ @@ -77,7 +72,7 @@ void __pthread_init (void) { #ifdef IS_IN_libpthread - __libc_pthread_init(ptr_pthread_functions); + __libc_pthread_init(&pthread_functions); #endif RUN_HOOK (__pthread_init, ()); } -- cgit v1.2.3 From 25260994c812050a5d7addf125cdc90c911ca5c1 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Fri, 27 Apr 2012 01:32:54 +0000 Subject: Store self in __thread variable instead of threadvar * sysdeps/mach/hurd/pt-sysdep.h (_HURD_THREADVAR_THREAD): Remove macro. (___pthread_self): Declare new __thread variable. (_pthread_self): Take self pointer from ___pthread_self instead of threadvar. * sysdeps/mach/hurd/pt-sysdep.c (___pthread_self): Define new __thread variable. (init_routine): Set ___pthread_self to initial thread structure. * pthread/pt-internal.h (__pthread_setup): Add `self' parameter to `entry_point' parameter. * pthread/pt-create.c (entry_point): Add `self' parameter. Store it in ___pthread_self. * sysdeps/l4/hurd/ia32/pt-setup.c (stack_setup): Add `self parameter to `entry_point' parameter. Pass it the `thread' parameter. (__pthread_setup): Likewise. * sysdeps/l4/hurd/powerpc/pt-setup.c (struct start_info): Add `self' field. (first_entry_1): Pass `self' parameter. (stack_setup): Add `self' parameter to `entry_point' parameter, pass it the `thread' parameter. (__pthread_setup): Likewise. * sysdeps/mach/hurd/ia32/pt-setup.c (stack_setup): Pass `thread' parameter to the start routine. (stack_setup): Add `self' parameter to `entry_point' paramter. --- pthread/pt-create.c | 6 +++++- pthread/pt-internal.h | 3 ++- sysdeps/l4/hurd/ia32/pt-setup.c | 5 +++-- sysdeps/l4/hurd/powerpc/pt-setup.c | 7 +++++-- sysdeps/mach/hurd/ia32/pt-setup.c | 12 +++++------- sysdeps/mach/hurd/pt-sysdep.c | 5 +++-- sysdeps/mach/hurd/pt-sysdep.h | 6 ++---- 7 files changed, 25 insertions(+), 19 deletions(-) diff --git a/pthread/pt-create.c b/pthread/pt-create.c index ca6b66c..4d81a95 100644 --- a/pthread/pt-create.c +++ b/pthread/pt-create.c @@ -38,8 +38,12 @@ __atomic_t __pthread_total; /* The entry-point for new threads. */ static void -entry_point (void *(*start_routine)(void *), void *arg) +entry_point (struct __pthread *self, void *(*start_routine)(void *), void *arg) { +#ifdef ENABLE_TLS + ___pthread_self = self; +#endif + #ifdef HAVE_USELOCALE /* A fresh thread needs to be bound to the global locale. */ uselocale (LC_GLOBAL_LOCALE); diff --git a/pthread/pt-internal.h b/pthread/pt-internal.h index a1da377..f5766e9 100644 --- a/pthread/pt-internal.h +++ b/pthread/pt-internal.h @@ -217,7 +217,8 @@ extern void __pthread_stack_dealloc (void *stackaddr, size_t stacksize); /* Setup thread THREAD's context. */ extern int __pthread_setup (struct __pthread *__restrict thread, - void (*entry_point)(void *(*)(void *), + void (*entry_point)(struct __pthread *, + void *(*)(void *), void *), void *(*start_routine)(void *), void *__restrict arg); diff --git a/sysdeps/l4/hurd/ia32/pt-setup.c b/sysdeps/l4/hurd/ia32/pt-setup.c index 579905c..de7359c 100644 --- a/sysdeps/l4/hurd/ia32/pt-setup.c +++ b/sysdeps/l4/hurd/ia32/pt-setup.c @@ -65,7 +65,7 @@ __pthread_entry_point:\n\ static void * stack_setup (struct __pthread *thread, void *(*start_routine)(void *), void *arg, - void (*entry_point)(void *(*)(void *), void *)) + void (*entry_point)(struct __pthread *, void *(*)(void *), void *)) { uintptr_t *top; @@ -80,6 +80,7 @@ stack_setup (struct __pthread *thread, /* Set up call frame. */ *--top = (uintptr_t) arg; /* Argument to START_ROUTINE. */ *--top = (uintptr_t) start_routine; + *--top = (uintptr_t) thread; *--top = 0; /* Fake return address. */ *--top = (uintptr_t) entry_point; } @@ -89,7 +90,7 @@ stack_setup (struct __pthread *thread, int __pthread_setup (struct __pthread *thread, - void (*entry_point)(void *(*)(void *), void *), + void (*entry_point)(struct __pthread *, void *(*)(void *), void *), void *(*start_routine)(void *), void *arg) { thread->mcontext.pc = (void *) &_pthread_entry_point; diff --git a/sysdeps/l4/hurd/powerpc/pt-setup.c b/sysdeps/l4/hurd/powerpc/pt-setup.c index d3cf4ec..d309216 100644 --- a/sysdeps/l4/hurd/powerpc/pt-setup.c +++ b/sysdeps/l4/hurd/powerpc/pt-setup.c @@ -28,6 +28,7 @@ struct start_info { void (*entry_point) (void *(*)(void *), void *); + struct __pthread *self; void *(*start_routine) (void *); void *arg; }; @@ -41,6 +42,7 @@ first_entry_1: ;\ lwz 0, 0(1) ;\ lwz 3, 4(1) ;\ lwz 4, 8(1) ;\ + lwz 5, 12(1) ;\ mtctr 0 ;\ bctrl ;\ "); @@ -51,7 +53,7 @@ first_entry_1: ;\ opportunity to install THREAD in our utcb. */ static void * stack_setup (struct __pthread *thread, - void (*entry_point)(void *(*)(void *), void *), + void (*entry_point)(struct __pthread *, void *(*)(void *), void *), void *(*start_routine)(void *), void *arg) { l4_word_t *top; @@ -68,6 +70,7 @@ stack_setup (struct __pthread *thread, struct start_info *info = ((struct start_info *) top) - 1; info->entry_point = entry_point; + info->self = thread; info->start_routine = start_routine; info->arg = arg; return (void *) info; @@ -77,7 +80,7 @@ stack_setup (struct __pthread *thread, int __pthread_setup (struct __pthread *thread, - void (*entry_point)(void *(*)(void *), void *), + void (*entry_point)(struct __pthread *, void *(*)(void *), void *), void *(*start_routine)(void *), void *arg) { thread->mcontext.pc = first_entry_1; diff --git a/sysdeps/mach/hurd/ia32/pt-setup.c b/sysdeps/mach/hurd/ia32/pt-setup.c index 5420dc8..73fd43d 100644 --- a/sysdeps/mach/hurd/ia32/pt-setup.c +++ b/sysdeps/mach/hurd/ia32/pt-setup.c @@ -57,16 +57,14 @@ stack_setup (struct __pthread *thread, /* Next, make room for the TSDs. */ top -= __hurd_threadvar_max; - /* Save the self pointer. */ - top[_HURD_THREADVAR_THREAD] = (uintptr_t) thread; - if (start_routine) { /* And then the call frame. */ - top -= 2; + top -= 3; top = (uintptr_t *) ((uintptr_t) top & ~0xf); - top[1] = (uintptr_t) arg; /* Argument to START_ROUTINE. */ - top[0] = (uintptr_t) start_routine; + top[2] = (uintptr_t) arg; /* Argument to START_ROUTINE. */ + top[1] = (uintptr_t) start_routine; + top[0] = (uintptr_t) thread; *--top = 0; /* Fake return address. */ } @@ -82,7 +80,7 @@ stack_setup (struct __pthread *thread, int __pthread_setup (struct __pthread *thread, - void (*entry_point)(void *(*)(void *), void *), + void (*entry_point)(struct __pthread *, void *(*)(void *), void *), void *(*start_routine)(void *), void *arg) { error_t err; diff --git a/sysdeps/mach/hurd/pt-sysdep.c b/sysdeps/mach/hurd/pt-sysdep.c index 95a4d36..f40fee5 100644 --- a/sysdeps/mach/hurd/pt-sysdep.c +++ b/sysdeps/mach/hurd/pt-sysdep.c @@ -28,6 +28,8 @@ #include +__thread struct __pthread *___pthread_self; + /* Forward. */ static void *init_routine (void); @@ -51,8 +53,7 @@ init_routine (void) err = __pthread_create_internal (&thread, 0, 0, 0); assert_perror (err); - ((void **) (__hurd_threadvar_stack_offset))[_HURD_THREADVAR_THREAD] - = thread; + ___pthread_self = thread; /* Decrease the number of threads, to take into account that the signal thread (which will be created by the glibc startup code diff --git a/sysdeps/mach/hurd/pt-sysdep.h b/sysdeps/mach/hurd/pt-sysdep.h index 13e235d..bec1b40 100644 --- a/sysdeps/mach/hurd/pt-sysdep.h +++ b/sysdeps/mach/hurd/pt-sysdep.h @@ -35,15 +35,13 @@ mach_msg_header_t wakeupmsg; \ int have_kernel_resources; -#define _HURD_THREADVAR_THREAD _HURD_THREADVAR_DYNAMIC_USER - +extern __thread struct __pthread *___pthread_self; #define _pthread_self() \ ({ \ struct __pthread *thread; \ \ assert (__pthread_threads); \ - thread = *(struct __pthread **) \ - __hurd_threadvar_location (_HURD_THREADVAR_THREAD); \ + thread = ___pthread_self; \ \ assert (thread); \ assert (({ mach_port_t ktid = __mach_thread_self (); \ -- cgit v1.2.3 From 1dc7553d93bf7f48b5f767b74eab607142d77160 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Fri, 25 May 2012 02:32:40 +0200 Subject: Add -lrt to libpthread.a to fix static link * libpthread.a (GROUP): Add -lrt. --- libpthread.a | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libpthread.a b/libpthread.a index d0e689e..926315b 100644 --- a/libpthread.a +++ b/libpthread.a @@ -17,4 +17,4 @@ EXTERN(_cthreads_flockfile) EXTERN(_cthreads_funlockfile) EXTERN(_cthreads_ftrylockfile) -GROUP(-lpthread2 -lihash) +GROUP(-lpthread2 -lihash -lrt) -- cgit v1.2.3 From f42e3ba3cb16bd892957f3b018e2d8ae1e06d022 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Sun, 8 Jul 2012 20:45:56 +0200 Subject: Comment on deviation from standard * pthread/pt-internal.h (guardsize): Mention that we depart from the standard which says guardsize is in addition to stacksize. --- pthread/pt-internal.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pthread/pt-internal.h b/pthread/pt-internal.h index f5766e9..067fb73 100644 --- a/pthread/pt-internal.h +++ b/pthread/pt-internal.h @@ -84,6 +84,8 @@ struct __pthread size_t guardsize; /* Included in STACKSIZE (i.e. total stack memory is STACKSIZE, not STACKSIZE + GUARDSIZE). */ + /* FIXME: standard says that guardsize is in + addition to stacksize. */ int stack; /* Nonzero if the stack was allocated. */ /* Exit status. */ -- cgit v1.2.3 From 966245ae2a9b17a58205751e6251fdb84ee89fce Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Sun, 8 Jul 2012 20:54:19 +0200 Subject: Default to a little guardsize Later rounded up to a page. * sysdeps/generic/pt-attr.c (__pthread_default_attr) [!PAGESIZE]: Set guardsize field to 1. --- sysdeps/generic/pt-attr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sysdeps/generic/pt-attr.c b/sysdeps/generic/pt-attr.c index 769f292..e501dc7 100644 --- a/sysdeps/generic/pt-attr.c +++ b/sysdeps/generic/pt-attr.c @@ -32,7 +32,7 @@ const struct __pthread_attr __pthread_default_attr = #ifdef PAGESIZE guardsize: PAGESIZE, #else - guardsize: 0, + guardsize: 1, #endif /* PAGESIZE */ detachstate: PTHREAD_CREATE_JOINABLE, inheritsched: PTHREAD_EXPLICIT_SCHED, -- cgit v1.2.3 From 36b80faf23f4585721355ad2501225776a0ce392 Mon Sep 17 00:00:00 2001 From: Thomas DiModica Date: Sat, 4 Aug 2012 00:37:16 +0200 Subject: Fix typo * Makefile (inst_libdir) [!IN_GLIBC]: Set variable to $(libdir) instead of expanding it. --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index e8c77e3..efb486e 100644 --- a/Makefile +++ b/Makefile @@ -244,7 +244,7 @@ all: # Make this the default target; it will be defined in Rules. endif ifeq ($(IN_GLIBC),no) -$(inst_libdir) = $(libdir) +inst_libdir = $(libdir) endif ifeq ($(IN_GLIBC),no) -- cgit v1.2.3 From 549aba4335946c26f2701c2b43be0e6148d27c09 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Tue, 7 Aug 2012 13:19:58 +0200 Subject: Fix libpthread.so symlink * Makefile ($(inst_libdir)/libpthread.so): Symlink from absolute path $(slibdir)/libpthread.so$(libpthread.so-version) instead of relative, as both files may not be in the same directory (e.g. in Debian). --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index efb486e..b6e5602 100644 --- a/Makefile +++ b/Makefile @@ -275,7 +275,7 @@ $(inst_libdir)/libpthread2_pic.a: $(inst_libdir)/libpthread_pic.a ifeq ($(IN_GLIBC),yes) $(inst_libdir)/libpthread.so: $(objpfx)libpthread.so$(libpthread.so-version) \ $(+force) - ln -sf libpthread.so$(libpthread.so-version) $@ + ln -sf $(slibdir)/libpthread.so$(libpthread.so-version) $@ libc-link.so = $(common-objpfx)libc.so -- cgit v1.2.3 From a0bca9895bca67591127680860077b2658830e96 Mon Sep 17 00:00:00 2001 From: Thomas Schwinge Date: Tue, 7 Aug 2012 22:55:36 +0200 Subject: Remove L4 port. * Makefile.am: Remove file. * headers.m4: Likewise. * sysdeps/l4/bits/pthread-np.h: Likewise. * sysdeps/l4/hurd/bits/pthread-np.h: Likewise. * sysdeps/l4/hurd/ia32/pt-machdep.c: Likewise. * sysdeps/l4/hurd/ia32/pt-setup.c: Likewise. * sysdeps/l4/hurd/ia32/signal-dispatch-lowlevel.c: Likewise. * sysdeps/l4/hurd/powerpc/pt-machdep.c: Likewise. * sysdeps/l4/hurd/powerpc/pt-setup.c: Likewise. * sysdeps/l4/hurd/pt-block.c: Likewise. * sysdeps/l4/hurd/pt-kill.c: Likewise. * sysdeps/l4/hurd/pt-setactivity-np.c: Likewise. * sysdeps/l4/hurd/pt-sigstate-destroy.c: Likewise. * sysdeps/l4/hurd/pt-sigstate-init.c: Likewise. * sysdeps/l4/hurd/pt-sigstate.c: Likewise. * sysdeps/l4/hurd/pt-startup.c: Likewise. * sysdeps/l4/hurd/pt-sysdep.c: Likewise. * sysdeps/l4/hurd/pt-sysdep.h: Likewise. * sysdeps/l4/hurd/pt-thread-alloc.c: Likewise. * sysdeps/l4/hurd/pt-thread-halt.c: Likewise. * sysdeps/l4/hurd/pt-thread-start.c: Likewise. * sysdeps/l4/hurd/pt-wakeup.c: Likewise. * sysdeps/l4/hurd/sig-sysdep.h: Likewise. * sysdeps/l4/hurd/sigprocmask.c: Likewise. * sysdeps/l4/pt-block.c: Likewise. * sysdeps/l4/pt-docancel.c: Likewise. * sysdeps/l4/pt-pool-np.c: Likewise. * sysdeps/l4/pt-spin.c: Likewise. * sysdeps/l4/pt-stack-alloc.c: Likewise. * sysdeps/l4/pt-thread-alloc.c: Likewise. * sysdeps/l4/pt-thread-dealloc.c: Likewise. * sysdeps/l4/pt-thread-halt.c: Likewise. * sysdeps/l4/pt-thread-start.c: Likewise. * sysdeps/l4/pt-timedblock.c: Likewise. * sysdeps/l4/pt-wakeup.c: Likewise. * TODO: Update. * signal/README: Likewise. --- Makefile.am | 170 ------------------- TODO | 33 ---- headers.m4 | 45 ----- signal/README | 3 + sysdeps/l4/bits/pthread-np.h | 35 ---- sysdeps/l4/hurd/bits/pthread-np.h | 31 ---- sysdeps/l4/hurd/ia32/pt-machdep.c | 20 --- sysdeps/l4/hurd/ia32/pt-setup.c | 118 ------------- sysdeps/l4/hurd/ia32/signal-dispatch-lowlevel.c | 213 ------------------------ sysdeps/l4/hurd/powerpc/pt-machdep.c | 20 --- sysdeps/l4/hurd/powerpc/pt-setup.c | 96 ----------- sysdeps/l4/hurd/pt-block.c | 30 ---- sysdeps/l4/hurd/pt-kill.c | 3 - sysdeps/l4/hurd/pt-setactivity-np.c | 39 ----- sysdeps/l4/hurd/pt-sigstate-destroy.c | 28 ---- sysdeps/l4/hurd/pt-sigstate-init.c | 44 ----- sysdeps/l4/hurd/pt-sigstate.c | 81 --------- sysdeps/l4/hurd/pt-startup.c | 30 ---- sysdeps/l4/hurd/pt-sysdep.c | 61 ------- sysdeps/l4/hurd/pt-sysdep.h | 61 ------- sysdeps/l4/hurd/pt-thread-alloc.c | 95 ----------- sysdeps/l4/hurd/pt-thread-halt.c | 104 ------------ sysdeps/l4/hurd/pt-thread-start.c | 70 -------- sysdeps/l4/hurd/pt-wakeup.c | 46 ----- sysdeps/l4/hurd/sig-sysdep.h | 69 -------- sysdeps/l4/hurd/sigprocmask.c | 41 ----- sysdeps/l4/pt-block.c | 47 ------ sysdeps/l4/pt-docancel.c | 42 ----- sysdeps/l4/pt-pool-np.c | 54 ------ sysdeps/l4/pt-spin.c | 63 ------- sysdeps/l4/pt-stack-alloc.c | 43 ----- sysdeps/l4/pt-thread-alloc.c | 43 ----- sysdeps/l4/pt-thread-dealloc.c | 32 ---- sysdeps/l4/pt-thread-halt.c | 45 ----- sysdeps/l4/pt-thread-start.c | 40 ----- sysdeps/l4/pt-timedblock.c | 36 ---- sysdeps/l4/pt-wakeup.c | 54 ------ 37 files changed, 3 insertions(+), 2082 deletions(-) delete mode 100644 Makefile.am delete mode 100644 headers.m4 delete mode 100644 sysdeps/l4/bits/pthread-np.h delete mode 100644 sysdeps/l4/hurd/bits/pthread-np.h delete mode 100644 sysdeps/l4/hurd/ia32/pt-machdep.c delete mode 100644 sysdeps/l4/hurd/ia32/pt-setup.c delete mode 100644 sysdeps/l4/hurd/ia32/signal-dispatch-lowlevel.c delete mode 100644 sysdeps/l4/hurd/powerpc/pt-machdep.c delete mode 100644 sysdeps/l4/hurd/powerpc/pt-setup.c delete mode 100644 sysdeps/l4/hurd/pt-block.c delete mode 100644 sysdeps/l4/hurd/pt-kill.c delete mode 100644 sysdeps/l4/hurd/pt-setactivity-np.c delete mode 100644 sysdeps/l4/hurd/pt-sigstate-destroy.c delete mode 100644 sysdeps/l4/hurd/pt-sigstate-init.c delete mode 100644 sysdeps/l4/hurd/pt-sigstate.c delete mode 100644 sysdeps/l4/hurd/pt-startup.c delete mode 100644 sysdeps/l4/hurd/pt-sysdep.c delete mode 100644 sysdeps/l4/hurd/pt-sysdep.h delete mode 100644 sysdeps/l4/hurd/pt-thread-alloc.c delete mode 100644 sysdeps/l4/hurd/pt-thread-halt.c delete mode 100644 sysdeps/l4/hurd/pt-thread-start.c delete mode 100644 sysdeps/l4/hurd/pt-wakeup.c delete mode 100644 sysdeps/l4/hurd/sig-sysdep.h delete mode 100644 sysdeps/l4/hurd/sigprocmask.c delete mode 100644 sysdeps/l4/pt-block.c delete mode 100644 sysdeps/l4/pt-docancel.c delete mode 100644 sysdeps/l4/pt-pool-np.c delete mode 100644 sysdeps/l4/pt-spin.c delete mode 100644 sysdeps/l4/pt-stack-alloc.c delete mode 100644 sysdeps/l4/pt-thread-alloc.c delete mode 100644 sysdeps/l4/pt-thread-dealloc.c delete mode 100644 sysdeps/l4/pt-thread-halt.c delete mode 100644 sysdeps/l4/pt-thread-start.c delete mode 100644 sysdeps/l4/pt-timedblock.c delete mode 100644 sysdeps/l4/pt-wakeup.c diff --git a/Makefile.am b/Makefile.am deleted file mode 100644 index 36ede54..0000000 --- a/Makefile.am +++ /dev/null @@ -1,170 +0,0 @@ -# Makefile.am - Makefile template for libpthread. -# Copyright (C) 2003, 2008 Free Software Foundation, Inc. -# -# This file is part of the GNU Hurd. -# -# The GNU Hurd is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# The GNU Hurd is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA - -if ARCH_IA32 - arch=ia32 -endif -if ARCH_POWERPC - arch=powerpc -endif - -# The source files are scattered over several directories. Add -# all these directories to the vpath. -SYSDEP_PATH = $(srcdir)/sysdeps/l4/hurd/${arch} \ - $(srcdir)/sysdeps/l4/${arch} \ - $(srcdir)/sysdeps/${arch} \ - $(srcdir)/sysdeps/l4/hurd \ - $(srcdir)/sysdeps/l4 \ - $(srcdir)/sysdeps/hurd \ - $(srcdir)/sysdeps/generic \ - $(srcdir)/sysdeps/posix \ - $(srcdir)/pthread \ - $(srcdir)/signal \ - $(srcdir)/include -vpath %.c $(SYSDEP_PATH) - -AM_CPPFLAGS = $(USER_CPPFLAGS) -I$(srcdir)/pthread \ - $(addprefix -I, $(SYSDEP_PATH)) -imacros $(srcdir)/include/libc-symbols.h -AM_CFLAGS = $(USER_CFLAGS) - -# Sources. -SYSDEPS := lockfile.c - -if ! ENABLE_TESTS -noinst_LIBRARIES = libpthread.a -endif - -libpthread_a_SOURCES = pt-attr.c pt-attr-destroy.c pt-attr-getdetachstate.c \ - pt-attr-getguardsize.c pt-attr-getinheritsched.c \ - pt-attr-getschedparam.c pt-attr-getschedpolicy.c pt-attr-getscope.c \ - pt-attr-getstack.c pt-attr-getstackaddr.c pt-attr-getstacksize.c \ - pt-attr-init.c pt-attr-setdetachstate.c pt-attr-setguardsize.c \ - pt-attr-setinheritsched.c pt-attr-setschedparam.c \ - pt-attr-setschedpolicy.c pt-attr-setscope.c pt-attr-setstack.c \ - pt-attr-setstackaddr.c pt-attr-setstacksize.c pt-attr.c \ - pt-barrier-destroy.c pt-barrier-init.c pt-barrier-wait.c \ - pt-barrier.c pt-barrierattr-destroy.c pt-barrierattr-init.c \ - pt-barrierattr-getpshared.c pt-barrierattr-setpshared.c \ - pt-destroy-specific.c pt-init-specific.c \ - pt-key-create.c pt-key-delete.c \ - pt-getspecific.c pt-setspecific.c \ - pt-once.c \ - pt-alloc.c \ - pt-create.c \ - pt-getattr.c \ - pt-pool-np.c \ - pt-equal.c \ - pt-dealloc.c \ - pt-detach.c \ - pt-exit.c \ - pt-initialize.c \ - pt-join.c \ - pt-self.c \ - pt-sigmask.c \ - pt-spin-inlines.c \ - pt-cleanup.c \ - pt-setcancelstate.c \ - pt-setcanceltype.c \ - pt-testcancel.c \ - pt-cancel.c \ - pt-mutexattr.c \ - pt-mutexattr-destroy.c pt-mutexattr-init.c \ - pt-mutexattr-getprioceiling.c pt-mutexattr-getprotocol.c \ - pt-mutexattr-getpshared.c pt-mutexattr-gettype.c \ - pt-mutexattr-setprioceiling.c pt-mutexattr-setprotocol.c \ - pt-mutexattr-setpshared.c pt-mutexattr-settype.c \ - pt-mutex-init.c pt-mutex-destroy.c \ - pt-mutex-lock.c pt-mutex-trylock.c pt-mutex-timedlock.c \ - pt-mutex-unlock.c \ - pt-mutex-transfer-np.c \ - pt-mutex-getprioceiling.c pt-mutex-setprioceiling.c \ - pt-rwlock-attr.c \ - pt-rwlockattr-init.c pt-rwlockattr-destroy.c \ - pt-rwlockattr-getpshared.c pt-rwlockattr-setpshared.c \ - pt-rwlock-init.c pt-rwlock-destroy.c \ - pt-rwlock-rdlock.c pt-rwlock-tryrdlock.c \ - pt-rwlock-trywrlock.c pt-rwlock-wrlock.c \ - pt-rwlock-timedrdlock.c pt-rwlock-timedwrlock.c \ - pt-rwlock-unlock.c \ - pt-cond.c \ - pt-condattr-init.c pt-condattr-destroy.c \ - pt-condattr-getclock.c pt-condattr-getpshared.c \ - pt-condattr-setclock.c pt-condattr-setpshared.c \ - pt-cond-destroy.c pt-cond-init.c \ - pt-cond-brdcast.c \ - pt-cond-signal.c \ - pt-cond-wait.c \ - pt-cond-timedwait.c \ - pt-stack-alloc.c \ - pt-thread-alloc.c \ - pt-thread-dealloc.c \ - pt-thread-start.c \ - pt-thread-halt.c \ - pt-startup.c \ - pt-getconcurrency.c pt-setconcurrency.c \ - pt-block.c \ - pt-timedblock.c \ - pt-wakeup.c \ - pt-docancel.c \ - pt-sysdep.c \ - pt-setup.c \ - pt-machdep.c \ - pt-spin.c \ - pt-sigstate-init.c \ - pt-sigstate-destroy.c \ - pt-sigstate.c \ - pt-atfork.c \ - pt-kill.c \ - pt-getcpuclockid.c \ - pt-getschedparam.c pt-setschedparam.c pt-setschedprio.c \ - pt-yield.c \ - sem-close.c sem-init.c sem-timedwait.c sem-wait.c \ - sem-destroy.c sem-open.c sem-trywait.c sem-getvalue.c \ - sem-post.c sem-unlink.c \ - \ - pt-setactivity-np.c \ - \ - kill.c \ - killpg.c \ - pt-kill-siginfo-np.c \ - raise.c \ - sigaction.c \ - sigaddset.c \ - sigaltstack.c \ - sigdelset.c \ - sigemptyset.c \ - sigfillset.c \ - sig-internal.c \ - sig-internal.h \ - siginterrupt.c \ - sigismember.c \ - signal.c \ - signal-dispatch.c \ - signal.h \ - sigpending.c \ - sigprocmask.c \ - sigsuspend.c \ - sigtimedwait.c \ - sigwait.c \ - sigwaiter.c \ - sigwaitinfo.c \ - signal-dispatch-lowlevel.c \ - sigprocmask.c - -libpthread_a_LDADD = -lrt diff --git a/TODO b/TODO index d7e54da..8b087b1 100644 --- a/TODO +++ b/TODO @@ -142,36 +142,3 @@ ** TLS Support for TLS is only implemented for Mach/Hurd (x86). - -* L4 Specific Issues -** Stack -*** Size - The stack size is defined to be a single page in - sysdeps/l4/hurd/pt-sysdep.h. Once we are able to setup regions, - this can be expanded to two megs as suggested by the Mach version. - Until then, however, we need to allocate too much physical memory. -*** Deallocation - __thread_stack_dealloc currently does not deallocate the stack. - For a proper implementation, we need a working memory manager. - -** Scheduling -*** yield - [L4] We cannot use yield for spin locks as L4 only yields to threads of - priority which are greater than or equal to the yielding thread. - If there are threads of lower priority, they are not considered; - the yielding thread is just placed back on the processor. This - introduces priority inversion quite quickly. L4 will not add a - priority suppression function call. As such, we need to do - an ipc with a small time out and then use exponential back off to - do the actual waiting. This sucks. - -** Stub code - [L4] We include in pt-start.c, however, we need a library - so we do not have to play with the corba stuff. - -** Root server and Task server -*** Getting the tids. - pt-start.c has a wonderfully evil hack that will never work well. - -** Paging - We set the pager to the root server. Evil. Fix this in pt-start.c. diff --git a/headers.m4 b/headers.m4 deleted file mode 100644 index 5a58b9b..0000000 --- a/headers.m4 +++ /dev/null @@ -1,45 +0,0 @@ -# headers.m4 - Autoconf snippets to install links for header files. -# Copyright 2003, 2008 Free Software Foundation, Inc. -# Written by Marcus Brinkmann . -# -# This file is free software; as a special exception the author gives -# unlimited permission to copy and/or distribute it, with or without -# modifications, as long as this notice is preserved. -# -# This file is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the -# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - -AC_CONFIG_LINKS([ - sysroot/include/pthread.h:libpthread/include/pthread.h - sysroot/include/pthread/pthread.h:libpthread/include/pthread/pthread.h - sysroot/include/pthread/pthreadtypes.h:libpthread/include/pthread/pthreadtypes.h - sysroot/include/bits/memory.h:libpthread/sysdeps/${arch}/bits/memory.h - sysroot/include/bits/spin-lock.h:libpthread/sysdeps/${arch}/bits/spin-lock.h - sysroot/include/bits/spin-lock-inline.h:libpthread/sysdeps/${arch}/bits/spin-lock-inline.h - sysroot/include/bits/pthreadtypes.h:libpthread/sysdeps/generic/bits/pthreadtypes.h - sysroot/include/bits/barrier-attr.h:libpthread/sysdeps/generic/bits/barrier-attr.h - sysroot/include/bits/barrier.h:libpthread/sysdeps/generic/bits/barrier.h - sysroot/include/bits/cancelation.h:libpthread/sysdeps/generic/bits/cancelation.h - sysroot/include/bits/condition-attr.h:libpthread/sysdeps/generic/bits/condition-attr.h - sysroot/include/bits/condition.h:libpthread/sysdeps/generic/bits/condition.h - sysroot/include/bits/mutex-attr.h:libpthread/sysdeps/generic/bits/mutex-attr.h - sysroot/include/bits/mutex.h:libpthread/sysdeps/generic/bits/mutex.h - sysroot/include/bits/once.h:libpthread/sysdeps/generic/bits/once.h - sysroot/include/bits/pthread.h:libpthread/sysdeps/generic/bits/pthread.h - sysroot/include/bits/rwlock-attr.h:libpthread/sysdeps/generic/bits/rwlock-attr.h - sysroot/include/bits/rwlock.h:libpthread/sysdeps/generic/bits/rwlock.h - sysroot/include/bits/thread-attr.h:libpthread/sysdeps/generic/bits/thread-attr.h - sysroot/include/bits/thread-barrier.h:libpthread/sysdeps/generic/bits/thread-barrier.h - sysroot/include/bits/thread-specific.h:libpthread/sysdeps/generic/bits/thread-specific.h - sysroot/include/bits/pthread-np.h:libpthread/sysdeps/l4/hurd/bits/pthread-np.h - sysroot/include/semaphore.h:libpthread/include/semaphore.h - sysroot/include/bits/semaphore.h:libpthread/sysdeps/generic/bits/semaphore.h - sysroot/include/signal.h:libpthread/signal/signal.h -]) - -AC_CONFIG_COMMANDS_POST([ - mkdir -p sysroot/lib libpthread && - ln -sf ../../libpthread/libpthread.a sysroot/lib/ && - touch libpthread/libpthread.a -]) diff --git a/signal/README b/signal/README index 5487e2e..259ec4c 100644 --- a/signal/README +++ b/signal/README @@ -2,3 +2,6 @@ This directory provides a signal implementation, which is appropriate for operating systems where signals are managed at user-level. It is up to the run-time to catch the signals and forward them to the implementation via, e.g., the pthread_kill_info_np call. + +This implementation was once used for a native port running on L4, but is not +currently used in any libpthread port bundled in this release. diff --git a/sysdeps/l4/bits/pthread-np.h b/sysdeps/l4/bits/pthread-np.h deleted file mode 100644 index 6a02bdc..0000000 --- a/sysdeps/l4/bits/pthread-np.h +++ /dev/null @@ -1,35 +0,0 @@ -/* Non-portable functions. L4 version. - Copyright (C) 2003, 2007 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with the GNU C Library; see the file COPYING.LIB. If not, - write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. */ - -/* - * Never include this file directly; use or instead. - */ - -#ifndef _BITS_PTHREAD_NP_H -#define _BITS_PTHREAD_NP_H 1 - -#include - -/* Add the thread TID to the internal kernel thread pool. */ -extern int pthread_pool_add_np (l4_thread_id_t tid); - -/* Get the first thread from the pool. */ -extern l4_thread_id_t pthread_pool_get_np (void); - -#endif /* bits/pthread-np.h */ diff --git a/sysdeps/l4/hurd/bits/pthread-np.h b/sysdeps/l4/hurd/bits/pthread-np.h deleted file mode 100644 index a90793d..0000000 --- a/sysdeps/l4/hurd/bits/pthread-np.h +++ /dev/null @@ -1,31 +0,0 @@ -/* Non-portable functions. Viengoos version. - Copyright (C) 2008 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with the GNU C Library; see the file COPYING.LIB. If not, - write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. */ - -/* - * Never include this file directly; use or instead. - */ - -#ifndef _BITS_PTHREAD_NP_H -#define _BITS_PTHREAD_NP_H 1 - -#include - -int pthread_setactivity_np (addr_t activity); - -#endif /* bits/pthread-np.h */ diff --git a/sysdeps/l4/hurd/ia32/pt-machdep.c b/sysdeps/l4/hurd/ia32/pt-machdep.c deleted file mode 100644 index dbf5cd7..0000000 --- a/sysdeps/l4/hurd/ia32/pt-machdep.c +++ /dev/null @@ -1,20 +0,0 @@ -/* Machine dependent pthreads code. Hurd/i386 version. - Copyright (C) 2000 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with the GNU C Library; see the file COPYING.LIB. If not, - write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. */ - -/* Nothing to do. */ diff --git a/sysdeps/l4/hurd/ia32/pt-setup.c b/sysdeps/l4/hurd/ia32/pt-setup.c deleted file mode 100644 index de7359c..0000000 --- a/sysdeps/l4/hurd/ia32/pt-setup.c +++ /dev/null @@ -1,118 +0,0 @@ -/* Setup thread stack. Viengoos/i386 version. - Copyright (C) 2000, 2002, 2008 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with the GNU C Library; see the file COPYING.LIB. If not, - write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. */ - -#include - -#include -#include -#include - -/* The stack layout used on the i386 is: - - ----------------- - | ARG | - ----------------- - | START_ROUTINE | - ----------------- - | Return address | - ----------------- <- %ebp - | Frame pointer | - ----------------- - - We do the following: setup the stack to return to the entry routine. - - -*/ - -/* The stack contains: - - arg - start_routine - 0 <- fake return address - C entry_point -*/ -extern uintptr_t _pthread_entry_point; -__asm__ ("\n\ - .globl _pthread_entry_point, __pthread_entry_point\n\ -_pthread_entry_point:\n\ -__pthread_entry_point:\n\ - pushl $0\n\ - popf\n\ -\n\ - xor %ebp, %ebp\n\ - ret\n"); - -/* Set up the stack for THREAD, such that it appears as if - START_ROUTINE and ARG were passed to the new thread's entry-point. - Return the stack pointer for the new thread. We also take the - opportunity to install THREAD in our utcb. */ -static void * -stack_setup (struct __pthread *thread, - void *(*start_routine)(void *), void *arg, - void (*entry_point)(struct __pthread *, void *(*)(void *), void *)) -{ - uintptr_t *top; - - /* Calculate top of the new stack. */ - top = (uintptr_t *) ((uintptr_t) thread->stackaddr + thread->stacksize); - - /* Align on 0x10 for MMX operations. */ - top = (uintptr_t) top & ~0xf; - - if (start_routine) - { - /* Set up call frame. */ - *--top = (uintptr_t) arg; /* Argument to START_ROUTINE. */ - *--top = (uintptr_t) start_routine; - *--top = (uintptr_t) thread; - *--top = 0; /* Fake return address. */ - *--top = (uintptr_t) entry_point; - } - - return top; -} - -int -__pthread_setup (struct __pthread *thread, - void (*entry_point)(struct __pthread *, void *(*)(void *), void *), - void *(*start_routine)(void *), void *arg) -{ - thread->mcontext.pc = (void *) &_pthread_entry_point; - thread->mcontext.sp = (void *) stack_setup (thread, start_routine, arg, - entry_point); - - if (__pthread_num_threads == 1) - return 0; - - assert (! ADDR_IS_VOID (thread->exception_area[0])); - - struct exception_page *exception_page = thread->exception_area_va; - - /* SP is set to the end of the exception area minus one word, which - is the location of the exception page. */ - exception_page->exception_handler_sp - = (uintptr_t) thread->exception_area_va + EXCEPTION_AREA_SIZE; - exception_page->exception_handler_sp -= sizeof (void *); - * (void **) exception_page->exception_handler_sp = thread->exception_area_va; - - exception_page->exception_handler_ip = (uintptr_t) &exception_handler_entry; - exception_page->exception_handler_end = (uintptr_t) &exception_handler_end; - - return 0; -} diff --git a/sysdeps/l4/hurd/ia32/signal-dispatch-lowlevel.c b/sysdeps/l4/hurd/ia32/signal-dispatch-lowlevel.c deleted file mode 100644 index 37ef821..0000000 --- a/sysdeps/l4/hurd/ia32/signal-dispatch-lowlevel.c +++ /dev/null @@ -1,213 +0,0 @@ -/* signal-dispatch-lowlevel.c - ia32 specific signal handling functions. - Copyright (C) 2008 Free Software Foundation, Inc. - Written by Neal H. Walfield . - - This file is part of the GNU Hurd. - - The GNU Hurd is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public License - as published by the Free Software Foundation; either version 3 of - the License, or (at your option) any later version. - - The GNU Hurd is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this program. If not, see - . */ - -#include -#include - -#include -#include -#include -#include - -extern char _signal_dispatch_entry; -/* - 0(%esp) a pointer to the thread's struct signal_state. - - 4(%esp) a pointer to a siginfo_t. - - 8(%esp) is a pointer to the ss_flags field (or NULL). - - 12(%esp)+4 is the value of the sp when the thread was interrupted (intr_sp) - - 0(intr_sp) is the value of the ip when the thread was interrupted. - - 16(%esp) - 16 byte register save area -*/ -__asm__ ("\n\ - .globl _signal_dispatch_entry\n\ -_signal_dispatch_entry:\n\ - /* Save caller saved registers (16 bytes). */\n\ - mov %eax, 16(%esp)\n\ - mov %ecx, 16+4(%esp)\n\ - mov %edx, 16+8(%esp)\n\ - pushf\n\ - popl %eax\n\ - mov %eax, 16+12(%esp)\n\ -\n\ - /* Reset EFLAGS. */\n\ - cld\n\ - call signal_dispatch\n\ -\n\ - /* Get the original stack and begin restoration. */\n\ - mov 12(%esp), %edx\n\ -\n\ - /* Move the saved registers to the user stack. */\n\ - sub $16, %edx\n\ - /* eax. */\n\ - mov 16+0(%esp), %ecx\n\ - mov %ecx, 0(%edx)\n\ - /* ecx. */\n\ - mov 16+4(%esp), %ecx\n\ - mov %ecx, 4(%edx)\n\ - /* edx. */\n\ - mov 16+8(%esp), %ecx\n\ - mov %ecx, 8(%edx)\n\ - /* eflags. */\n\ - mov 16+12(%esp), %ecx\n\ - mov %ecx, 12(%edx)\n\ -\n\ - /* Get the pointer to the sigaltstack flags. */\n\ - mov 8(%esp), %ecx\n\ -\n\ - /* Restore the user stack. */\n\ - mov %edx, %esp\n\ -\n\ - /* Clear the SA_ONSTACK flag. */\n\ - and %ecx, %ecx\n\ - jz after_clear\n\ - lock; and $~1, 0(%ecx)\n\ -after_clear:\n\ -\n\ - /* Restore eflags, the scratch regs and the original sp and ip. */\n\ - popl %eax\n\ - popl %ecx\n\ - popl %edx\n\ - popf\n\ - ret\n"); - -extern char _signal_dispatch_entry_self; -/* - 0(%esp) is the return address (we ignore it) - - 4(%esp) is the sp to load - - Since we are returning to signal_dispatch_lowlevel's caller, we - also need to restore its frame pointer. */ -__asm__ ("\n\ - .globl _signal_dispatch_entry_self\n\ -_signal_dispatch_entry_self:\n\ - mov 0(%ebp), %ebp\n\ - mov 4(%esp), %esp\n\ - jmp _signal_dispatch_entry\n"); - -void -signal_dispatch_lowlevel (struct signal_state *ss, pthread_t tid, - siginfo_t si) -{ - assert (pthread_mutex_trylock (&ss->lock) == EBUSY); - - struct __pthread *thread = __pthread_getid (tid); - - bool self = tid == pthread_self (); - - uintptr_t intr_sp; - - if (self) - { - /* The return address is just before the first argument. */ - intr_sp = (uintptr_t) &ss - 4; - assert (* (void **) intr_sp == __builtin_return_address (0)); - } - else - { - struct hurd_thread_exregs_in in; - memset (&in, 0, sizeof (in)); - struct hurd_thread_exregs_out out; - - error_t err; - err = rm_thread_exregs (ADDR_VOID, thread->object, - HURD_EXREGS_STOP | HURD_EXREGS_ABORT_IPC - | HURD_EXREGS_GET_REGS, - in, &out); - if (err) - panic ("Failed to modify thread " ADDR_FMT, - ADDR_PRINTF (thread->object)); - - intr_sp = out.sp; - - /* Push the ip on the user stack. */ - intr_sp -= 4; - * (uintptr_t *) intr_sp = out.ip; - } - - bool altstack = false; - uintptr_t sp; - if (! (ss->actions[si.si_signo - 1].sa_flags & SA_ONSTACK) - || (ss->stack.ss_flags & SS_DISABLE) - || (ss->stack.ss_flags & SS_ONSTACK)) - { - assert (! self); - sp = intr_sp; - } - else - { - /* The stack grows down. */ - sp = (uintptr_t) ss->stack.ss_sp + ss->stack.ss_size; - - /* We know intimately that SS_ONSTACK is the least significant - bit. */ - assert (SS_ONSTACK == 1); - atomic_bit_set (&ss->stack.ss_flags, 0); - - altstack = true; - } - - /* Set up the call frame for a call to signal_dispatch_entry. */ - - /* Allocate a siginfo structure on the stack. */ - sp = sp - sizeof (siginfo_t); - siginfo_t *sip = (void *) sp; - /* Copy the user supplied values. */ - *sip = si; - - /* Add space for the 4 caller saved registers. */ - sp -= 4 * sizeof (uintptr_t); - - /* Save the interrupted sp. */ - sp -= 4; - * (uintptr_t *) sp = intr_sp; - - /* Address of the ss_flags. */ - sp -= 4; - if (altstack) - * (uintptr_t *) sp = (uintptr_t) &ss->stack.ss_flags; - else - * (uintptr_t *) sp = 0; - - /* Push the parameters to signal_dispatch. */ - - /* signal info structure. */ - sp -= 4; - * (uintptr_t *) sp = (uintptr_t) sip; - - /* The ss. */ - sp -= 4; - * (uintptr_t *) sp = (uintptr_t) ss; - - pthread_mutex_transfer_np (&ss->lock, tid); - - if (self) - ((void (*) (uintptr_t)) &_signal_dispatch_entry_self) ((uintptr_t) sp); - else - { - struct hurd_thread_exregs_in in; - struct hurd_thread_exregs_out out; - - in.sp = sp; - in.ip = (uintptr_t) &_signal_dispatch_entry; - - rm_thread_exregs (ADDR_VOID, thread->object, - HURD_EXREGS_SET_SP_IP - | HURD_EXREGS_START | HURD_EXREGS_ABORT_IPC, - in, &out); - } -} diff --git a/sysdeps/l4/hurd/powerpc/pt-machdep.c b/sysdeps/l4/hurd/powerpc/pt-machdep.c deleted file mode 100644 index 754d203..0000000 --- a/sysdeps/l4/hurd/powerpc/pt-machdep.c +++ /dev/null @@ -1,20 +0,0 @@ -/* Machine dependent pthreads code. Hurd/PowerPC version. - Copyright (C) 2003 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with the GNU C Library; see the file COPYING.LIB. If not, - write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. */ - -/* Nothing to do. */ diff --git a/sysdeps/l4/hurd/powerpc/pt-setup.c b/sysdeps/l4/hurd/powerpc/pt-setup.c deleted file mode 100644 index d309216..0000000 --- a/sysdeps/l4/hurd/powerpc/pt-setup.c +++ /dev/null @@ -1,96 +0,0 @@ -/* Setup thread stack. Hurd/PowerPC version. - Copyright (C) 2003 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with the GNU C Library; see the file COPYING.LIB. If not, - write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. */ - -#include - -#include - -/* Arguments is passed in registers on the PowerPC. But the - exchange registers syscall only allows us to set the PC and the - stack pointer so we put the entry point and start function on - the stack. */ -struct start_info -{ - void (*entry_point) (void *(*)(void *), void *); - struct __pthread *self; - void *(*start_routine) (void *); - void *arg; -}; - -void first_entry_1 (void); - -/* Stage 1 entry function. The start_info structure is inlined on the - stack. Put values into registers and call entry function. */ -asm (" ;\ -first_entry_1: ;\ - lwz 0, 0(1) ;\ - lwz 3, 4(1) ;\ - lwz 4, 8(1) ;\ - lwz 5, 12(1) ;\ - mtctr 0 ;\ - bctrl ;\ -"); - -/* Set up the stack for THREAD, such that it appears as if - START_ROUTINE and ARG were passed to the new thread's entry-point. - Return the stack pointer for the new thread. We also take the - opportunity to install THREAD in our utcb. */ -static void * -stack_setup (struct __pthread *thread, - void (*entry_point)(struct __pthread *, void *(*)(void *), void *), - void *(*start_routine)(void *), void *arg) -{ - l4_word_t *top; - - /* Calculate top of the new stack. */ - top = (l4_word_t *) ((l4_word_t) thread->stackaddr + thread->stacksize); - - /* Initial stack frame. */ - top[-4] = 0; - top = top - 4; - - if (start_routine) - { - struct start_info *info = ((struct start_info *) top) - 1; - - info->entry_point = entry_point; - info->self = thread; - info->start_routine = start_routine; - info->arg = arg; - return (void *) info; - } - return top; -} - -int -__pthread_setup (struct __pthread *thread, - void (*entry_point)(struct __pthread *, void *(*)(void *), void *), - void *(*start_routine)(void *), void *arg) -{ - thread->mcontext.pc = first_entry_1; - thread->mcontext.sp = stack_setup (thread, entry_point, - start_routine, arg); - - if (l4_same_threads (thread->threadid, l4_myself ())) - l4_set_user_defined_handle ((l4_word_t) thread); - else - l4_set_user_defined_handle_of (thread->threadid, - (l4_word_t) thread); - return 0; -} diff --git a/sysdeps/l4/hurd/pt-block.c b/sysdeps/l4/hurd/pt-block.c deleted file mode 100644 index 2315b1c..0000000 --- a/sysdeps/l4/hurd/pt-block.c +++ /dev/null @@ -1,30 +0,0 @@ -/* Block a thread. Viengoos version. - Copyright (C) 2008 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with the GNU C Library; see the file COPYING.LIB. If not, - write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. */ - -#include - -#include -#include - -/* Block THREAD. */ -void -__pthread_block (struct __pthread *thread) -{ - futex_wait (&thread->threadid, thread->threadid); -} diff --git a/sysdeps/l4/hurd/pt-kill.c b/sysdeps/l4/hurd/pt-kill.c deleted file mode 100644 index c72e82f..0000000 --- a/sysdeps/l4/hurd/pt-kill.c +++ /dev/null @@ -1,3 +0,0 @@ -/* The generic version is good enough for us, however, the generic - Hurd on Mach version supplies a specialized version */ -#include "../generic/pt-kill.c" diff --git a/sysdeps/l4/hurd/pt-setactivity-np.c b/sysdeps/l4/hurd/pt-setactivity-np.c deleted file mode 100644 index f2f0723..0000000 --- a/sysdeps/l4/hurd/pt-setactivity-np.c +++ /dev/null @@ -1,39 +0,0 @@ -/* Set a thread's activity activity. Viengoos version. - Copyright (C) 2008 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with the GNU C Library; see the file COPYING.LIB. If not, - write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. */ - -#include - -#include -#include - -int -pthread_setactivity_np (addr_t activity) -{ - struct __pthread *self = _pthread_self (); - - struct hurd_thread_exregs_in in; - in.activity = activity; - - struct hurd_thread_exregs_out out; - int err = rm_thread_exregs (ADDR_VOID, self->object, - HURD_EXREGS_SET_ACTIVITY, - in, &out); - - return err; -} diff --git a/sysdeps/l4/hurd/pt-sigstate-destroy.c b/sysdeps/l4/hurd/pt-sigstate-destroy.c deleted file mode 100644 index 997a036..0000000 --- a/sysdeps/l4/hurd/pt-sigstate-destroy.c +++ /dev/null @@ -1,28 +0,0 @@ -/* Destroy the signal state. Hurd on L4 version. - Copyright (C) 2002 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with the GNU C Library; see the file COPYING.LIB. If not, - write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. */ - -#include - -#include - -void -__pthread_sigstate_destroy (struct __pthread *thread) -{ - /* Nothing to do. */ -} diff --git a/sysdeps/l4/hurd/pt-sigstate-init.c b/sysdeps/l4/hurd/pt-sigstate-init.c deleted file mode 100644 index 4c40fdb..0000000 --- a/sysdeps/l4/hurd/pt-sigstate-init.c +++ /dev/null @@ -1,44 +0,0 @@ -/* Initialize the signal state. Hurd on L4 version. - Copyright (C) 2003, 2008 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with the GNU C Library; see the file COPYING.LIB. If not, - write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. */ - -#include - -#include -#include - -error_t -__pthread_sigstate_init (struct __pthread *thread) -{ - struct signal_state *ss = &thread->ss; - - memset (ss, 0, sizeof (*ss)); - - ss->stack.ss_flags = SS_DISABLE; - - int signo; - for (signo = 1; signo < NSIG; ++signo) - { - sigemptyset (&ss->actions[signo - 1].sa_mask); - ss->actions[signo - 1].sa_flags = SA_RESTART; - ss->actions[signo - 1].sa_handler = SIG_DFL; - ss->lock = (pthread_mutex_t) PTHREAD_MUTEX_INITIALIZER; - } - - return 0; -} diff --git a/sysdeps/l4/hurd/pt-sigstate.c b/sysdeps/l4/hurd/pt-sigstate.c deleted file mode 100644 index 66dd08c..0000000 --- a/sysdeps/l4/hurd/pt-sigstate.c +++ /dev/null @@ -1,81 +0,0 @@ -/* Set a thread's signal state. Hurd on L4 version. - Copyright (C) 2002, 2005, 2008 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with the GNU C Library; see the file COPYING.LIB. If not, - write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. */ - -#include -#include -#include - -#include - -error_t -__pthread_sigstate (struct __pthread *thread, int how, - const sigset_t *set, sigset_t *oset, - int clear_pending) -{ - struct signal_state *ss = &thread->ss; - pthread_mutex_lock (&ss->lock); - - if (oset) - *oset = ss->blocked; - - if (set) - { - /* Mask out SIGKILL and SIGSTOP. */ - sigset_t s = *set; - sigdelset (&s, SIGKILL); - sigdelset (&s, SIGSTOP); - - switch (how) - { - case SIG_BLOCK: - ss->blocked |= s; - break; - case SIG_UNBLOCK: - ss->blocked &= ~s; - break; - case SIG_SETMASK: - ss->blocked = s; - break; - default: - errno = EINVAL; - pthread_mutex_unlock (&ss->lock); - return -1; - } - } - - if (clear_pending) - sigemptyset (&ss->pending); - - /* A "signal shall remain pending until it is unblocked" (2.4.1). - - "If there are any pending unblocked signals after the call to - sigprocmask(), at least one of those signals shall be delivered - before the call to sigprocmask() returns." - (pthread_sigmask). */ - sigset_t extant = ~ss->blocked & ss->pending; - if (! extant) - extant = ~ss->blocked & process_pending; - - pthread_mutex_unlock (&ss->lock); - - if (extant) - raise (l4_lsb64 (extant)); - - return 0; -} diff --git a/sysdeps/l4/hurd/pt-startup.c b/sysdeps/l4/hurd/pt-startup.c deleted file mode 100644 index b6461de..0000000 --- a/sysdeps/l4/hurd/pt-startup.c +++ /dev/null @@ -1,30 +0,0 @@ -/* Thread initialization. Hurd/L4 version. - Copyright (C) 2007 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with the GNU C Library; see the file COPYING.LIB. If not, - write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. */ - -#include -#include - -#include - -void -__pthread_startup (void) -{ - struct __pthread *pthread = _pthread_self (); - pthread->threadid = l4_myself (); -} diff --git a/sysdeps/l4/hurd/pt-sysdep.c b/sysdeps/l4/hurd/pt-sysdep.c deleted file mode 100644 index 1df6c2e..0000000 --- a/sysdeps/l4/hurd/pt-sysdep.c +++ /dev/null @@ -1,61 +0,0 @@ -/* System dependent pthreads code. Hurd version. - Copyright (C) 2000, 2008 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with the GNU C Library; see the file COPYING.LIB. If not, - write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. */ - -#include -#include -#include - -#include - -int -sched_yield (void) -{ - l4_yield (); - return 0; -} - -/* Forward. */ -static void init_routine (void (*) (void *), void *) - __attribute__ ((noreturn)); - -/* OK, the name of this variable isn't really appropriate, but I don't - want to change it yet. */ -void (*_pthread_init_routine)(void (*) (void *), void *) = &init_routine; - -/* This function is called from the Hurd-specific startup code. It - should return a new stack pointer for the main thread. The caller - will switch to this new stack before doing anything serious. */ -static void -init_routine (void (*entry) (void *), void *arg) -{ - /* Initialize the library. */ - __pthread_init(); - - struct __pthread *thread; - int err; - - /* Create the pthread structure for the main thread (i.e. us). */ - err = __pthread_create_internal (&thread, 0, - (void *(*)(void *)) entry, arg); - assert_perror (err); - - /* Switch stacks. */ - l4_start_sp_ip (l4_myself (), thread->mcontext.sp, - thread->mcontext.pc); -} diff --git a/sysdeps/l4/hurd/pt-sysdep.h b/sysdeps/l4/hurd/pt-sysdep.h deleted file mode 100644 index 08bcd14..0000000 --- a/sysdeps/l4/hurd/pt-sysdep.h +++ /dev/null @@ -1,61 +0,0 @@ -/* Internal definitions for pthreads library. - Copyright (C) 2000, 2002, 2005, 2007, 2008 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with the GNU C Library; see the file COPYING.LIB. If not, - write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. */ - -#ifndef _PT_SYSDEP_H -#define _PT_SYSDEP_H 1 - -#include -#include -#include - -/* XXX */ -#define _POSIX_THREAD_THREADS_MAX 64 - -/* The default stack size: 2MB. */ -#define PTHREAD_STACK_DEFAULT (2 * 1024 * 1024) - -#include - -#define EXCEPTION_AREA_SIZE EXCEPTION_STACK_SIZE -#define EXCEPTION_AREA_SIZE_LOG2 EXCEPTION_STACK_SIZE_LOG2 -/* The exception page is the first object. */ -#define EXCEPTION_PAGE 0 - -#define PTHREAD_SYSDEP_MEMBERS \ - addr_t object; \ - l4_thread_id_t threadid; \ - addr_t exception_area[EXCEPTION_AREA_SIZE / PAGESIZE]; \ - void *exception_area_va; \ - l4_word_t my_errno; - -extern inline struct __pthread * -__attribute__((__always_inline__)) -_pthread_self (void) -{ - return (struct __pthread *) l4_user_defined_handle (); -} - -extern inline void -__attribute__((__always_inline__)) -__pthread_stack_dealloc (void *stackaddr, size_t stacksize) -{ - munmap (stackaddr, stacksize); -} - -#endif /* pt-sysdep.h */ diff --git a/sysdeps/l4/hurd/pt-thread-alloc.c b/sysdeps/l4/hurd/pt-thread-alloc.c deleted file mode 100644 index ada7b3b..0000000 --- a/sysdeps/l4/hurd/pt-thread-alloc.c +++ /dev/null @@ -1,95 +0,0 @@ -/* Allocate kernel thread. Viengoos version. - Copyright (C) 2007, 2008 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with the GNU C Library; see the file COPYING.LIB. If not, - write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. */ - -#include -#include -#include - -#include -#include -#include -#include - -#include - -extern struct hurd_startup_data *__hurd_startup_data; - -extern addr_t meta_data_activity; - -int -__pthread_thread_alloc (struct __pthread *thread) -{ - /* The main thread is already running of course. */ - if (__pthread_num_threads == 1) - { - thread->object = __hurd_startup_data->thread; - thread->threadid = l4_myself (); - return 0; - } - else - { - addr_t exception_area = as_alloc (EXCEPTION_AREA_SIZE_LOG2, 1, true); - - thread->exception_area_va - = ADDR_TO_PTR (addr_extend (exception_area, - 0, EXCEPTION_AREA_SIZE_LOG2)); - - int i; - for (i = 0; i < EXCEPTION_AREA_SIZE / PAGESIZE; i ++) - { - addr_t slot = addr_chop (PTR_TO_ADDR (thread->exception_area_va - + i * PAGESIZE), - PAGESIZE_LOG2); - as_ensure (slot); - - struct storage storage = storage_alloc (ADDR_VOID, cap_page, - STORAGE_LONG_LIVED, - OBJECT_POLICY_DEFAULT, - slot); - if (ADDR_IS_VOID (storage.addr)) - { - int j; - for (j = 0; j < i; j ++) - storage_free (thread->exception_area[j], false); - as_free (exception_area, false); - return EAGAIN; - } - - thread->exception_area[i] = storage.addr; - } - - struct storage storage; - storage = storage_alloc (meta_data_activity, cap_thread, - /* Threads are rarely shortly lived. */ - STORAGE_MEDIUM_LIVED, OBJECT_POLICY_DEFAULT, - ADDR_VOID); - if (ADDR_IS_VOID (storage.addr)) - { - int j; - for (j = 0; j < EXCEPTION_AREA_SIZE / PAGESIZE; j ++) - storage_free (thread->exception_area[j], false); - as_free (exception_area, false); - return EAGAIN; - } - - thread->object = storage.addr; - } - - return 0; -} diff --git a/sysdeps/l4/hurd/pt-thread-halt.c b/sysdeps/l4/hurd/pt-thread-halt.c deleted file mode 100644 index 98fefaa..0000000 --- a/sysdeps/l4/hurd/pt-thread-halt.c +++ /dev/null @@ -1,104 +0,0 @@ -/* Deallocate the kernel thread resources. Viengoos version. - Copyright (C) 2007, 2008 Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with the GNU C Library; see the file COPYING.LIB. If not, - write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. */ - -#include -#include - -#include - -#include -#include -#include -#include - -/* If we try to deallocate our self, we will end up causing a - deadlock. Thus, when a thread tries to free itself, we add it - here. The next thread to free a thread will free it. */ -ss_mutex_t saved_object_lock; -static addr_t saved_object; - -void -__pthread_thread_halt (struct __pthread *thread, int need_dealloc) -{ - /* We may deallocate THREAD. First save any data we need. */ - - addr_t exception_area[EXCEPTION_AREA_SIZE / PAGESIZE]; - memcpy (exception_area, thread->exception_area, - sizeof (thread->exception_area)); - memset (thread->exception_area, 0, sizeof (thread->exception_area)); - - void *va = thread->exception_area_va; - - addr_t object = thread->object; - l4_thread_id_t tid = thread->threadid; - - if (need_dealloc) - __pthread_dealloc (thread); - - /* The THREAD data structure is no longer valid. */ - thread = NULL; - - /* Deallocate any saved object. */ - ss_mutex_lock (&saved_object_lock); - if (! ADDR_IS_VOID (saved_object)) - { - storage_free (saved_object, false); - saved_object = ADDR_VOID; - } - ss_mutex_unlock (&saved_object_lock); - - /* Free the exception area. */ - - /* Clean up the exception page. */ - exception_page_cleanup - (ADDR_TO_PTR (addr_extend (exception_area[EXCEPTION_PAGE], - 0, PAGESIZE_LOG2))); - - /* Free the storage. */ - int i; - for (i = 0; i < EXCEPTION_AREA_SIZE / PAGESIZE; i ++) - { - assert (! ADDR_IS_VOID (exception_area[i])); - storage_free (exception_area[i], false); - } - - /* And the address space. */ - as_free (addr_chop (PTR_TO_ADDR (va), EXCEPTION_AREA_SIZE_LOG2), false); - - if (tid == l4_myself ()) - /* If we try to storage_free (storage.addr), we will freeze in the - middle. That's no good. We set SAVED_OBJECT to our thread - object and the next thread in will free us. */ - { - ss_mutex_lock (&saved_object_lock); - saved_object = object; - ss_mutex_unlock (&saved_object_lock); - } - else - storage_free (object, false); - - if (tid == l4_myself ()) - { - l4_send_timeout (l4_myself (), L4_NEVER); - panic ("Failed to stop thread %x.%x!", - l4_thread_no (l4_myself ()), l4_version (l4_myself ())); - } - else - thread_stop (object); -} diff --git a/sysdeps/l4/hurd/pt-thread-start.c b/sysdeps/l4/hurd/pt-thread-start.c deleted file mode 100644 index 9db399c..0000000 --- a/sysdeps/l4/hurd/pt-thread-start.c +++ /dev/null @@ -1,70 +0,0 @@ -/* Start thread. L4 version. - Copyright (C) 2007 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with the GNU C Library; see the file COPYING.LIB. If not, - write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. */ - -#include -#include -#include -#include -#include - -#include - -int -__pthread_thread_start (struct __pthread *thread) -{ - error_t err; - - if (__pthread_num_threads == 1) - /* The main thread is already running of course. */ - { - assert (__pthread_total == 1); - assert (l4_is_thread_equal (l4_myself (), thread->threadid)); - l4_set_user_defined_handle ((l4_word_t) thread); - } - else - { - struct hurd_thread_exregs_in in; - struct hurd_thread_exregs_out out; - - in.aspace = ADDR (0, 0); - in.aspace_cap_properties = CAP_PROPERTIES_VOID; - in.aspace_cap_properties_flags = CAP_COPY_COPY_SOURCE_GUARD; - - in.activity = ADDR_VOID; - - in.exception_page = addr_chop (PTR_TO_ADDR (thread->exception_area_va), - PAGESIZE_LOG2); - - in.sp = (l4_word_t) thread->mcontext.sp; - in.ip = (l4_word_t) thread->mcontext.pc; - - in.user_handle = (l4_word_t) thread; - err = rm_thread_exregs (ADDR_VOID, thread->object, - HURD_EXREGS_SET_ASPACE - | HURD_EXREGS_SET_ACTIVITY - | HURD_EXREGS_SET_EXCEPTION_PAGE - | HURD_EXREGS_SET_SP_IP - | HURD_EXREGS_SET_USER_HANDLE - | HURD_EXREGS_START - | HURD_EXREGS_ABORT_IPC, - in, &out); - assert (err == 0); - } - return 0; -} diff --git a/sysdeps/l4/hurd/pt-wakeup.c b/sysdeps/l4/hurd/pt-wakeup.c deleted file mode 100644 index e568a6f..0000000 --- a/sysdeps/l4/hurd/pt-wakeup.c +++ /dev/null @@ -1,46 +0,0 @@ -/* Wakeup a thread. Viengoos version. - Copyright (C) 2008 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with the GNU C Library; see the file COPYING.LIB. If not, - write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. */ - -#include - -#include -#include -#include - -/* Wakeup THREAD. */ -void -__pthread_wakeup (struct __pthread *thread) -{ - /* We need to loop here as the blocked thread may not yet be - blocked! Here's what happens when a thread blocks: it registers - itself as blocked, drops the relevant lock and then actually - blocks (via __pthread_block). This means that after dropping the - lock and before blocking, it may be interrupted and another - thread may try to wake it. */ - long ret; - do - { - ret = futex_wake (&thread->threadid, INT_MAX); - assertx (ret <= 1, "tid: %x, ret: %d", thread->threadid, ret); - - if (ret == 0) - l4_thread_switch (thread->threadid); - } - while (ret == 0); -} diff --git a/sysdeps/l4/hurd/sig-sysdep.h b/sysdeps/l4/hurd/sig-sysdep.h deleted file mode 100644 index 33e1385..0000000 --- a/sysdeps/l4/hurd/sig-sysdep.h +++ /dev/null @@ -1,69 +0,0 @@ -/* sig-sysdep.h - Hurd system specific header file. - Copyright (C) 2008 Free Software Foundation, Inc. - Written by Neal H. Walfield . - - This file is part of the GNU Hurd. - - The GNU Hurd is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public License - as published by the Free Software Foundation; either version 3 of - the License, or (at your option) any later version. - - The GNU Hurd is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this program. If not, see - . */ - -#include -#include - -struct utcb -{ - l4_word_t saved_sender; - l4_word_t saved_receiver; - l4_word_t saved_timeout; - l4_word_t saved_error_code; - l4_word_t saved_flags; - l4_word_t saved_br0; - l4_msg_t saved_message; -}; - -static inline void -utcb_state_save (struct utcb *buffer) -{ - l4_word_t *utcb = _L4_utcb (); - - buffer->saved_sender = utcb[_L4_UTCB_SENDER]; - buffer->saved_receiver = utcb[_L4_UTCB_RECEIVER]; - buffer->saved_timeout = utcb[_L4_UTCB_TIMEOUT]; - buffer->saved_error_code = utcb[_L4_UTCB_ERROR_CODE]; - buffer->saved_flags = utcb[_L4_UTCB_FLAGS]; - buffer->saved_br0 = utcb[_L4_UTCB_BR0]; - memcpy (&buffer->saved_message, - utcb, L4_NUM_MRS * sizeof (l4_word_t)); -} - -static inline void -utcb_state_restore (struct utcb *buffer) -{ - l4_word_t *utcb = _L4_utcb (); - - utcb[_L4_UTCB_SENDER] = buffer->saved_sender; - utcb[_L4_UTCB_RECEIVER] = buffer->saved_receiver; - utcb[_L4_UTCB_TIMEOUT] = buffer->saved_timeout; - utcb[_L4_UTCB_ERROR_CODE] = buffer->saved_error_code; - utcb[_L4_UTCB_FLAGS] = buffer->saved_flags; - utcb[_L4_UTCB_BR0] = buffer->saved_br0; - memcpy (utcb, &buffer->saved_message, - L4_NUM_MRS * sizeof (l4_word_t)); -} - -#define SIGNAL_DISPATCH_ENTRY \ - struct utcb buffer; utcb_state_save (&buffer); - -#define SIGNAL_DISPATCH_EXIT \ - utcb_state_restore (&buffer); diff --git a/sysdeps/l4/hurd/sigprocmask.c b/sysdeps/l4/hurd/sigprocmask.c deleted file mode 100644 index a38b379..0000000 --- a/sysdeps/l4/hurd/sigprocmask.c +++ /dev/null @@ -1,41 +0,0 @@ -/* sigprocmask.c - Generic sigprocmask implementation. - Copyright (C) 2008 Free Software Foundation, Inc. - Written by Neal H. Walfield . - - This file is part of the GNU Hurd. - - The GNU Hurd is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public License - as published by the Free Software Foundation; either version 3 of - the License, or (at your option) any later version. - - The GNU Hurd is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this program. If not, see - . */ - -#include -#include - -int -sigprocmask (int how, const sigset_t *restrict set, sigset_t *restrict old) -{ - struct __pthread *thread = _pthread_self (); - if (! thread) - /* Library is initializing. */ - { - assert (__pthread_num_threads == 1); - - /* We should get the default mask from the startup data structure. */ - if (old) - *old = 0; - - return 0; - } - - return pthread_sigmask (how, set, old); -} diff --git a/sysdeps/l4/pt-block.c b/sysdeps/l4/pt-block.c deleted file mode 100644 index 69e1d35..0000000 --- a/sysdeps/l4/pt-block.c +++ /dev/null @@ -1,47 +0,0 @@ -/* Block a thread. L4 version. - Copyright (C) 2002 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with the GNU C Library; see the file COPYING.LIB. If not, - write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. */ - -#include - -#include - -#include - -/* Block THREAD. */ -void -__pthread_block (struct __pthread *thread) -{ - debug (5, "%x.%x/%x blocking", - l4_thread_no (thread->threadid), l4_version (thread->threadid), - thread->threadid); - - l4_accept (L4_UNTYPED_WORDS_ACCEPTOR); - l4_msg_tag_t tag = l4_receive (l4_anythread); - if (l4_ipc_failed (tag)) - { - debug (1, "%x.%x failed to block: %d, offset: %x", - l4_thread_no (l4_myself ()), l4_version (l4_myself ()), - (l4_error_code () >> 1) & 0x7, - l4_error_code () >> 4); - assert (! l4_ipc_failed (tag)); - } - else - debug (5, "%x.%x unblocked", - l4_thread_no (thread->threadid), l4_version (thread->threadid)); -} diff --git a/sysdeps/l4/pt-docancel.c b/sysdeps/l4/pt-docancel.c deleted file mode 100644 index a3965d0..0000000 --- a/sysdeps/l4/pt-docancel.c +++ /dev/null @@ -1,42 +0,0 @@ -/* Cancel a thread. - Copyright (C) 2002, 2007 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with the GNU C Library; see the file COPYING.LIB. If not, - write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. */ - -#include - -#include - -static void -call_exit (void) -{ - pthread_exit (0); -} - -int -__pthread_do_cancel (struct __pthread *p) -{ - assert (p->cancel_pending == 1); - assert (p->cancel_state == PTHREAD_CANCEL_ENABLE); - - if (l4_is_thread_equal (l4_myself (), p->threadid)) - call_exit (); - else - l4_start_sp_ip (p->threadid, (l4_word_t) p->mcontext.sp, - (l4_word_t) call_exit); - return 0; -} diff --git a/sysdeps/l4/pt-pool-np.c b/sysdeps/l4/pt-pool-np.c deleted file mode 100644 index e83022b..0000000 --- a/sysdeps/l4/pt-pool-np.c +++ /dev/null @@ -1,54 +0,0 @@ -/* Thread pool for L4 threads. - Copyright (C) 2004, 2007 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with the GNU C Library; see the file COPYING.LIB. If not, - write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. */ - -#include -#include - -static pthread_mutex_t pool_lock = PTHREAD_MUTEX_INITIALIZER; - -_L4_thread_id_t pool_list = l4_nilthread; - -/* Add the thread TID to the pthread kernel thread pool. */ -int -pthread_pool_add_np (l4_thread_id_t tid) -{ - __pthread_mutex_lock (&pool_lock); - /* FIXME: Do error checking. */ - l4_set_user_defined_handle_of (tid, pool_list); - pool_list = tid; - __pthread_mutex_unlock (&pool_lock); - - return 0; -} - - -/* Get the first thread from the pool. */ -l4_thread_id_t -pthread_pool_get_np (void) -{ - _L4_thread_id_t tid; - - __pthread_mutex_lock (&pool_lock); - /* FIXME: Do error checking. */ - tid = pool_list; - if (tid != l4_nilthread) - pool_list = l4_user_defined_handle_of (tid); - __pthread_mutex_unlock (&pool_lock); - return tid; -} diff --git a/sysdeps/l4/pt-spin.c b/sysdeps/l4/pt-spin.c deleted file mode 100644 index b6978b0..0000000 --- a/sysdeps/l4/pt-spin.c +++ /dev/null @@ -1,63 +0,0 @@ -/* Spin locks. L4 version. - Copyright (C) 2000, 2004 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with the GNU C Library; see the file COPYING.LIB. If not, - write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. */ - -#include - -#include -#include - -/* The default for single processor machines; don't spin, it's - pointless. */ -#ifndef __PTHREAD_SPIN_COUNT -# define __PTHREAD_SPIN_COUNT 1 -#endif - -/* The number of times to spin while trying to lock a spin lock object - before yielding the processor. */ -int __pthread_spin_count = __PTHREAD_SPIN_COUNT; - - -/* Lock the spin lock object LOCK. If the lock is held by another - thread spin until it becomes available. */ -int -_pthread_spin_lock (__pthread_spinlock_t *lock) -{ - l4_time_t timeout; - int i; - - /* Start with a small timeout of 2 microseconds, then back off - exponentially. */ - timeout = l4_time_period (2); - - while (1) - { - for (i = 0; i < __pthread_spin_count; i++) - { - if (__pthread_spin_trylock (lock) == 0) - return 0; - } - l4_sleep (timeout); - - timeout = l4_time_mul2 (timeout); - if (timeout == L4_NEVER) - timeout = L4_TIME_PERIOD_MAX; - } -} - -weak_alias (_pthread_spin_lock, pthread_spin_lock); diff --git a/sysdeps/l4/pt-stack-alloc.c b/sysdeps/l4/pt-stack-alloc.c deleted file mode 100644 index b7ec12b..0000000 --- a/sysdeps/l4/pt-stack-alloc.c +++ /dev/null @@ -1,43 +0,0 @@ -/* Allocate a new stack. L4 Hurd version. - Copyright (C) 2000, 2007 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with the GNU C Library; see the file COPYING.LIB. If not, - write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. */ - -#include -#include - -#include - -#include - -/* Allocate a new stack of size STACKSIZE. If successful, store the - address of the newly allocated stack in *STACKADDR and return 0. - Otherwise return an error code (EINVAL for an invalid stack size, - EAGAIN if the system lacked the necessary resources to allocate a - new stack). */ -int -__pthread_stack_alloc (void **stackaddr, size_t stacksize) -{ - void *buffer = mmap (0, stacksize, PROT_READ | PROT_WRITE, - MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); - if (buffer == MAP_FAILED) - return EAGAIN; - - *stackaddr = buffer; - - return 0; -} diff --git a/sysdeps/l4/pt-thread-alloc.c b/sysdeps/l4/pt-thread-alloc.c deleted file mode 100644 index ec69afb..0000000 --- a/sysdeps/l4/pt-thread-alloc.c +++ /dev/null @@ -1,43 +0,0 @@ -/* Allocate kernel thread. L4 version. - Copyright (C) 2003, 2005 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with the GNU C Library; see the file COPYING.LIB. If not, - write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. */ - -#include -#include -#include - -#include - -int -__pthread_thread_alloc (struct __pthread *thread) -{ - error_t err; - - /* The main thread is already running of course. */ - if (__pthread_num_threads == 1) - thread->threadid = l4_myself (); - else - { - thread->threadid = pthread_pool_get_np (); - if (thread->threadid != l4_nilthread) - return 0; - - return EAGAIN; - } - return 0; -} diff --git a/sysdeps/l4/pt-thread-dealloc.c b/sysdeps/l4/pt-thread-dealloc.c deleted file mode 100644 index c09e486..0000000 --- a/sysdeps/l4/pt-thread-dealloc.c +++ /dev/null @@ -1,32 +0,0 @@ -/* Deallocate the kernel thread resources. L4 version. - Copyright (C) 2005 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with the GNU C Library; see the file COPYING.LIB. If not, - write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. */ - -#include -#include -#include - -#include - -/* Deallocate any kernel resources associated with THREAD except don't - halt the thread itself. On return, the thread will be marked as - dead and __pthread_halt will be called. */ -void -__pthread_thread_dealloc (struct __pthread *thread) -{ -} diff --git a/sysdeps/l4/pt-thread-halt.c b/sysdeps/l4/pt-thread-halt.c deleted file mode 100644 index aa2bf43..0000000 --- a/sysdeps/l4/pt-thread-halt.c +++ /dev/null @@ -1,45 +0,0 @@ -/* Deallocate the kernel thread resources. L4version. - Copyright (C) 2000, 2002, 2004 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with the GNU C Library; see the file COPYING.LIB. If not, - write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. */ - -#include -#include - -#include - -/* Deallocate the kernel thread resources associated with THREAD. */ -void -__pthread_thread_halt (struct __pthread *thread, int need_dealloc) -{ - l4_thread_id_t tid = thread->threadid; - - if (need_dealloc) - __pthread_dealloc (thread); - - /* There is potential race here: once if TID is the current thread, - then once we add TID to the pool, someone can reallocate it - before we call stop. However, to start the thread, the caller - atomically starts and sets the sp and ip, thus, if the stop has - not yet executed at that point, it won't. */ - - if (tid != l4_myself ()) - l4_stop (tid); - pthread_pool_add_np (tid); - if (tid == l4_myself ()) - l4_stop (tid); -} diff --git a/sysdeps/l4/pt-thread-start.c b/sysdeps/l4/pt-thread-start.c deleted file mode 100644 index 144c58b..0000000 --- a/sysdeps/l4/pt-thread-start.c +++ /dev/null @@ -1,40 +0,0 @@ -/* Start thread. L4 version. - Copyright (C) 2003, 2004, 2007 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with the GNU C Library; see the file COPYING.LIB. If not, - write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. */ - -#include -#include -#include - -#include - -/* Start THREAD. Get the kernel thread scheduled and running. */ -int -__pthread_thread_start (struct __pthread *thread) -{ - if (__pthread_num_threads == 1) - /* The main thread is already running of course. */ - { - assert (__pthread_total == 1); - assert (l4_is_thread_equal (l4_myself (), thread->threadid)); - } - else - l4_start_sp_ip (thread->threadid, (l4_word_t) thread->mcontext.sp, - (l4_word_t) thread->mcontext.pc); - return 0; -} diff --git a/sysdeps/l4/pt-timedblock.c b/sysdeps/l4/pt-timedblock.c deleted file mode 100644 index 951644f..0000000 --- a/sysdeps/l4/pt-timedblock.c +++ /dev/null @@ -1,36 +0,0 @@ -/* Block a thread with a timeout. L4 version. - Copyright (C) 2000,02 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with the GNU C Library; see the file COPYING.LIB. If not, - write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. */ - -#include -#include -#include -#include - -#include - -/* Block THREAD. */ -error_t -__pthread_timedblock (struct __pthread *thread, - const struct timespec *abstime, - clockid_t clock_id) -{ -#warning Need gettimeofday to implement properly. - __pthread_block (thread); - return 0; -} diff --git a/sysdeps/l4/pt-wakeup.c b/sysdeps/l4/pt-wakeup.c deleted file mode 100644 index de37846..0000000 --- a/sysdeps/l4/pt-wakeup.c +++ /dev/null @@ -1,54 +0,0 @@ -/* Wakeup a thread. L4 version. - Copyright (C) 2002 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with the GNU C Library; see the file COPYING.LIB. If not, - write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. */ - -#include - -#include - -#include - -/* Wakeup THREAD. */ -void -__pthread_wakeup (struct __pthread *thread) -{ - debug (5, "%x.%x/%x waking %x.%x/%x", - l4_thread_no (l4_myself ()), l4_version (l4_myself ()), l4_myself (), - l4_thread_no (thread->threadid), l4_version (thread->threadid), - thread->threadid); - - /* Signal the waiter. */ - l4_msg_t msg; - l4_msg_clear (msg); - l4_msg_set_untyped_words (msg, 0); - l4_msg_load (msg); - - l4_msg_tag_t tag = l4_send (thread->threadid); - if (l4_ipc_failed (tag)) - { - int err = l4_error_code (); - debug (1, "%x.%x failed to wake %x.%x: %s (%d)", - l4_thread_no (l4_myself ()), l4_version (l4_myself ()), - l4_thread_no (thread->threadid), l4_version (thread->threadid), - l4_strerror (err), err); - } - else - debug (5, "%x.%x woke %x.%x", - l4_thread_no (l4_myself ()), l4_version (l4_myself ()), - l4_thread_no (thread->threadid), l4_version (thread->threadid)); -} -- cgit v1.2.3 From 642de69b2152489fed2d0af9cf7c201e9a7d33dc Mon Sep 17 00:00:00 2001 From: Thomas Schwinge Date: Tue, 7 Aug 2012 22:21:09 +0200 Subject: * signal/README: Add note about accompanying sysdeps/generic/ files. --- signal/README | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/signal/README b/signal/README index 259ec4c..4963b26 100644 --- a/signal/README +++ b/signal/README @@ -3,5 +3,10 @@ for operating systems where signals are managed at user-level. It is up to the run-time to catch the signals and forward them to the implementation via, e.g., the pthread_kill_info_np call. +The files in this directory are accompanied by the generic implementations +found in sysdeps/generic/: killpg.c, raise.c, sigaddset.c, sigdelset.c, +sigemptyset.c, sigfillset.c, siginterrupt.c, sigismember.c, signal.c, +sigwait.c. + This implementation was once used for a native port running on L4, but is not currently used in any libpthread port bundled in this release. -- cgit v1.2.3 From a5387f6a45d6b3f2b381d861f5c288b79da6204f Mon Sep 17 00:00:00 2001 From: Thomas Schwinge Date: Sat, 4 Aug 2012 12:19:17 +0200 Subject: Remove PowerPC port. * sysdeps/powerpc/bits/machine-lock.h: Remove file. * sysdeps/powerpc/bits/memory.h: Likewise. * sysdeps/powerpc/bits/spin-lock.h: Likewise. * sysdeps/powerpc/machine-sp.h: Likewise. * sysdeps/powerpc/pt-machdep.h: Likewise. * TODO: Update. --- TODO | 3 - sysdeps/powerpc/bits/machine-lock.h | 78 -------------------------- sysdeps/powerpc/bits/memory.h | 36 ------------ sysdeps/powerpc/bits/spin-lock.h | 108 ------------------------------------ sysdeps/powerpc/machine-sp.h | 31 ----------- sysdeps/powerpc/pt-machdep.h | 29 ---------- 6 files changed, 285 deletions(-) delete mode 100644 sysdeps/powerpc/bits/machine-lock.h delete mode 100644 sysdeps/powerpc/bits/memory.h delete mode 100644 sysdeps/powerpc/bits/spin-lock.h delete mode 100644 sysdeps/powerpc/machine-sp.h delete mode 100644 sysdeps/powerpc/pt-machdep.h diff --git a/TODO b/TODO index 8b087b1..848992d 100644 --- a/TODO +++ b/TODO @@ -139,6 +139,3 @@ ** weak aliases Use them consistently and correctly and start by reading http://sources.redhat.com/ml/libc-alpha/2002-08/msg00278.html. - -** TLS - Support for TLS is only implemented for Mach/Hurd (x86). diff --git a/sysdeps/powerpc/bits/machine-lock.h b/sysdeps/powerpc/bits/machine-lock.h deleted file mode 100644 index cba6b0a..0000000 --- a/sysdeps/powerpc/bits/machine-lock.h +++ /dev/null @@ -1,78 +0,0 @@ -/* Machine-specific definition for spin locks. PowerPC version. - Copyright (C) 1994,97,2002 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, write to the Free - Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - 02111-1307 USA. */ - -#ifndef _MACHINE_LOCK_H -#define _MACHINE_LOCK_H - -/* The type of a spin lock variable. */ - -typedef __volatile long int __spin_lock_t; - -/* Value to initialize `__spin_lock_t' variables to. */ - -#define __SPIN_LOCK_INITIALIZER 0L - - -#ifndef _EXTERN_INLINE -#define _EXTERN_INLINE extern __inline -#endif - -/* Unlock LOCK. */ - -_EXTERN_INLINE void -__spin_unlock (__spin_lock_t *__lock) -{ - long int __locked; - __asm__ __volatile__ ("\ -0: lwarx %0,0,%1\n\ - stwcx. %2,0,%1\n\ - bne- 0b\n\ -" : "=&r" (__locked) : "r" (__lock), "r" (0) : "cr0"); -} - -/* Try to lock LOCK; return nonzero if we locked it, zero if another has. */ - -_EXTERN_INLINE int -__spin_try_lock (register __spin_lock_t *__lock) -{ - long int __rtn; - __asm__ __volatile__ ("\ -0: lwarx %0,0,%1\n\ - stwcx. %2,0,%1\n\ - bne- 0b\n\ -" : "=&r" (__rtn) : "r" (__lock), "r" (1) : "cr0"); - return !__rtn; -} - -/* Return nonzero if LOCK is locked. */ - -_EXTERN_INLINE int -__spin_lock_locked (__spin_lock_t *__lock) -{ - long int __rtn; - __asm__ __volatile__ ("\ -0: lwarx %0,0,%1\n\ - stwcx. %0,0,%1\n\ - bne- 0b\n\ -" : "=&r" (__rtn) : "r" (__lock) : "cr0"); - return __rtn; -} - - -#endif /* machine-lock.h */ diff --git a/sysdeps/powerpc/bits/memory.h b/sysdeps/powerpc/bits/memory.h deleted file mode 100644 index 96624c3..0000000 --- a/sysdeps/powerpc/bits/memory.h +++ /dev/null @@ -1,36 +0,0 @@ -/* Memory barrier operations. PowerPC version. - Copyright (C) 2003 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with the GNU C Library; see the file COPYING.LIB. If not, - write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. */ - -#ifndef _BITS_MEMORY_H -#define _BITS_MEMORY_H 1 - -/* Prevent read and write reordering across this function. */ -inline void -__memory_barrier (void) -{ - asm ("sync" ::: "memory"); -} - -/* Prevent read reordering across this function. */ -#define __memory_read_barrier __memory_barrier - -/* Prevent write reordering across this function. */ -#define __memory_write_barrier __memory_barrier - -#endif diff --git a/sysdeps/powerpc/bits/spin-lock.h b/sysdeps/powerpc/bits/spin-lock.h deleted file mode 100644 index 1dc2571..0000000 --- a/sysdeps/powerpc/bits/spin-lock.h +++ /dev/null @@ -1,108 +0,0 @@ -/* Machine-specific definitions for spin locks. PowerPC version. - Copyright (C) 2003 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with the GNU C Library; see the file COPYING.LIB. If not, - write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. */ - -/* - * Never include this file directly; use or instead. - */ - -#ifndef _BITS_SPIN_LOCK_H -#define _BITS_SPIN_LOCK_H 1 - -#include - -__BEGIN_DECLS - -/* The type of a spin lock object. */ -typedef __volatile int __pthread_spinlock_t; - -/* Initializer for a spin lock object. */ -# define __SPIN_LOCK_INITIALIZER ((__pthread_spinlock_t) 0) - -#if defined __USE_EXTERN_INLINES || defined _FORCE_INLINES - -# ifndef __EBUSY -# include -# define __EBUSY EBUSY -# endif - -# ifndef __PT_SPIN_INLINE -# define __PT_SPIN_INLINE extern __inline -# endif - -__PT_SPIN_INLINE int __pthread_spin_destroy (__pthread_spinlock_t *__lock); - -__PT_SPIN_INLINE int -__pthread_spin_destroy (__pthread_spinlock_t *__lock) -{ - return 0; -} - -__PT_SPIN_INLINE int __pthread_spin_init (__pthread_spinlock_t *__lock, - int __pshared); - -__PT_SPIN_INLINE int -__pthread_spin_init (__pthread_spinlock_t *__lock, int __pshared) -{ - *__lock = __SPIN_LOCK_INITIALIZER; - return 0; -} - -__PT_SPIN_INLINE int __pthread_spin_trylock (__pthread_spinlock_t *__lock); - -__PT_SPIN_INLINE int -__pthread_spin_trylock (__pthread_spinlock_t *__lock) -{ - long int __rtn; - __asm__ __volatile__ ("\ -0: lwarx %0,0,%1\n\ - stwcx. %2,0,%1\n\ - bne- 0b\n\ -" : "=&r" (__rtn) : "r" (__lock), "r" (1) : "cr0"); - return __rtn ? __EBUSY : 0; -} - -extern inline int __pthread_spin_lock (__pthread_spinlock_t *__lock); -extern int _pthread_spin_lock (__pthread_spinlock_t *__lock); - -extern inline int -__pthread_spin_lock (__pthread_spinlock_t *__lock) -{ - if (__pthread_spin_trylock (__lock)) - return _pthread_spin_lock (__lock); - return 0; -} - -__PT_SPIN_INLINE int __pthread_spin_unlock (__pthread_spinlock_t *__lock); - -__PT_SPIN_INLINE int -__pthread_spin_unlock (__pthread_spinlock_t *__lock) -{ - long int __locked; - __asm__ __volatile__ ("\ -0: lwarx %0,0,%1\n\ - stwcx. %2,0,%1\n\ - bne- 0b\n\ -" : "=&r" (__locked) : "r" (__lock), "r" (0) : "cr0"); -} - -#endif /* Use extern inlines or force inlines. */ - -__END_DECLS - -#endif /* bits/spin-lock.h */ diff --git a/sysdeps/powerpc/machine-sp.h b/sysdeps/powerpc/machine-sp.h deleted file mode 100644 index aa787c5..0000000 --- a/sysdeps/powerpc/machine-sp.h +++ /dev/null @@ -1,31 +0,0 @@ -/* Machine-specific function to return the stack pointer. i386 version. - Copyright (C) 1994,97,2001 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, write to the Free - Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - 02111-1307 USA. */ - -#ifndef _MACHINE_SP_H -#define _MACHINE_SP_H - -/* Return the current stack pointer. */ - -#define __thread_stack_pointer() ({ \ - void *__sp__; \ - __asm__ ("mr %0, 1" : "=r" (__sp__)); \ - __sp__; \ -}) - -#endif /* machine-sp.h */ diff --git a/sysdeps/powerpc/pt-machdep.h b/sysdeps/powerpc/pt-machdep.h deleted file mode 100644 index 6d45636..0000000 --- a/sysdeps/powerpc/pt-machdep.h +++ /dev/null @@ -1,29 +0,0 @@ -/* Machine dependent pthreads internal defenitions. i386 version. - Copyright (C) 2000 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with the GNU C Library; see the file COPYING.LIB. If not, - write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. */ - -#ifndef _PT_MACHDEP_H -#define _PT_MACHDEP_H 1 - -struct pthread_mcontext -{ - void *pc; - void *sp; -}; - -#endif /* pt-machdep.h */ -- cgit v1.2.3 From af7d78e726cb0d3248c461cfee27fe15121dacd1 Mon Sep 17 00:00:00 2001 From: Thomas Schwinge Date: Tue, 7 Aug 2012 22:36:56 +0200 Subject: Rename ia32 sysdep directories to i386. * sysdeps/i386/Implies: Remove file. * sysdeps/mach/hurd/i386/Implies: Likewise. * sysdeps/ia32/bits/memory.h: Rename to sysdeps/i386/bits/memory.h. * sysdeps/ia32/bits/pt-atomic.h: Rename to sysdeps/i386/bits/pt-atomic.h. * sysdeps/ia32/bits/spin-lock-inline.h: Rename to sysdeps/i386/bits/spin-lock-inline.h. * sysdeps/ia32/bits/spin-lock.h: Rename to sysdeps/i386/bits/spin-lock.h. * sysdeps/ia32/machine-sp.h: Rename to sysdeps/i386/machine-sp.h. * sysdeps/ia32/pt-machdep.h: Rename to sysdeps/i386/pt-machdep.h. * sysdeps/mach/hurd/ia32/pt-machdep.c: Rename to sysdeps/mach/hurd/i386/pt-machdep.c. * sysdeps/mach/hurd/ia32/pt-setup.c: Rename to sysdeps/mach/hurd/i386/pt-setup.c. * Makefile (SYSDEP_PATH): Adapt to that. --- Makefile | 6 +- sysdeps/i386/Implies | 1 - sysdeps/i386/bits/memory.h | 40 +++++++++++++ sysdeps/i386/bits/pt-atomic.h | 66 ++++++++++++++++++++++ sysdeps/i386/bits/spin-lock-inline.h | 98 ++++++++++++++++++++++++++++++++ sysdeps/i386/bits/spin-lock.h | 39 +++++++++++++ sysdeps/i386/machine-sp.h | 30 ++++++++++ sysdeps/i386/pt-machdep.h | 29 ++++++++++ sysdeps/ia32/bits/memory.h | 40 ------------- sysdeps/ia32/bits/pt-atomic.h | 66 ---------------------- sysdeps/ia32/bits/spin-lock-inline.h | 98 -------------------------------- sysdeps/ia32/bits/spin-lock.h | 39 ------------- sysdeps/ia32/machine-sp.h | 30 ---------- sysdeps/ia32/pt-machdep.h | 29 ---------- sysdeps/mach/hurd/i386/Implies | 1 - sysdeps/mach/hurd/i386/pt-machdep.c | 83 +++++++++++++++++++++++++++ sysdeps/mach/hurd/i386/pt-setup.c | 106 +++++++++++++++++++++++++++++++++++ sysdeps/mach/hurd/ia32/pt-machdep.c | 83 --------------------------- sysdeps/mach/hurd/ia32/pt-setup.c | 106 ----------------------------------- 19 files changed, 494 insertions(+), 496 deletions(-) delete mode 100644 sysdeps/i386/Implies create mode 100644 sysdeps/i386/bits/memory.h create mode 100644 sysdeps/i386/bits/pt-atomic.h create mode 100644 sysdeps/i386/bits/spin-lock-inline.h create mode 100644 sysdeps/i386/bits/spin-lock.h create mode 100644 sysdeps/i386/machine-sp.h create mode 100644 sysdeps/i386/pt-machdep.h delete mode 100644 sysdeps/ia32/bits/memory.h delete mode 100644 sysdeps/ia32/bits/pt-atomic.h delete mode 100644 sysdeps/ia32/bits/spin-lock-inline.h delete mode 100644 sysdeps/ia32/bits/spin-lock.h delete mode 100644 sysdeps/ia32/machine-sp.h delete mode 100644 sysdeps/ia32/pt-machdep.h delete mode 100644 sysdeps/mach/hurd/i386/Implies create mode 100644 sysdeps/mach/hurd/i386/pt-machdep.c create mode 100644 sysdeps/mach/hurd/i386/pt-setup.c delete mode 100644 sysdeps/mach/hurd/ia32/pt-machdep.c delete mode 100644 sysdeps/mach/hurd/ia32/pt-setup.c diff --git a/Makefile b/Makefile index b6e5602..fdfe3ae 100644 --- a/Makefile +++ b/Makefile @@ -196,9 +196,9 @@ install-lib-ldscripts := libpthread.so include ../Makeconfig endif -SYSDEP_PATH = $(srcdir)/sysdeps/$(MICROKERNEL)/hurd/ia32 \ - $(srcdir)/sysdeps/$(MICROKERNEL)/ia32 \ - $(srcdir)/sysdeps/ia32 \ +SYSDEP_PATH = $(srcdir)/sysdeps/$(MICROKERNEL)/hurd/i386 \ + $(srcdir)/sysdeps/$(MICROKERNEL)/i386 \ + $(srcdir)/sysdeps/i386 \ $(srcdir)/sysdeps/$(MICROKERNEL)/hurd \ $(srcdir)/sysdeps/$(MICROKERNEL) \ $(srcdir)/sysdeps/hurd \ diff --git a/sysdeps/i386/Implies b/sysdeps/i386/Implies deleted file mode 100644 index d799fa1..0000000 --- a/sysdeps/i386/Implies +++ /dev/null @@ -1 +0,0 @@ -ia32 diff --git a/sysdeps/i386/bits/memory.h b/sysdeps/i386/bits/memory.h new file mode 100644 index 0000000..932c408 --- /dev/null +++ b/sysdeps/i386/bits/memory.h @@ -0,0 +1,40 @@ +/* Memory barrier operations. i386 version. + Copyright (C) 2002, 2008 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#ifndef _BITS_MEMORY_H +#define _BITS_MEMORY_H 1 + +/* Prevent read and write reordering across this function. */ +static inline void +__memory_barrier (void) +{ + int i; + + /* Any lock'ed instruction will do. We just do a simple + increment. */ + __asm__ __volatile ("lock; incl %0" : "=m" (i) : "m" (i) : "memory"); +} + +/* Prevent read reordering across this function. */ +#define __memory_read_barrier __memory_barrier + +/* Prevent write reordering across this function. */ +#define __memory_write_barrier __memory_barrier + +#endif diff --git a/sysdeps/i386/bits/pt-atomic.h b/sysdeps/i386/bits/pt-atomic.h new file mode 100644 index 0000000..0dfc1f6 --- /dev/null +++ b/sysdeps/i386/bits/pt-atomic.h @@ -0,0 +1,66 @@ +/* Atomic operations. i386 version. + Copyright (C) 2000 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#ifndef _BITS_ATOMIC_H +#define _BITS_ATOMIC_H 1 + +typedef __volatile int __atomic_t; + +static inline void +__atomic_inc (__atomic_t *__var) +{ + __asm__ __volatile ("lock; incl %0" : "=m" (*__var) : "m" (*__var)); +} + +static inline void +__atomic_dec (__atomic_t *__var) +{ + __asm__ __volatile ("lock; decl %0" : "=m" (*__var) : "m" (*__var)); +} + +static inline int +__atomic_dec_and_test (__atomic_t *__var) +{ + unsigned char __ret; + + __asm__ __volatile ("lock; decl %0; sete %1" + : "=m" (*__var), "=qm" (__ret) : "m" (*__var)); + return __ret != 0; +} + +/* We assume that an __atomicptr_t is only used for pointers to + word-aligned objects, and use the lowest bit for a simple lock. */ +typedef __volatile int * __atomicptr_t; + +/* Actually we don't implement that yet, and assume that we run on + something that has the i486 instruction set. */ +static inline int +__atomicptr_compare_and_swap (__atomicptr_t *__ptr, void *__oldval, + void * __newval) +{ + char __ret; + int __dummy; + + __asm__ __volatile ("lock; cmpxchgl %3, %1; sete %0" + : "=q" (__ret), "=m" (*__ptr), "=a" (__dummy) + : "r" (__newval), "m" (*__ptr), "a" (__oldval)); + return __ret; +} + +#endif diff --git a/sysdeps/i386/bits/spin-lock-inline.h b/sysdeps/i386/bits/spin-lock-inline.h new file mode 100644 index 0000000..e5ed3de --- /dev/null +++ b/sysdeps/i386/bits/spin-lock-inline.h @@ -0,0 +1,98 @@ +/* Machine-specific definitions for spin locks. i386 version. + Copyright (C) 2000, 2005, 2008, 2009 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +/* + * Never include this file directly; use or instead. + */ + +#ifndef _BITS_SPIN_LOCK_INLINE_H +#define _BITS_SPIN_LOCK_INLINE_H 1 + +#include +#include + +__BEGIN_DECLS + +#if defined __USE_EXTERN_INLINES || defined _FORCE_INLINES + +# ifndef __EBUSY +# include +# define __EBUSY EBUSY +# endif + +# ifndef __PT_SPIN_INLINE +# define __PT_SPIN_INLINE __extern_inline +# endif + +__PT_SPIN_INLINE int __pthread_spin_destroy (__pthread_spinlock_t *__lock); + +__PT_SPIN_INLINE int +__pthread_spin_destroy (__pthread_spinlock_t *__lock) +{ + return 0; +} + +__PT_SPIN_INLINE int __pthread_spin_init (__pthread_spinlock_t *__lock, + int __pshared); + +__PT_SPIN_INLINE int +__pthread_spin_init (__pthread_spinlock_t *__lock, int __pshared) +{ + *__lock = __PTHREAD_SPIN_LOCK_INITIALIZER; + return 0; +} + +__PT_SPIN_INLINE int __pthread_spin_trylock (__pthread_spinlock_t *__lock); + +__PT_SPIN_INLINE int +__pthread_spin_trylock (__pthread_spinlock_t *__lock) +{ + int __locked; + __asm__ __volatile ("xchgl %0, %1" + : "=&r" (__locked), "=m" (*__lock) : "0" (1) : "memory"); + return __locked ? __EBUSY : 0; +} + +__extern_inline int __pthread_spin_lock (__pthread_spinlock_t *__lock); +extern int _pthread_spin_lock (__pthread_spinlock_t *__lock); + +__extern_inline int +__pthread_spin_lock (__pthread_spinlock_t *__lock) +{ + if (__pthread_spin_trylock (__lock)) + return _pthread_spin_lock (__lock); + return 0; +} + +__PT_SPIN_INLINE int __pthread_spin_unlock (__pthread_spinlock_t *__lock); + +__PT_SPIN_INLINE int +__pthread_spin_unlock (__pthread_spinlock_t *__lock) +{ + int __unlocked; + __asm__ __volatile ("xchgl %0, %1" + : "=&r" (__unlocked), "=m" (*__lock) : "0" (0) : "memory"); + return 0; +} + +#endif /* Use extern inlines or force inlines. */ + +__END_DECLS + +#endif /* bits/spin-lock.h */ diff --git a/sysdeps/i386/bits/spin-lock.h b/sysdeps/i386/bits/spin-lock.h new file mode 100644 index 0000000..5ae81e1 --- /dev/null +++ b/sysdeps/i386/bits/spin-lock.h @@ -0,0 +1,39 @@ +/* Machine-specific definitions for spin locks. i386 version. + Copyright (C) 2000, 2005, 2008, 2009 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +/* + * Never include this file directly; use or instead. + */ + +#ifndef _BITS_SPIN_LOCK_H +#define _BITS_SPIN_LOCK_H 1 + +#include + +__BEGIN_DECLS + +/* The type of a spin lock object. */ +typedef __volatile int __pthread_spinlock_t; + +/* Initializer for a spin lock object. */ +# define __PTHREAD_SPIN_LOCK_INITIALIZER ((__pthread_spinlock_t) 0) + +__END_DECLS + +#endif /* bits/spin-lock.h */ diff --git a/sysdeps/i386/machine-sp.h b/sysdeps/i386/machine-sp.h new file mode 100644 index 0000000..cef6ab7 --- /dev/null +++ b/sysdeps/i386/machine-sp.h @@ -0,0 +1,30 @@ +/* Machine-specific function to return the stack pointer. i386 version. + Copyright (C) 1994, 1997, 2001, 2006 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _MACHINE_SP_H +#define _MACHINE_SP_H + +/* Return the current stack pointer. */ + +#define __thread_stack_pointer() ({ \ + register void *__sp__ asm("esp"); \ + __sp__; \ +}) + +#endif /* machine-sp.h */ diff --git a/sysdeps/i386/pt-machdep.h b/sysdeps/i386/pt-machdep.h new file mode 100644 index 0000000..6d45636 --- /dev/null +++ b/sysdeps/i386/pt-machdep.h @@ -0,0 +1,29 @@ +/* Machine dependent pthreads internal defenitions. i386 version. + Copyright (C) 2000 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#ifndef _PT_MACHDEP_H +#define _PT_MACHDEP_H 1 + +struct pthread_mcontext +{ + void *pc; + void *sp; +}; + +#endif /* pt-machdep.h */ diff --git a/sysdeps/ia32/bits/memory.h b/sysdeps/ia32/bits/memory.h deleted file mode 100644 index 932c408..0000000 --- a/sysdeps/ia32/bits/memory.h +++ /dev/null @@ -1,40 +0,0 @@ -/* Memory barrier operations. i386 version. - Copyright (C) 2002, 2008 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with the GNU C Library; see the file COPYING.LIB. If not, - write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. */ - -#ifndef _BITS_MEMORY_H -#define _BITS_MEMORY_H 1 - -/* Prevent read and write reordering across this function. */ -static inline void -__memory_barrier (void) -{ - int i; - - /* Any lock'ed instruction will do. We just do a simple - increment. */ - __asm__ __volatile ("lock; incl %0" : "=m" (i) : "m" (i) : "memory"); -} - -/* Prevent read reordering across this function. */ -#define __memory_read_barrier __memory_barrier - -/* Prevent write reordering across this function. */ -#define __memory_write_barrier __memory_barrier - -#endif diff --git a/sysdeps/ia32/bits/pt-atomic.h b/sysdeps/ia32/bits/pt-atomic.h deleted file mode 100644 index 0dfc1f6..0000000 --- a/sysdeps/ia32/bits/pt-atomic.h +++ /dev/null @@ -1,66 +0,0 @@ -/* Atomic operations. i386 version. - Copyright (C) 2000 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with the GNU C Library; see the file COPYING.LIB. If not, - write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. */ - -#ifndef _BITS_ATOMIC_H -#define _BITS_ATOMIC_H 1 - -typedef __volatile int __atomic_t; - -static inline void -__atomic_inc (__atomic_t *__var) -{ - __asm__ __volatile ("lock; incl %0" : "=m" (*__var) : "m" (*__var)); -} - -static inline void -__atomic_dec (__atomic_t *__var) -{ - __asm__ __volatile ("lock; decl %0" : "=m" (*__var) : "m" (*__var)); -} - -static inline int -__atomic_dec_and_test (__atomic_t *__var) -{ - unsigned char __ret; - - __asm__ __volatile ("lock; decl %0; sete %1" - : "=m" (*__var), "=qm" (__ret) : "m" (*__var)); - return __ret != 0; -} - -/* We assume that an __atomicptr_t is only used for pointers to - word-aligned objects, and use the lowest bit for a simple lock. */ -typedef __volatile int * __atomicptr_t; - -/* Actually we don't implement that yet, and assume that we run on - something that has the i486 instruction set. */ -static inline int -__atomicptr_compare_and_swap (__atomicptr_t *__ptr, void *__oldval, - void * __newval) -{ - char __ret; - int __dummy; - - __asm__ __volatile ("lock; cmpxchgl %3, %1; sete %0" - : "=q" (__ret), "=m" (*__ptr), "=a" (__dummy) - : "r" (__newval), "m" (*__ptr), "a" (__oldval)); - return __ret; -} - -#endif diff --git a/sysdeps/ia32/bits/spin-lock-inline.h b/sysdeps/ia32/bits/spin-lock-inline.h deleted file mode 100644 index e5ed3de..0000000 --- a/sysdeps/ia32/bits/spin-lock-inline.h +++ /dev/null @@ -1,98 +0,0 @@ -/* Machine-specific definitions for spin locks. i386 version. - Copyright (C) 2000, 2005, 2008, 2009 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with the GNU C Library; see the file COPYING.LIB. If not, - write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. */ - -/* - * Never include this file directly; use or instead. - */ - -#ifndef _BITS_SPIN_LOCK_INLINE_H -#define _BITS_SPIN_LOCK_INLINE_H 1 - -#include -#include - -__BEGIN_DECLS - -#if defined __USE_EXTERN_INLINES || defined _FORCE_INLINES - -# ifndef __EBUSY -# include -# define __EBUSY EBUSY -# endif - -# ifndef __PT_SPIN_INLINE -# define __PT_SPIN_INLINE __extern_inline -# endif - -__PT_SPIN_INLINE int __pthread_spin_destroy (__pthread_spinlock_t *__lock); - -__PT_SPIN_INLINE int -__pthread_spin_destroy (__pthread_spinlock_t *__lock) -{ - return 0; -} - -__PT_SPIN_INLINE int __pthread_spin_init (__pthread_spinlock_t *__lock, - int __pshared); - -__PT_SPIN_INLINE int -__pthread_spin_init (__pthread_spinlock_t *__lock, int __pshared) -{ - *__lock = __PTHREAD_SPIN_LOCK_INITIALIZER; - return 0; -} - -__PT_SPIN_INLINE int __pthread_spin_trylock (__pthread_spinlock_t *__lock); - -__PT_SPIN_INLINE int -__pthread_spin_trylock (__pthread_spinlock_t *__lock) -{ - int __locked; - __asm__ __volatile ("xchgl %0, %1" - : "=&r" (__locked), "=m" (*__lock) : "0" (1) : "memory"); - return __locked ? __EBUSY : 0; -} - -__extern_inline int __pthread_spin_lock (__pthread_spinlock_t *__lock); -extern int _pthread_spin_lock (__pthread_spinlock_t *__lock); - -__extern_inline int -__pthread_spin_lock (__pthread_spinlock_t *__lock) -{ - if (__pthread_spin_trylock (__lock)) - return _pthread_spin_lock (__lock); - return 0; -} - -__PT_SPIN_INLINE int __pthread_spin_unlock (__pthread_spinlock_t *__lock); - -__PT_SPIN_INLINE int -__pthread_spin_unlock (__pthread_spinlock_t *__lock) -{ - int __unlocked; - __asm__ __volatile ("xchgl %0, %1" - : "=&r" (__unlocked), "=m" (*__lock) : "0" (0) : "memory"); - return 0; -} - -#endif /* Use extern inlines or force inlines. */ - -__END_DECLS - -#endif /* bits/spin-lock.h */ diff --git a/sysdeps/ia32/bits/spin-lock.h b/sysdeps/ia32/bits/spin-lock.h deleted file mode 100644 index 5ae81e1..0000000 --- a/sysdeps/ia32/bits/spin-lock.h +++ /dev/null @@ -1,39 +0,0 @@ -/* Machine-specific definitions for spin locks. i386 version. - Copyright (C) 2000, 2005, 2008, 2009 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with the GNU C Library; see the file COPYING.LIB. If not, - write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. */ - -/* - * Never include this file directly; use or instead. - */ - -#ifndef _BITS_SPIN_LOCK_H -#define _BITS_SPIN_LOCK_H 1 - -#include - -__BEGIN_DECLS - -/* The type of a spin lock object. */ -typedef __volatile int __pthread_spinlock_t; - -/* Initializer for a spin lock object. */ -# define __PTHREAD_SPIN_LOCK_INITIALIZER ((__pthread_spinlock_t) 0) - -__END_DECLS - -#endif /* bits/spin-lock.h */ diff --git a/sysdeps/ia32/machine-sp.h b/sysdeps/ia32/machine-sp.h deleted file mode 100644 index cef6ab7..0000000 --- a/sysdeps/ia32/machine-sp.h +++ /dev/null @@ -1,30 +0,0 @@ -/* Machine-specific function to return the stack pointer. i386 version. - Copyright (C) 1994, 1997, 2001, 2006 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, write to the Free - Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - 02111-1307 USA. */ - -#ifndef _MACHINE_SP_H -#define _MACHINE_SP_H - -/* Return the current stack pointer. */ - -#define __thread_stack_pointer() ({ \ - register void *__sp__ asm("esp"); \ - __sp__; \ -}) - -#endif /* machine-sp.h */ diff --git a/sysdeps/ia32/pt-machdep.h b/sysdeps/ia32/pt-machdep.h deleted file mode 100644 index 6d45636..0000000 --- a/sysdeps/ia32/pt-machdep.h +++ /dev/null @@ -1,29 +0,0 @@ -/* Machine dependent pthreads internal defenitions. i386 version. - Copyright (C) 2000 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with the GNU C Library; see the file COPYING.LIB. If not, - write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. */ - -#ifndef _PT_MACHDEP_H -#define _PT_MACHDEP_H 1 - -struct pthread_mcontext -{ - void *pc; - void *sp; -}; - -#endif /* pt-machdep.h */ diff --git a/sysdeps/mach/hurd/i386/Implies b/sysdeps/mach/hurd/i386/Implies deleted file mode 100644 index d799fa1..0000000 --- a/sysdeps/mach/hurd/i386/Implies +++ /dev/null @@ -1 +0,0 @@ -ia32 diff --git a/sysdeps/mach/hurd/i386/pt-machdep.c b/sysdeps/mach/hurd/i386/pt-machdep.c new file mode 100644 index 0000000..f3c8cf5 --- /dev/null +++ b/sysdeps/mach/hurd/i386/pt-machdep.c @@ -0,0 +1,83 @@ +/* Machine dependent pthreads code. Hurd/i386 version. + Copyright (C) 2000, 2002, 2007 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include + +#include +#include +#include +#include +#include + +#define HURD_TLS_DESC_DECL(desc, tcb) \ + struct descriptor desc = \ + { /* low word: */ \ + 0xffff /* limit 0..15 */ \ + | (((unsigned int) (tcb)) << 16) /* base 0..15 */ \ + , /* high word: */ \ + ((((unsigned int) (tcb)) >> 16) & 0xff) /* base 16..23 */ \ + | ((0x12 | 0x60 | 0x80) << 8) /* access = ACC_DATA_W|ACC_PL_U|ACC_P */ \ + | (0xf << 16) /* limit 16..19 */ \ + | ((4 | 8) << 20) /* granularity = SZ_32|SZ_G */ \ + | (((unsigned int) (tcb)) & 0xff000000) /* base 24..31 */ \ + } + +int +__thread_set_pcsptp (thread_t thread, + int set_ip, void *ip, + int set_sp, void *sp, + int set_tp, void *tp) +{ + error_t err; + struct i386_thread_state state; + mach_msg_type_number_t state_count; + + state_count = i386_THREAD_STATE_COUNT; + + err = __thread_get_state (thread, i386_REGS_SEGS_STATE, + (thread_state_t) &state, &state_count); + if (err) + return err; + + if (set_sp) + state.uesp = (unsigned int) sp; + if (set_ip) + state.eip = (unsigned int) ip; + if (set_tp) { + HURD_TLS_DESC_DECL(desc, tp); + int sel; + + asm ("mov %%gs, %w0" : "=q" (sel) : "0" (0)); + if (__builtin_expect (sel, 0x48) & 4) /* LDT selector */ + err = __i386_set_ldt (thread, sel, &desc, 1); + else + err = __i386_set_gdt (thread, &sel, desc); + if (err) + return err; + state.gs = sel; + } + + err = __thread_set_state (thread, i386_REGS_SEGS_STATE, + (thread_state_t) &state, + i386_THREAD_STATE_COUNT); + if (err) + return err; + + return 0; +} diff --git a/sysdeps/mach/hurd/i386/pt-setup.c b/sysdeps/mach/hurd/i386/pt-setup.c new file mode 100644 index 0000000..73fd43d --- /dev/null +++ b/sysdeps/mach/hurd/i386/pt-setup.c @@ -0,0 +1,106 @@ +/* Setup thread stack. Hurd/i386 version. + Copyright (C) 2000, 2002, 2005, 2007, 2008 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include +#include +#include + +#include + +/* The stack layout used on the i386 is: + + ----------------- + | ARG | + ----------------- + | START_ROUTINE | + ----------------- + | 0 | + ----------------- + | | + | Fast TSD | + | | + ----------------- + + We need to reserve __hurd_threadvar_max `unsigned long int's' of + (fast) thread-specific data (TSD) for the Hurd. */ + +/* Set up the stack for THREAD, such that it appears as if + START_ROUTINE and ARG were passed to the new thread's entry-point. + Return the stack pointer for the new thread. */ +static void * +stack_setup (struct __pthread *thread, + void *(*start_routine)(void *), void *arg) +{ + error_t err; + uintptr_t *bottom, *top; + + /* Calculate the top of the new stack. */ + bottom = thread->stackaddr; + top = (uintptr_t *) ((uintptr_t) bottom + thread->stacksize); + + /* Next, make room for the TSDs. */ + top -= __hurd_threadvar_max; + + if (start_routine) + { + /* And then the call frame. */ + top -= 3; + top = (uintptr_t *) ((uintptr_t) top & ~0xf); + top[2] = (uintptr_t) arg; /* Argument to START_ROUTINE. */ + top[1] = (uintptr_t) start_routine; + top[0] = (uintptr_t) thread; + *--top = 0; /* Fake return address. */ + } + + if (thread->guardsize) + { + err = __vm_protect (__mach_task_self (), (vm_address_t) bottom, + thread->guardsize, 0, 0); + assert_perror (err); + } + + return top; +} + +int +__pthread_setup (struct __pthread *thread, + void (*entry_point)(struct __pthread *, void *(*)(void *), void *), + void *(*start_routine)(void *), void *arg) +{ + error_t err; + mach_port_t ktid; + + thread->mcontext.pc = entry_point; + thread->mcontext.sp = stack_setup (thread, start_routine, arg); + + thread->tcb->self = thread->kernel_thread; + + ktid = __mach_thread_self (); + if (thread->kernel_thread != ktid) + { + err = __thread_set_pcsptp (thread->kernel_thread, + 1, thread->mcontext.pc, + 1, thread->mcontext.sp, + 1, thread->tcb); + assert_perror (err); + } + __mach_port_deallocate (__mach_task_self (), ktid); + + return 0; +} diff --git a/sysdeps/mach/hurd/ia32/pt-machdep.c b/sysdeps/mach/hurd/ia32/pt-machdep.c deleted file mode 100644 index f3c8cf5..0000000 --- a/sysdeps/mach/hurd/ia32/pt-machdep.c +++ /dev/null @@ -1,83 +0,0 @@ -/* Machine dependent pthreads code. Hurd/i386 version. - Copyright (C) 2000, 2002, 2007 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with the GNU C Library; see the file COPYING.LIB. If not, - write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. */ - -#include - -#include -#include -#include -#include -#include - -#define HURD_TLS_DESC_DECL(desc, tcb) \ - struct descriptor desc = \ - { /* low word: */ \ - 0xffff /* limit 0..15 */ \ - | (((unsigned int) (tcb)) << 16) /* base 0..15 */ \ - , /* high word: */ \ - ((((unsigned int) (tcb)) >> 16) & 0xff) /* base 16..23 */ \ - | ((0x12 | 0x60 | 0x80) << 8) /* access = ACC_DATA_W|ACC_PL_U|ACC_P */ \ - | (0xf << 16) /* limit 16..19 */ \ - | ((4 | 8) << 20) /* granularity = SZ_32|SZ_G */ \ - | (((unsigned int) (tcb)) & 0xff000000) /* base 24..31 */ \ - } - -int -__thread_set_pcsptp (thread_t thread, - int set_ip, void *ip, - int set_sp, void *sp, - int set_tp, void *tp) -{ - error_t err; - struct i386_thread_state state; - mach_msg_type_number_t state_count; - - state_count = i386_THREAD_STATE_COUNT; - - err = __thread_get_state (thread, i386_REGS_SEGS_STATE, - (thread_state_t) &state, &state_count); - if (err) - return err; - - if (set_sp) - state.uesp = (unsigned int) sp; - if (set_ip) - state.eip = (unsigned int) ip; - if (set_tp) { - HURD_TLS_DESC_DECL(desc, tp); - int sel; - - asm ("mov %%gs, %w0" : "=q" (sel) : "0" (0)); - if (__builtin_expect (sel, 0x48) & 4) /* LDT selector */ - err = __i386_set_ldt (thread, sel, &desc, 1); - else - err = __i386_set_gdt (thread, &sel, desc); - if (err) - return err; - state.gs = sel; - } - - err = __thread_set_state (thread, i386_REGS_SEGS_STATE, - (thread_state_t) &state, - i386_THREAD_STATE_COUNT); - if (err) - return err; - - return 0; -} diff --git a/sysdeps/mach/hurd/ia32/pt-setup.c b/sysdeps/mach/hurd/ia32/pt-setup.c deleted file mode 100644 index 73fd43d..0000000 --- a/sysdeps/mach/hurd/ia32/pt-setup.c +++ /dev/null @@ -1,106 +0,0 @@ -/* Setup thread stack. Hurd/i386 version. - Copyright (C) 2000, 2002, 2005, 2007, 2008 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with the GNU C Library; see the file COPYING.LIB. If not, - write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. */ - -#include -#include -#include - -#include - -/* The stack layout used on the i386 is: - - ----------------- - | ARG | - ----------------- - | START_ROUTINE | - ----------------- - | 0 | - ----------------- - | | - | Fast TSD | - | | - ----------------- - - We need to reserve __hurd_threadvar_max `unsigned long int's' of - (fast) thread-specific data (TSD) for the Hurd. */ - -/* Set up the stack for THREAD, such that it appears as if - START_ROUTINE and ARG were passed to the new thread's entry-point. - Return the stack pointer for the new thread. */ -static void * -stack_setup (struct __pthread *thread, - void *(*start_routine)(void *), void *arg) -{ - error_t err; - uintptr_t *bottom, *top; - - /* Calculate the top of the new stack. */ - bottom = thread->stackaddr; - top = (uintptr_t *) ((uintptr_t) bottom + thread->stacksize); - - /* Next, make room for the TSDs. */ - top -= __hurd_threadvar_max; - - if (start_routine) - { - /* And then the call frame. */ - top -= 3; - top = (uintptr_t *) ((uintptr_t) top & ~0xf); - top[2] = (uintptr_t) arg; /* Argument to START_ROUTINE. */ - top[1] = (uintptr_t) start_routine; - top[0] = (uintptr_t) thread; - *--top = 0; /* Fake return address. */ - } - - if (thread->guardsize) - { - err = __vm_protect (__mach_task_self (), (vm_address_t) bottom, - thread->guardsize, 0, 0); - assert_perror (err); - } - - return top; -} - -int -__pthread_setup (struct __pthread *thread, - void (*entry_point)(struct __pthread *, void *(*)(void *), void *), - void *(*start_routine)(void *), void *arg) -{ - error_t err; - mach_port_t ktid; - - thread->mcontext.pc = entry_point; - thread->mcontext.sp = stack_setup (thread, start_routine, arg); - - thread->tcb->self = thread->kernel_thread; - - ktid = __mach_thread_self (); - if (thread->kernel_thread != ktid) - { - err = __thread_set_pcsptp (thread->kernel_thread, - 1, thread->mcontext.pc, - 1, thread->mcontext.sp, - 1, thread->tcb); - assert_perror (err); - } - __mach_port_deallocate (__mach_task_self (), ktid); - - return 0; -} -- cgit v1.2.3 From 640cfa0a4af3dc399bff496fd94081a99dbbcdd2 Mon Sep 17 00:00:00 2001 From: Thomas Schwinge Date: Tue, 7 Aug 2012 23:04:43 +0200 Subject: tests/Makefile: Support INSTALL_ROOT environment variable. * tests/Makefile [ifdef INSTALL_ROOT] (INSTALL_ROOT_CPPFLAGS) (INSTALL_ROOT_LDFLAGS): New variables. (%.o: %.c, %: %.o): New rules. (%-static: %.o): Update rule. * tests/README: Update. --- tests/Makefile | 13 ++++++++++++- tests/README | 6 ++++++ 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 tests/README diff --git a/tests/Makefile b/tests/Makefile index 5ebc01d..7177ad1 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -1,3 +1,8 @@ +ifdef INSTALL_ROOT +INSTALL_ROOT_CPPFLAGS = -isystem $(INSTALL_ROOT)/include +INSTALL_ROOT_LDFLAGS = -L$(INSTALL_ROOT)/lib -Wl,-rpath,$(INSTALL_ROOT)/lib +endif + CFLAGS=-Wall -g LDLIBS = -lpthread @@ -10,8 +15,14 @@ CHECK_OBJS := $(addsuffix .o,$(basename $(notdir $(CHECK_SRC)))) CHECK_PROGS := $(basename $(notdir $(CHECK_SRC))) \ $(addsuffix -static, $(basename $(CHECK_SRC))) +%.o: %.c + $(CC) $(INSTALL_ROOT_CPPFLAGS) $(CPPFLAGS) $(CFLAGS) $< -c -o $@ + +%: %.o + $(CC) $(INSTALL_ROOT_LDFLAGS) $(LDFLAGS) $< -o $@ $(LDLIBS) + %-static: %.o - $(CC) -static $(CFLAGS) $(LDFLAGS) $< -o $@ $(LDLIBS) + $(CC) -static $(INSTALL_ROOT_LDFLAGS) $(LDFLAGS) $< -o $@ $(LDLIBS) check: $(CHECK_OBJS) $(CHECK_PROGS) for i in $(CHECK_PROGS); do \ diff --git a/tests/README b/tests/README new file mode 100644 index 0000000..230f1b2 --- /dev/null +++ b/tests/README @@ -0,0 +1,6 @@ +Testing of installed package: + + $ [libpthread]/configure --prefix=[install_root] + $ make + $ make install + $ make -C [libpthread]/tests/ INSTALL_ROOT=[install_root] clean check -- cgit v1.2.3 From 261cd65456b8785a16a45d35fd4f4cf5f7abf43a Mon Sep 17 00:00:00 2001 From: Thomas Schwinge Date: Thu, 30 Aug 2012 23:18:21 +0200 Subject: Initialize. --- .topdeps | 1 + .topmsg | 14 ++++++++++++++ 2 files changed, 15 insertions(+) create mode 100644 .topdeps create mode 100644 .topmsg diff --git a/.topdeps b/.topdeps new file mode 100644 index 0000000..ae89672 --- /dev/null +++ b/.topdeps @@ -0,0 +1 @@ +081c7aeb4d4de82ab615db565c60dd776a385c34 diff --git a/.topmsg b/.topmsg new file mode 100644 index 0000000..6669004 --- /dev/null +++ b/.topmsg @@ -0,0 +1,14 @@ +Subject: Baseline for our topic branches. + +--- + +This need not strictly be a TopGit branch, but it is for easy synchronization +between different machines. + +As the baseline is merged into the topic branches, it is forward-only. + +To advance it: + + $ echo [SHA1] > .topdeps + $ git commit -m Advance. -- .topdeps + $ tg update -- cgit v1.2.3 From d3f9d546c97402cd7d039fb6f3e3242327805784 Mon Sep 17 00:00:00 2001 From: Thomas Schwinge Date: Thu, 30 Aug 2012 23:28:58 +0200 Subject: Advance. --- .topdeps | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.topdeps b/.topdeps index ae89672..17c6c67 100644 --- a/.topdeps +++ b/.topdeps @@ -1 +1 @@ -081c7aeb4d4de82ab615db565c60dd776a385c34 +640cfa0a4af3dc399bff496fd94081a99dbbcdd2 -- cgit v1.2.3