Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/nathanw_sa]: src/lib/libpthread Move some of the more internal types to ...
details: https://anonhg.NetBSD.org/src/rev/5c2b30b5ac49
branches: nathanw_sa
changeset: 504838:5c2b30b5ac49
user: nathanw <nathanw%NetBSD.org@localhost>
date: Fri Jul 13 02:06:29 2001 +0000
description:
Move some of the more internal types to another file, to improve
readability.
C sucks, or I'd take them out of the application visibility completely.
diffstat:
lib/libpthread/pthread.h | 22 +++---------
lib/libpthread/pthread_types.h | 71 ++++++++++++++++++++++++++++++++++++++++++
2 files changed, 77 insertions(+), 16 deletions(-)
diffs (115 lines):
diff -r ce0c8e26a9fa -r 5c2b30b5ac49 lib/libpthread/pthread.h
--- a/lib/libpthread/pthread.h Fri Jul 13 02:04:33 2001 +0000
+++ b/lib/libpthread/pthread.h Fri Jul 13 02:06:29 2001 +0000
@@ -4,22 +4,13 @@
#ifndef _LIB_PTHREAD_H
#define _LIB_PTHREAD_H
-#include "sched.h"
+
#include <sys/time.h> /* For timespec */
-
-struct pthread_st;
-struct pthread_attr_st;
-struct pthread_mutex_st;
-struct pthread_mutexattr_st;
-struct pthread_cond_st;
-struct pthread_condattr_st;
-
-typedef struct pthread_st *pthread_t;
-typedef struct pthread_attr_st *pthread_attr_t;
-typedef struct pthread_mutex_st *pthread_mutex_t;
-typedef struct pthread_mutexattr_st *pthread_mutexattr_t;
-typedef struct pthread_cond_st *pthread_cond_t;
-typedef struct pthread_condattr_st *pthread_condattr_t;
+#include <signal.h> /* For sigset_t. XXX perhaps pthread_sigmask should
+ * be in signal.h instead of here.
+ */
+#include "pthread_types.h"
+#include "sched.h"
int pthread_create(pthread_t *thread, const pthread_attr_t *attr,
void *(*startfunc)(void *), void *arg);
@@ -62,7 +53,6 @@
int *pshared);
int pthread_condattr_setpshared(pthread_condattr_t *attr, int pshared);
-#define PTHREAD_MUTEX_INITIALIZER xxxxx
#define PTHREAD_COND_INITIALIZER xxxxx
#define PTHREAD_CREATE_JOINABLE 0
diff -r ce0c8e26a9fa -r 5c2b30b5ac49 lib/libpthread/pthread_types.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/libpthread/pthread_types.h Fri Jul 13 02:06:29 2001 +0000
@@ -0,0 +1,71 @@
+/* $Id: pthread_types.h,v 1.1.2.1 2001/07/13 02:06:29 nathanw Exp $ */
+
+/*
+ * Copyright
+ */
+
+#ifndef _LIB_PTHREAD_TYPES_H
+#define _LIB_PTHREAD_TYPES_H
+
+#include <machine/lock.h>
+#include "pthread_queue.h"
+
+typedef __cpu_simple_lock_t pt_spin_t;
+
+PTQ_HEAD(pt_queue_t, pthread_st);
+
+struct pthread_st;
+struct pthread_attr_st;
+struct pthread_mutex_st;
+struct pthread_mutexattr_st;
+struct pthread_cond_st;
+struct pthread_condattr_st;
+
+typedef struct pthread_st *pthread_t;
+typedef struct pthread_attr_st pthread_attr_t;
+typedef struct pthread_mutex_st pthread_mutex_t;
+typedef struct pthread_mutexattr_st pthread_mutexattr_t;
+typedef struct pthread_cond_st pthread_cond_t;
+typedef struct pthread_condattr_st pthread_condattr_t;
+
+
+struct pthread_attr_st {
+ unsigned int pta_magic;
+
+ int pta_flags;
+};
+
+struct pthread_mutex_st {
+ unsigned int ptm_magic;
+
+ /* Not a real spinlock; will never be spun on. Locked with
+ * __cpu_simple_lock_try() or not at all. Therefore, not
+ * subject to preempted-spinlock-continuation.
+ *
+ * Open research question: Would it help threaded applications if
+ * preempted-lock-continuation were applied to mutexes?
+ */
+ pt_spin_t ptm_lock;
+
+ /* Protects the owner and blocked queue */
+ pt_spin_t ptm_interlock;
+ pthread_t ptm_owner;
+ struct pt_queue_t ptm_blocked;
+};
+
+#define PT_MUTEX_MAGIC 0xCAFEFEED
+#define PT_MUTEX_DEAD 0xFEEDDEAD
+
+#define PTHREAD_MUTEX_INITIALIZER { PT_MUTEX_MAGIC, \
+ __SIMPLELOCK_UNLOCKED, \
+ __SIMPLELOCK_UNLOCKED, \
+ NULL, \
+ PTQ_HEAD_INITIALIZER \
+ }
+
+
+struct pthread_mutexattr_st {
+ int pad;
+};
+
+#endif /* _LIB_PTHREAD_TYPES_H */
Home |
Main Index |
Thread Index |
Old Index