source: rtems/cpukit/posix/include/semaphore.h @ c499856

4.115
Last change on this file since c499856 was c499856, checked in by Chris Johns <chrisj@…>, on 03/20/14 at 21:10:47

Change all references of rtems.com to rtems.org.

  • Property mode set to 100644
File size: 2.6 KB
Line 
1/**
2 * @file
3 *
4 * @brief Private Support Information for POSIX Semaphores
5 *
6 * This file contains definitions that are internal to the RTEMS
7 * implementation of POSIX Semaphores.
8 */
9
10/*
11 *  COPYRIGHT (c) 1989-2011.
12 *  On-Line Applications Research Corporation (OAR).
13 *
14 *  The license and distribution terms for this file may be
15 *  found in the file LICENSE in this distribution or at
16 *  http://www.rtems.org/license/LICENSE.
17 */
18
19#ifndef _SEMAPHORE_H
20#define _SEMAPHORE_H
21
22#ifdef __cplusplus
23extern "C" {
24#endif
25
26/**
27 * @defgroup POSIX_SEMAPHORE POSIX Semaphores Support
28 *
29 * @ingroup POSIXAPI
30 *
31 * @brief Private Support Information for POSIX Semaphores
32 */
33
34#include <unistd.h>
35
36#if defined(_POSIX_SEMAPHORES)
37
38#include <sys/time.h>
39
40/*
41 *  11.1 Semaphore Characteristics, P1003.1b-1993, p.219
42 */
43typedef int sem_t;
44
45/*
46 *  Bad semaphore Id
47 */
48#define SEM_FAILED (sem_t *) -1
49
50/*
51 *  11.2.1 Initialize an Unnamed Semaphore, P1003.1b-1993, p.219
52 */
53int sem_init(
54  sem_t         *sem,
55  int            pshared,
56  unsigned int   value
57);
58
59/**
60 * @brief Destroy an unnamed semaphore.
61 *
62 * 11.2.2 Destroy an Unnamed Semaphore, P1003.1b-1993, p.220
63 */
64int sem_destroy(
65  sem_t *sem
66);
67
68/*
69 *  11.2.3 Initialize/Open a Named Semaphore, P1003.1b-1993, p.221
70 *
71 *  NOTE: Follows open() calling conventions.
72 */
73sem_t *sem_open(
74  const char *name,
75  int         oflag,
76  ...
77);
78
79/**
80 * @brief Close a named semaphore.
81 *
82 * Routine to close a semaphore that has been opened or initialized.
83 *
84 * 11.2.4 Close a Named Semaphore, P1003.1b-1993, p.224
85 */
86int sem_close(
87  sem_t *sem
88);
89
90/**
91 * @brief Remove a named semaphore.
92 *
93 * Unlinks a named semaphore, sem_close must also be called to remove
94 * the semaphore.
95 *
96 * 11.2.5 Remove a Named Semaphore, P1003.1b-1993, p.225
97 */
98int sem_unlink(
99  const char *name
100);
101
102/**
103 * @brief Lock a semaphore.
104 *
105 * 11.2.6 Lock a Semaphore, P1003.1b-1993, p.226
106 *
107 * NOTE: P1003.4b/D8 adds sem_timedwait(), p. 27
108 */
109int sem_wait(
110  sem_t *sem
111);
112
113/**
114 * @brief Lock a semaphore.
115 *
116 * @see sem_wait()
117 */
118int sem_trywait(
119  sem_t *sem
120);
121
122#if defined(_POSIX_TIMEOUTS)
123/**
124 * @brief Lock a semaphore.
125 */
126int sem_timedwait(
127  sem_t                 *__restrict sem,
128  const struct timespec *__restrict timeout
129);
130#endif
131
132/**
133 * @brief Unlock a semaphore.
134 *
135 * 11.2.7 Unlock a Semaphore, P1003.1b-1993, p.227
136 */
137int sem_post(
138  sem_t  *sem
139);
140
141/**
142 * @brief Get the value of a semaphore.
143 *
144 * 11.2.8 Get the Value of a Semaphore, P1003.1b-1993, p.229
145 */
146int sem_getvalue(
147  sem_t  *__restrict sem,
148  int    *__restrict sval
149);
150
151#endif   /* _POSIX_SEMAPHORES */
152
153#ifdef __cplusplus
154}
155#endif
156
157#endif
158/* end of include file */
Note: See TracBrowser for help on using the repository browser.