summaryrefslogtreecommitdiff
path: root/PACE/pace/semaphore.h
blob: 67554909b68a928cae9e20813180a19818c3fb60 (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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
/* $Id$

 * ============================================================================
 *
 * = LIBRARY
 *    pace
 *
 * = FILENAME
 *    pace/semaphore.h
 *
 * = AUTHOR
 *    Luther Baker
 *
 * ============================================================================ */

#ifndef PACE_SEMAPHORE_H
#define PACE_SEMAPHORE_H

#include "pace/config/defines.h"

#if (PACE_HAS_POSIX)
# include "pace/posix/semaphore.h"
#elif (PACE_VXWORKS)
# include "pace/vxworks/semaphore.h"
#elif (PACE_WIN32)
# include "pace/win32/semaphore.h"
#endif

#if defined (PACE_HAS_CPLUSPLUS)
extern "C" {
#endif /* PACE_HAS_CPLUSPLUS */

  /**
     PACE's implementation of the POSIX function sem_close.
     See POSIX standard (Internation Standard ISO/IEC 9945-1:1996;
     IEEE Std 1003.1, 1996 Edition), Section 11.2.4.
   */
  PACE_INLINE int pace_sem_close (pace_sem_t * sem);

  /**
     PACE's implementation of the POSIX function sem_destroy.
     See POSIX standard (Internation Standard ISO/IEC 9945-1:1996;
     IEEE Std 1003.1, 1996 Edition), Section 11.2.2.
   */
  PACE_INLINE int pace_sem_destroy (pace_sem_t * sem);

  /**
     PACE's implementation of the POSIX function sem_getvalue.
     See POSIX standard (Internation Standard ISO/IEC 9945-1:1996;
     IEEE Std 1003.1, 1996 Edition), Section 11.2.8.
   */
  PACE_INLINE int pace_sem_getvalue (pace_sem_t * sem, int * sval);

  /**
     PACE's implementation of the POSIX function sem_init.
     See POSIX standard (Internation Standard ISO/IEC 9945-1:1996;
     IEEE Std 1003.1, 1996 Edition), Section 11.2.1.
   */
  PACE_INLINE int pace_sem_init (pace_sem_t * sem, int pshared, unsigned int value);

  /**
     PACE's implementation of the POSIX function sem_open.
     See POSIX standard (Internation Standard ISO/IEC 9945-1:1996;
     IEEE Std 1003.1, 1996 Edition), Section 11.2.3.
   */
  # define pace_sem_open(X) sem_open X
  /* int fprintf (FILE *stream, const char *format, (*//* args *//*) ... );
   *
   * PLEASE PAY SPECIAL ATTENTION HERE!
   * This is a macro and requires an additional set of parenthesis
   * surrounding the arguments.
   */

  /**
     PACE's implementation of the POSIX function sem_post.
     See POSIX standard (Internation Standard ISO/IEC 9945-1:1996;
     IEEE Std 1003.1, 1996 Edition), Section 11.2.7.
   */
  PACE_INLINE int pace_sem_post (pace_sem_t * sem);

  /**
     PACE's implementation of the POSIX function sem_trywait.
     See POSIX standard (Internation Standard ISO/IEC 9945-1:1996;
     IEEE Std 1003.1, 1996 Edition), Section 11.2.6.
   */
  PACE_INLINE int pace_sem_trywait (pace_sem_t * sem);

  /**
     PACE's implementation of the POSIX function sem_unlink.
     See POSIX standard (Internation Standard ISO/IEC 9945-1:1996;
     IEEE Std 1003.1, 1996 Edition), Section 11.2.5.
   */
  PACE_INLINE int pace_sem_unlink (const char * name);

  /**
     PACE's implementation of the POSIX function sem_wait.
     See POSIX standard (Internation Standard ISO/IEC 9945-1:1996;
     IEEE Std 1003.1, 1996 Edition), Section 11.2.6.
   */
  PACE_INLINE int pace_sem_wait (pace_sem_t * sem);

#if defined (PACE_HAS_CPLUSPLUS)
}
#endif /* PACE_HAS_CPLUSPLUS */

#if defined (PACE_HAS_INLINE)
#  if (PACE_HAS_POSIX)
#    include "pace/posix/semaphore.inl"
#  elif (PACE_VXWORKS)
#    include "pace/vxworks/semaphore.inl"
#  elif (PACE_WIN32)
#    include "pace/win32/semaphore.inl"
#  endif
#endif /* PACE_HAS_INLINE */

#endif /* PACE_SEMAPHORE_H */