source: rtems/cpukit/posix/include/rtems/posix/semaphoreimpl.h @ dce48791

5
Last change on this file since dce48791 was dce48791, checked in by Sebastian Huber <sebastian.huber@…>, on 05/23/16 at 11:37:59

score: Add Status_Control for all APIs

Unify the status codes of the Classic and POSIX API to use the new enum
Status_Control. This eliminates the Thread_Control::Wait::timeout_code
field and the timeout parameter of _Thread_queue_Enqueue_critical() and
_MPCI_Send_request_packet(). It gets rid of the status code translation
tables and instead uses simple bit operations to get the status for a
particular API. This enables translation of status code constants at
compile time. Add _Thread_Wait_get_status() to avoid direct access of
thread internal data structures.

  • Property mode set to 100644
File size: 3.1 KB
Line 
1/**
2 * @file
3 *
4 * @brief Private Inlined Routines for POSIX Semaphores
5 *
6 * This include file contains the static inline implementation of the private
7 * inlined routines for POSIX Semaphores.
8 */
9
10/*
11 *  COPYRIGHT (c) 1989-2013.
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 _RTEMS_POSIX_SEMAPHOREIMPL_H
20#define _RTEMS_POSIX_SEMAPHOREIMPL_H
21
22#include <rtems/posix/semaphore.h>
23#include <rtems/posix/posixapi.h>
24#include <rtems/score/coresemimpl.h>
25#include <rtems/seterr.h>
26
27#ifdef __cplusplus
28extern "C" {
29#endif
30
31/**
32 *  This defines the information control block used to manage
33 *  this class of objects.
34 */
35extern Objects_Information _POSIX_Semaphore_Information;
36
37RTEMS_INLINE_ROUTINE POSIX_Semaphore_Control *
38  _POSIX_Semaphore_Allocate_unprotected( void )
39{
40  return (POSIX_Semaphore_Control *)
41    _Objects_Allocate_unprotected( &_POSIX_Semaphore_Information );
42}
43
44/**
45 *  @brief POSIX Semaphore Free
46 *
47 *  This routine frees a semaphore control block to the
48 *  inactive chain of free semaphore control blocks.
49 */
50RTEMS_INLINE_ROUTINE void _POSIX_Semaphore_Free (
51  POSIX_Semaphore_Control *the_semaphore
52)
53{
54  _Objects_Free( &_POSIX_Semaphore_Information, &the_semaphore->Object );
55}
56
57RTEMS_INLINE_ROUTINE POSIX_Semaphore_Control *_POSIX_Semaphore_Get(
58  const sem_t          *id,
59  Thread_queue_Context *queue_context
60)
61{
62  _Thread_queue_Context_initialize( queue_context, NULL );
63  return (POSIX_Semaphore_Control *) _Objects_Get(
64    (Objects_Id) *id,
65    &queue_context->Lock_context,
66    &_POSIX_Semaphore_Information
67  );
68}
69
70/**
71 *  @brief POSIX Semaphore Create Support
72 *
73 *  This routine supports the sem_init and sem_open routines.
74 */
75
76int _POSIX_Semaphore_Create_support(
77  const char                *name,
78  size_t                     name_len,
79  int                        pshared,
80  unsigned int               value,
81  POSIX_Semaphore_Control  **the_sem
82);
83
84/**
85 *  @brief POSIX Semaphore Delete
86 *
87 * This routine supports the sem_close and sem_unlink routines.
88 */
89void _POSIX_Semaphore_Delete(
90  POSIX_Semaphore_Control *the_semaphore,
91  Thread_queue_Context    *queue_context
92);
93
94/**
95 * @brief POSIX semaphore wait support.
96 *
97 * This routine supports the sem_wait, sem_trywait, and sem_timedwait
98 * services.
99 */
100int _POSIX_Semaphore_Wait_support(
101  sem_t               *sem,
102  bool                 blocking,
103  Watchdog_Interval    timeout
104);
105 
106/**
107 *  @brief POSIX Semaphore Namespace Remove
108 */
109RTEMS_INLINE_ROUTINE void _POSIX_Semaphore_Namespace_remove (
110  POSIX_Semaphore_Control *the_semaphore
111)
112{
113  _Objects_Namespace_remove(
114    &_POSIX_Semaphore_Information, &the_semaphore->Object );
115}
116
117RTEMS_INLINE_ROUTINE POSIX_Semaphore_Control *_POSIX_Semaphore_Get_by_name(
118  const char                *name,
119  size_t                    *name_length_p,
120  Objects_Get_by_name_error *error
121)
122{
123  return (POSIX_Semaphore_Control *) _Objects_Get_by_name(
124    &_POSIX_Semaphore_Information,
125    name,
126    name_length_p,
127    error
128  );
129}
130
131#ifdef __cplusplus
132}
133#endif
134
135#endif
136/*  end of include file */
Note: See TracBrowser for help on using the repository browser.