summaryrefslogtreecommitdiff
path: root/semaphore.h
blob: 7b9d352aff9cb4217438a0fcc507efb63241918c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/*
 * -------------------------------------------------------------
 *
 * $Header: /cvs/pthreads-win32/pthreads/semaphore.h,v 1.1.2.1 1998/12/28 23:01:15 rpj Exp $
 *
 * 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.
 *
 * Disclaimer:
 *      This software is provided "as is".
 *
 *      The author makes no warranty or representation, either
 *      express or implied, with respect to this software, its
 *      quality, performance, merchantability, or fitness for a
 *      particular purpose. In no event will the author be
 *      liable for direct, indirect, special, incidental, or
 *      consequential damages arising out of the use or inability
 *      to use the software.
 *
 * -------------------------------------------------------------
 */
#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 */