RTEMS 6.1-rc5
Loading...
Searching...
No Matches
posixapi.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: BSD-2-Clause */
2
12/*
13 * COPYRIGHT (c) 1989-2011.
14 * On-Line Applications Research Corporation (OAR).
15 *
16 * Redistribution and use in source and binary forms, with or without
17 * modification, are permitted provided that the following conditions
18 * are met:
19 * 1. Redistributions of source code must retain the above copyright
20 * notice, this list of conditions and the following disclaimer.
21 * 2. Redistributions in binary form must reproduce the above copyright
22 * notice, this list of conditions and the following disclaimer in the
23 * documentation and/or other materials provided with the distribution.
24 *
25 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
26 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
29 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35 * POSSIBILITY OF SUCH DAMAGE.
36 */
37
38#ifndef _RTEMS_POSIX_POSIXAPI_H
39#define _RTEMS_POSIX_POSIXAPI_H
40
41#include <rtems/config.h>
42#include <rtems/score/assert.h>
45#include <rtems/seterr.h>
46
47#include <pthread.h>
48
60extern const int _POSIX_Get_by_name_error_table[ 3 ];
61
62static inline int _POSIX_Get_by_name_error(
63 Objects_Get_by_name_error error
64)
65{
66 _Assert( (size_t) error < RTEMS_ARRAY_SIZE( _POSIX_Get_by_name_error_table ) );
67 return _POSIX_Get_by_name_error_table[ error ];
68}
69
70static inline int _POSIX_Get_error( Status_Control status )
71{
72 return STATUS_GET_POSIX( status );
73}
74
75static inline int _POSIX_Get_error_after_wait(
76 const Thread_Control *executing
77)
78{
79 return _POSIX_Get_error( _Thread_Wait_get_status( executing ) );
80}
81
82static inline int _POSIX_Zero_or_minus_one_plus_errno(
83 Status_Control status
84)
85{
86 if ( status == STATUS_SUCCESSFUL ) {
87 return 0;
88 }
89
90 rtems_set_errno_and_return_minus_one( _POSIX_Get_error( status ) );
91}
92
93/*
94 * See also The Open Group Base Specifications Issue 7, IEEE Std 1003.1-2008,
95 * 2016 Edition, subsection 2.9.9, Synchronization Object Copies and
96 * Alternative Mappings.
97 *
98 * http://pubs.opengroup.org/onlinepubs/9699919799/functions/V2_chap02.html#tag_15_09_09
99 */
100static inline bool _POSIX_Is_valid_pshared( int pshared )
101{
102 return pshared == PTHREAD_PROCESS_PRIVATE ||
103 pshared == PTHREAD_PROCESS_SHARED;
104}
105
108#endif
109/* end of include file */
This header file provides the interfaces of the Assert Handler.
#define RTEMS_ARRAY_SIZE(_array)
Gets the element count of the array.
Definition: basedefs.h:244
#define rtems_set_errno_and_return_minus_one(_error)
Definition: seterr.h:67
#define _Assert(_e)
Assertion similar to assert() controlled via RTEMS_DEBUG instead of NDEBUG and static analysis runs.
Definition: assert.h:96
Status_Control
Status codes.
Definition: status.h:111
#define STATUS_GET_POSIX(status)
Macro to get the POSIX API status code.
Definition: status.h:105
POSIX Threads Private Support.
This header file provides interfaces of the Object Handler which are only used by the implementation.
This header file defines macros to set errno and return minus one.
Definition: thread.h:837
This header file provides interfaces of the Thread Handler which are only used by the implementation.