source: rtems/cpukit/posix/include/rtems/posix/semaphore.h @ 860c34e

4.104.114.9
Last change on this file since 860c34e was 860c34e, checked in by Glenn Humphrey <glenn.humphrey@…>, on Nov 30, 2007 at 8:34:13 PM

2007-11-30 Glenn Humphrey <glenn.humphrey@…>

  • posix/include/rtems/posix/mutex.h, posix/include/rtems/posix/semaphore.h, posix/src/cancel.c, posix/src/conddestroy.c, posix/src/condsignalsupp.c, posix/src/condwaitsupp.c, posix/src/keydelete.c, posix/src/keygetspecific.c, posix/src/keysetspecific.c, posix/src/mqueueclose.c, posix/src/mqueuegetattr.c, posix/src/mqueuenotify.c, posix/src/mqueuerecvsupp.c, posix/src/mqueuesendsupp.c, posix/src/mqueuesetattr.c, posix/src/mqueuetranslatereturncode.c, posix/src/mutexdestroy.c, posix/src/mutexgetprioceiling.c, posix/src/mutexinit.c, posix/src/mutexlocksupp.c, posix/src/mutexsetprioceiling.c, posix/src/mutexunlock.c, posix/src/pbarrierdestroy.c, posix/src/pbarriertranslatereturncode.c, posix/src/pbarrierwait.c, posix/src/prwlockdestroy.c, posix/src/prwlockrdlock.c, posix/src/prwlocktimedrdlock.c, posix/src/prwlocktimedwrlock.c, posix/src/prwlocktranslatereturncode.c, posix/src/prwlocktryrdlock.c, posix/src/prwlocktrywrlock.c, posix/src/prwlockunlock.c, posix/src/prwlockwrlock.c, posix/src/pspindestroy.c, posix/src/pspinlock.c, posix/src/pspinlocktranslatereturncode.c, posix/src/pspintrylock.c, posix/src/pspinunlock.c, posix/src/pthreaddetach.c, posix/src/pthreadequal.c, posix/src/pthreadgetschedparam.c, posix/src/pthreadjoin.c, posix/src/pthreadkill.c, posix/src/pthreadsetschedparam.c, posix/src/ptimer1.c, posix/src/semaphorewaitsupp.c, posix/src/semclose.c, posix/src/semdestroy.c, posix/src/semgetvalue.c, posix/src/sempost.c, posix/src/types.c, rtems/src/msgqtranslatereturncode.c, rtems/src/semobtain.c, rtems/src/timerfireafter.c, score/include/rtems/system.h, score/include/rtems/score/corebarrier.h, score/include/rtems/score/coremsg.h, score/include/rtems/score/coremutex.h, score/include/rtems/score/coresem.h: Restructed to move the OBJECTS_LOCAL case to the top of the switch statement and eliminate the fall-through return of POSIX_BOTTOM_REACHED. These changes produced simplier assembly code and allowed for complete test coverage. Also applied some consistency to the functions that translate the core status codes to POSIX status codes.
  • posix/src/mutextranslatereturncode.c, posix/src/semaphoretranslatereturncode.c: New files.
  • posix/src/mutexfromcorestatus.c: Removed.
  • Property mode set to 100644
