source: rtems/cpukit/posix/include/rtems/posix/posixapi.h @ 6cc83b32

5
Last change on this file since 6cc83b32 was 6cc83b32, checked in by Sebastian Huber <sebastian.huber@…>, on 12/02/16 at 11:40:32

posix: Fix typo

  • Property mode set to 100644
File size: 3.0 KB
Line 
1/**
2 * @file
3 *
4 * @brief POSIX API Implementation
5 *
6 * This include file defines the top level interface to the POSIX API
7 * implementation in RTEMS.
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 _RTEMS_POSIX_POSIXAPI_H
20#define _RTEMS_POSIX_POSIXAPI_H
21
22#include <rtems/config.h>
23#include <rtems/score/assert.h>
24#include <rtems/score/apimutex.h>
25#include <rtems/score/objectimpl.h>
26#include <rtems/score/threadimpl.h>
27#include <rtems/seterr.h>
28
29/**
30 * @defgroup POSIXAPI RTEMS POSIX API
31 *
32 * RTEMS POSIX API definitions and modules.
33 *
34 */
35/**@{**/
36
37/**
38 * @brief POSIX API Fatal domains.
39 */
40typedef enum {
41  POSIX_FD_PTHREAD,      /**< A pthread thread error. */
42  POSIX_FD_PTHREAD_ONCE  /**< A pthread once error. */
43} POSIX_Fatal_domain;
44
45/**
46 * @brief POSIX API Fatal error.
47 *
48 * A common method of rasing a POSIX API fatal error.
49 *
50 * @param[in] domain The POSIX error domain.
51 * @param[in] eno The error number as defined in errno.h.
52 */
53void _POSIX_Fatal_error( POSIX_Fatal_domain domain, int eno );
54
55extern const int _POSIX_Get_by_name_error_table[ 3 ];
56
57RTEMS_INLINE_ROUTINE int _POSIX_Get_by_name_error(
58  Objects_Get_by_name_error error
59)
60{
61  _Assert( (size_t) error < RTEMS_ARRAY_SIZE( _POSIX_Get_by_name_error_table ) );
62  return _POSIX_Get_by_name_error_table[ error ];
63}
64
65RTEMS_INLINE_ROUTINE int _POSIX_Get_error( Status_Control status )
66{
67  return STATUS_GET_POSIX( status );
68}
69
70RTEMS_INLINE_ROUTINE int _POSIX_Get_error_after_wait(
71  const Thread_Control *executing
72)
73{
74  return _POSIX_Get_error( _Thread_Wait_get_status( executing ) );
75}
76
77RTEMS_INLINE_ROUTINE int _POSIX_Zero_or_minus_one_plus_errno(
78  Status_Control status
79)
80{
81  if ( status == STATUS_SUCCESSFUL ) {
82    return 0;
83  }
84
85  rtems_set_errno_and_return_minus_one( _POSIX_Get_error( status ) );
86}
87
88/**
89 * @brief Macro to generate a function body to get a POSIX object by
90 * identifier.
91 *
92 * Generates a function body to get the object for the specified identifier.
93 * Performs automatic initialization if requested and necessary.  This is an
94 * ugly macro, since C lacks support for templates.
95 */
96#define _POSIX_Get_object_body( \
97  type, \
98  id, \
99  queue_context, \
100  info, \
101  initializer, \
102  init \
103) \
104  Objects_Control *the_object; \
105  if ( id == NULL ) { \
106    return NULL; \
107  } \
108  _Thread_queue_Context_initialize( queue_context ); \
109  the_object = _Objects_Get( \
110    (Objects_Id) *id, \
111    &queue_context->Lock_context.Lock_context, \
112    info \
113  ); \
114  if ( the_object == NULL ) { \
115    _Once_Lock(); \
116    if ( *id == initializer ) { \
117      init( id, NULL ); \
118    } \
119    _Once_Unlock(); \
120    the_object = _Objects_Get( \
121      (Objects_Id) *id, \
122      &queue_context->Lock_context.Lock_context, \
123      info \
124    ); \
125  } \
126  return (type *) the_object
127
128/** @} */
129
130#endif
131/* end of include file */
Note: See TracBrowser for help on using the repository browser.