summaryrefslogtreecommitdiff
path: root/libthreads
diff options
context:
space:
mode:
authorRoland McGrath <roland@gnu.org>1994-05-04 11:00:38 +0000
committerRoland McGrath <roland@gnu.org>1994-05-04 11:00:38 +0000
commita8f858295ef8cebe8575ab2729aaf71401d24b88 (patch)
treef7d16ed5f3fa3563e0894adf62ec664bfd0066d5 /libthreads
parent32300c7136abe31b7ba6598477f343ddbc4adb67 (diff)
Formerly cthreads.h.~3~
Diffstat (limited to 'libthreads')
-rw-r--r--libthreads/cthreads.h23
1 files changed, 22 insertions, 1 deletions
diff --git a/libthreads/cthreads.h b/libthreads/cthreads.h
index fed57250..d642ae9b 100644
--- a/libthreads/cthreads.h
+++ b/libthreads/cthreads.h
@@ -167,7 +167,14 @@
/* MIB XXX */
#define CTHREAD_DATA
+#if 0
+/* This is CMU's machine-dependent file. In GNU all of the machine
+ dependencies are dealt with in libc. */
#include <machine/cthreads.h>
+#else
+#include <machine-sp.h>
+#define cthread_sp() ((int) __thread_stack_pointer ())
+#endif
#if c_plusplus || __STDC__
@@ -271,6 +278,14 @@ typedef struct cthread_queue_item {
} \
MACRO_END
+#if 1
+
+/* In GNU, spin locks are implemented in libc.
+ Just include its header file. */
+#include <spin-lock.h>
+
+#else /* Unused CMU code. */
+
/*
* Spin locks.
*/
@@ -289,14 +304,20 @@ spin_try_lock C_ARG_DECLS((spin_lock_t *p));
#define spin_lock(p) ({if (!spin_try_lock(p)) spin_lock_solid(p);})
+#endif /* End unused CMU code. */
+
/*
* Mutex objects.
*/
typedef struct mutex {
+ /* The `held' member must be first in GNU. The GNU C library relies on
+ being able to cast a `struct mutex *' to a `spin_lock_t *' (which is
+ kosher if it is the first member) and spin_try_lock that address to
+ see if it gets the mutex. */
+ spin_lock_t held;
spin_lock_t lock;
char *name;
struct cthread_queue queue;
- spin_lock_t held;
} *mutex_t;
#define MUTEX_INITIALIZER { SPIN_LOCK_INITIALIZER, 0, QUEUE_INITIALIZER, SPIN_LOCK_INITIALIZER}