File size: 4.2 KB
Line 
1/**
2 * @file rtems/posix/semaphore.h
3 */
4
5/*  rtems/posix/semaphore.h
6 *
7 *  This include file contains all the private support information for
8 *  POSIX Semaphores.
9 *
10 *  COPYRIGHT (c) 1989-2007.
11 *  On-Line Applications Research Corporation (OAR).
12 *
13 *  The license and distribution terms for this file may be
14 *  found in the file LICENSE in this distribution or at
15 *  http://www.rtems.com/license/LICENSE.
16 *
17 *  $Id$
18 */
19
20#ifndef _RTEMS_POSIX_SEMAPHORE_H
21#define _RTEMS_POSIX_SEMAPHORE_H
22
23#ifdef __cplusplus
24extern "C" {
25#endif
26
27#include <semaphore.h>
28#include <rtems/score/coresem.h>
29
30#define SEM_FAILED (sem_t *) -1
31
32/*
33 *  Data Structure used to manage a POSIX semaphore
34 */
35
36typedef struct {
37   Objects_Control         Object;
38   int                     process_shared;
39   boolean                 named;
40   boolean                 linked;
41   uint32_t                open_count;
42   CORE_semaphore_Control  Semaphore;
43}  POSIX_Semaphore_Control;
44
45/*
46 *  The following defines the information control block used to manage
47 *  this class of objects.
48 */
49
50POSIX_EXTERN Objects_Information  _POSIX_Semaphore_Information;
51
52/*
53 *  _POSIX_Semaphore_Manager_initialization
54 *
55 *  DESCRIPTION:
56 *
57 *  This routine performs the initialization necessary for this manager.
58 */
59
60void _POSIX_Semaphore_Manager_initialization(
61  uint32_t   maximum_semaphorees
62);
63
64/*
65 *  _POSIX_Semaphore_Allocate
66 *
67 *  DESCRIPTION:
68 *
69 *  This function allocates a semaphore control block from
70 *  the inactive chain of free semaphore control blocks.
71 */
72
73RTEMS_INLINE_ROUTINE POSIX_Semaphore_Control *_POSIX_Semaphore_Allocate( void );
74
75/*
76 *  _POSIX_Semaphore_Free
77 *
78 *  DESCRIPTION:
79 *
80 *  This routine frees a semaphore control block to the
81 *  inactive chain of free semaphore control blocks.
82 */
83
84RTEMS_INLINE_ROUTINE void _POSIX_Semaphore_Free (
85  POSIX_Semaphore_Control *the_semaphore
86);
87
88/*
89 *  _POSIX_Semaphore_Get
90 *
91 *  DESCRIPTION:
92 *
93 *  This function maps semaphore IDs to semaphore control blocks.
94 *  If ID corresponds to a local semaphore, then it returns
95 *  the_semaphore control pointer which maps to ID and location
96 *  is set to OBJECTS_LOCAL.  if the semaphore ID is global and
97 *  resides on a remote node, then location is set to OBJECTS_REMOTE,
98 *  and the_semaphore is undefined.  Otherwise, location is set
99 *  to OBJECTS_ERROR and the_semaphore is undefined.
100 */
101
102RTEMS_INLINE_ROUTINE POSIX_Semaphore_Control *_POSIX_Semaphore_Get (
103  sem_t        *id,
104  Objects_Locations *location
105);
106
107/*
108 *  _POSIX_Semaphore_Is_null
109 *
110 *  DESCRIPTION:
111 *
112 *  This function returns TRUE if the_semaphore is NULL and FALSE otherwise.
113 */
114
115RTEMS_INLINE_ROUTINE boolean _POSIX_Semaphore_Is_null (
116  POSIX_Semaphore_Control *the_semaphore
117);
118
119/*
120 *  _POSIX_Semaphore_Create_support
121 *
122 *  DESCRIPTION:
123 *
124 *  This routine supports the sem_init and sem_open routines.
125 */
126
127int _POSIX_Semaphore_Create_support(
128  const char                *name,
129  int                        pshared,
130  unsigned int               value,
131  POSIX_Semaphore_Control  **the_sem
132);
133
134/*
135 *  _POSIX_Semaphore_Delete
136 *
137 *  DESCRIPTION:
138 *
139 *  This routine supports the sem_close and sem_unlink routines.
140 */
141
142void _POSIX_Semaphore_Delete(
143  POSIX_Semaphore_Control *the_semaphore
144);
145
146/*
147 *  _POSIX_Semaphore_Wait_support
148 *
149 *  DESCRIPTION:
150 *
151 *  This routine supports the sem_wait, sem_trywait, and sem_timedwait
152 *  services.
153 */
154
155int _POSIX_Semaphore_Wait_support(
156  sem_t                          *sem,
157  Core_semaphore_Blocking_option  blocking,
158  Watchdog_Interval               timeout
159);
160
161/*
162 *  _POSIX_Semaphore_Name_to_id
163 *
164 *  DESCRIPTION:
165 *
166 *  This routine performs name to id translation.
167 */
168
169int _POSIX_Semaphore_Name_to_id(
170  const char          *name,
171  sem_t          *id
172);
173
174/*
175 *  _POSIX_Semaphore_Translate_core_semaphore_return_code
176 *
177 *  DESCRIPTION:
178 *
179 *  A support routine which converts core semaphore status codes into the
180 *  appropriate POSIX status values.
181 */
182
183int _POSIX_Semaphore_Translate_core_semaphore_return_code(
184  CORE_semaphore_Status  the_semaphore_status
185);
186
187#include <rtems/posix/semaphore.inl>
188#if defined(RTEMS_MULTIPROCESSING)
189#include <rtems/posix/semaphoremp.h>
190#endif
191
192#ifdef __cplusplus
193}
194#endif
195
196#endif
197/*  end of include file */
Note: See TracBrowser for help on using the repository browser.