1 | /* SPDX-License-Identifier: BSD-2-Clause */ |
---|
2 | |
---|
3 | /** |
---|
4 | * @file |
---|
5 | * |
---|
6 | * @ingroup POSIXAPI |
---|
7 | * |
---|
8 | * @brief This header file provides interfaces used by the POSIX API |
---|
9 | * implementation. |
---|
10 | */ |
---|
11 | |
---|
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> |
---|
43 | #include <rtems/score/objectimpl.h> |
---|
44 | #include <rtems/score/threadimpl.h> |
---|
45 | #include <rtems/seterr.h> |
---|
46 | |
---|
47 | #include <pthread.h> |
---|
48 | |
---|
49 | /** |
---|
50 | * @defgroup POSIXAPI POSIX API |
---|
51 | * |
---|
52 | * @ingroup RTEMSImpl |
---|
53 | * |
---|
54 | * @brief This group contains definitions and modules which are used to |
---|
55 | * implement the POSIX APIs supported by RTEMS. |
---|
56 | * |
---|
57 | * @{ |
---|
58 | */ |
---|
59 | |
---|
60 | extern const int _POSIX_Get_by_name_error_table[ 3 ]; |
---|
61 | |
---|
62 | static 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 | |
---|
70 | static inline int _POSIX_Get_error( Status_Control status ) |
---|
71 | { |
---|
72 | return STATUS_GET_POSIX( status ); |
---|
73 | } |
---|
74 | |
---|
75 | static 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 | |
---|
82 | static 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 | */ |
---|
100 | static inline bool _POSIX_Is_valid_pshared( int pshared ) |
---|
101 | { |
---|
102 | return pshared == PTHREAD_PROCESS_PRIVATE || |
---|
103 | pshared == PTHREAD_PROCESS_SHARED; |
---|
104 | } |
---|
105 | |
---|
106 | /** @} */ |
---|
107 | |
---|
108 | #endif |
---|
109 | /* end of include file */ |
---|