summaryrefslogtreecommitdiff
path: root/include/semaphore.h
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2003-02-27 18:13:05 +0000
committerEric Andersen <andersen@codepoet.org>2003-02-27 18:13:05 +0000
commit187dd78d7bd1c03fcf16e54a30314512d38e1a4a (patch)
tree9780638e5286b40da74a128c9f540a9ea720862f /include/semaphore.h
parentd4d6e2c50565da18253cd0d6f3332484142b6587 (diff)
Major update for pthreads, based in large part on improvements
from glibc 2.3. This should make threads much more efficient. -Erik
Diffstat (limited to 'include/semaphore.h')
-rw-r--r--include/semaphore.h36
1 files changed, 22 insertions, 14 deletions
diff --git a/include/semaphore.h b/include/semaphore.h
index 84742233b..9c283c864 100644
--- a/include/semaphore.h
+++ b/include/semaphore.h
@@ -17,6 +17,10 @@
#include <features.h>
#include <sys/types.h>
+#ifdef __USE_XOPEN2K
+# define __need_timespec
+# include <time.h>
+#endif
#ifndef _PTHREAD_DESCR_DEFINED
/* Thread descriptors. Needed for `sem_t' definition. */
@@ -27,11 +31,7 @@ typedef struct _pthread_descr_struct *_pthread_descr;
/* System specific semaphore definition. */
typedef struct
{
- struct
- {
- long int status;
- int spinlock;
- } __sem_lock;
+ struct _pthread_fastlock __sem_lock;
int __sem_value;
_pthread_descr __sem_waiting;
} sem_t;
@@ -49,31 +49,39 @@ __BEGIN_DECLS
/* Initialize semaphore object SEM to VALUE. If PSHARED then share it
with other processes. */
-extern int sem_init __P ((sem_t *__sem, int __pshared, unsigned int __value));
+extern int sem_init (sem_t *__sem, int __pshared, unsigned int __value) __THROW;
/* Free resources associated with semaphore object SEM. */
-extern int sem_destroy __P ((sem_t *__sem));
+extern int sem_destroy (sem_t *__sem) __THROW;
/* Open a named semaphore NAME with open flaot OFLAG. */
-extern sem_t *sem_open __P ((__const char *__name, int __oflag, ...));
+extern sem_t *sem_open (__const char *__name, int __oflag, ...) __THROW;
/* Close descriptor for named semaphore SEM. */
-extern int sem_close __P ((sem_t *__sem));
+extern int sem_close (sem_t *__sem) __THROW;
/* Remove named semaphore NAME. */
-extern int sem_unlink __P ((__const char *__name));
+extern int sem_unlink (__const char *__name) __THROW;
/* Wait for SEM being posted. */
-extern int sem_wait __P ((sem_t *__sem));
+extern int sem_wait (sem_t *__sem) __THROW;
+
+#ifdef __USE_XOPEN2K
+/* Similar to `sem_wait' but wait only until ABSTIME. */
+extern int sem_timedwait (sem_t *__restrict __sem,
+ __const struct timespec *__restrict __abstime)
+ __THROW;
+#endif
/* Test whether SEM is posted. */
-extern int sem_trywait __P ((sem_t *__sem));
+extern int sem_trywait (sem_t *__sem) __THROW;
/* Post SEM. */
-extern int sem_post __P ((sem_t *__sem));
+extern int sem_post (sem_t *__sem) __THROW;
/* Get current value of SEM and store it in *SVAL. */
-extern int sem_getvalue __P ((sem_t *__sem, int *__sval));
+extern int sem_getvalue (sem_t *__restrict __sem, int *__restrict __sval)
+ __THROW;
__END_DECLS