diff options
author | rpj <rpj> | 1999-01-03 18:47:50 +0000 |
---|---|---|
committer | rpj <rpj> | 1999-01-03 18:47:50 +0000 |
commit | 36f0ed4155fdab7b12c5c5ddf4252170fac0a77e (patch) | |
tree | 2d8ed62df0b72d42a74b383d389ee7c28a0324da /semaphore.h | |
parent | 4650bcf1f1efd88a0c8f502c28945bfabd7ef6db (diff) |
Merge John Bossom's code into the main trunk. See ChangeLog for details.snapshot-1999-01-04-1305
This will be tagged as snapshot-1999-01-04-1305
Diffstat (limited to 'semaphore.h')
-rw-r--r-- | semaphore.h | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/semaphore.h b/semaphore.h new file mode 100644 index 0000000..5eeaf3c --- /dev/null +++ b/semaphore.h @@ -0,0 +1,52 @@ +/* + * ------------------------------------------------------------- + * + * Module: semaphore.h + * + * Purpose: + * Semaphores aren't actually part of the PThreads standard. + * They are defined by the POSIX Standard: + * + * POSIX 1003.1b-1993 (POSIX.1b) + * + * They are supposed to follow the older UNIX convention for + * reporting errors. That is, on failure they are supposed + * to return a value of -1 and store the appropriate error + * number into 'errno'. + * HOWEVER,errno cannot be modified in a multithreaded + * program on WIN32; therefore, the value is returned as + * the function value. + * It is recommended that you compare for zero (0) for success + * instead of -1 for failure when checking the status of + * these functions. + * + * ------------------------------------------------------------- + */ +#if !defined( SEMAPHORE_H ) +#define SEMAPHORE_H + +#include <process.h> +#include <errno.h> + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +typedef HANDLE sem_t; + +int sem_init (sem_t * sem, int pshared, unsigned int value); + +int sem_destroy (sem_t * sem); + +int sem_trywait (sem_t * sem); + +int sem_wait (sem_t * sem); + +int sem_post (sem_t * sem); + +#ifdef __cplusplus +} /* End of extern "C" */ +#endif /* __cplusplus */ + +#endif /* !SEMAPHORE_H */ |