source: rtems/cpukit/sapi/src/posixapi.c

Last change on this file was de59c065, checked in by Sebastian Huber <sebastian.huber@…>, on Sep 27, 2017 at 1:08:33 PM

posix: Implement self-contained POSIX mutex

POSIX mutexes are now available in all configurations and no longer
depend on --enable-posix.

Update #2514.
Update #3112.

  • Property mode set to 100644
File size: 4.2 KB
Line 
1/**
2 * @file
3 *
4 * @brief Initialize POSIX API
5 *
6 * @ingroup ClassicRTEMS
7 */
8
9/*
10 *  COPYRIGHT (c) 1989-2014.
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.org/license/LICENSE.
16 */
17
18#if HAVE_CONFIG_H
19#include "config.h"
20#endif
21
22#include <rtems/posix/posixapi.h>
23#include <rtems/posix/barrierimpl.h>
24#include <rtems/posix/condimpl.h>
25#include <rtems/posix/muteximpl.h>
26#include <rtems/posix/rwlockimpl.h>
27#include <rtems/posix/semaphoreimpl.h>
28#include <rtems/score/heap.h>
29
30#ifdef HEAP_PROTECTION
31RTEMS_STATIC_ASSERT(
32  POSIX_SEMAPHORE_MAGIC != HEAP_BEGIN_PROTECTOR_0,
33  POSIX_SEMAPHORE_MAGIC_0
34);
35RTEMS_STATIC_ASSERT(
36  POSIX_SEMAPHORE_MAGIC != HEAP_BEGIN_PROTECTOR_1,
37  POSIX_SEMAPHORE_MAGIC_1
38);
39RTEMS_STATIC_ASSERT(
40  POSIX_SEMAPHORE_MAGIC != HEAP_END_PROTECTOR_0,
41  POSIX_SEMAPHORE_MAGIC_2
42);
43RTEMS_STATIC_ASSERT(
44  POSIX_SEMAPHORE_MAGIC != HEAP_END_PROTECTOR_1,
45  POSIX_SEMAPHORE_MAGIC_3
46);
47RTEMS_STATIC_ASSERT(
48  POSIX_SEMAPHORE_MAGIC != HEAP_FREE_PATTERN,
49  POSIX_SEMAPHORE_MAGIC_4
50);
51RTEMS_STATIC_ASSERT(
52  POSIX_BARRIER_MAGIC != HEAP_BEGIN_PROTECTOR_0,
53  POSIX_BARRIER_MAGIC_0
54);
55RTEMS_STATIC_ASSERT(
56  POSIX_BARRIER_MAGIC != HEAP_BEGIN_PROTECTOR_1,
57  POSIX_BARRIER_MAGIC_1
58);
59RTEMS_STATIC_ASSERT(
60  POSIX_BARRIER_MAGIC != HEAP_END_PROTECTOR_0,
61  POSIX_BARRIER_MAGIC_2
62);
63RTEMS_STATIC_ASSERT(
64  POSIX_BARRIER_MAGIC != HEAP_END_PROTECTOR_1,
65  POSIX_BARRIER_MAGIC_3
66);
67RTEMS_STATIC_ASSERT(
68  POSIX_BARRIER_MAGIC != HEAP_FREE_PATTERN,
69  POSIX_BARRIER_MAGIC_4
70);
71RTEMS_STATIC_ASSERT(
72  POSIX_RWLOCK_MAGIC != HEAP_BEGIN_PROTECTOR_0,
73  POSIX_RWLOCK_MAGIC_0
74);
75RTEMS_STATIC_ASSERT(
76  POSIX_RWLOCK_MAGIC != HEAP_BEGIN_PROTECTOR_1,
77  POSIX_RWLOCK_MAGIC_1
78);
79RTEMS_STATIC_ASSERT(
80  POSIX_RWLOCK_MAGIC != HEAP_END_PROTECTOR_0,
81  POSIX_RWLOCK_MAGIC_2
82);
83RTEMS_STATIC_ASSERT(
84  POSIX_RWLOCK_MAGIC != HEAP_END_PROTECTOR_1,
85  POSIX_RWLOCK_MAGIC_3
86);
87RTEMS_STATIC_ASSERT(
88  POSIX_RWLOCK_MAGIC != HEAP_FREE_PATTERN,
89  POSIX_RWLOCK_MAGIC_4
90);
91RTEMS_STATIC_ASSERT(
92  POSIX_CONDITION_VARIABLES_MAGIC != HEAP_BEGIN_PROTECTOR_0,
93  POSIX_CONDITION_VARIABLES_MAGIC_0
94);
95RTEMS_STATIC_ASSERT(
96  POSIX_CONDITION_VARIABLES_MAGIC != HEAP_BEGIN_PROTECTOR_1,
97  POSIX_CONDITION_VARIABLES_MAGIC_1
98);
99RTEMS_STATIC_ASSERT(
100  POSIX_CONDITION_VARIABLES_MAGIC != HEAP_END_PROTECTOR_0,
101  POSIX_CONDITION_VARIABLES_MAGIC_2
102);
103RTEMS_STATIC_ASSERT(
104  POSIX_CONDITION_VARIABLES_MAGIC != HEAP_END_PROTECTOR_1,
105  POSIX_CONDITION_VARIABLES_MAGIC_3
106);
107RTEMS_STATIC_ASSERT(
108  POSIX_CONDITION_VARIABLES_MAGIC != HEAP_FREE_PATTERN,
109  POSIX_CONDITION_VARIABLES_MAGIC_4
110);
111RTEMS_STATIC_ASSERT(
112  POSIX_MUTEX_MAGIC != HEAP_BEGIN_PROTECTOR_0,
113  POSIX_MUTEX_MAGIC_0
114);
115RTEMS_STATIC_ASSERT(
116  POSIX_MUTEX_MAGIC != HEAP_BEGIN_PROTECTOR_1,
117  POSIX_MUTEX_MAGIC_1
118);
119RTEMS_STATIC_ASSERT(
120  POSIX_MUTEX_MAGIC != HEAP_END_PROTECTOR_0,
121  POSIX_MUTEX_MAGIC_2
122);
123RTEMS_STATIC_ASSERT(
124  POSIX_MUTEX_MAGIC != HEAP_END_PROTECTOR_1,
125  POSIX_MUTEX_MAGIC_3
126);
127RTEMS_STATIC_ASSERT(
128  POSIX_MUTEX_MAGIC != HEAP_FREE_PATTERN,
129  POSIX_MUTEX_MAGIC_4
130);
131#endif
132
133RTEMS_STATIC_ASSERT(
134  POSIX_SEMAPHORE_MAGIC != POSIX_BARRIER_MAGIC,
135  POSIX_SEMAPHORE_MAGIC_5
136);
137RTEMS_STATIC_ASSERT(
138  POSIX_SEMAPHORE_MAGIC != POSIX_RWLOCK_MAGIC,
139  POSIX_SEMAPHORE_MAGIC_6
140);
141RTEMS_STATIC_ASSERT(
142  POSIX_SEMAPHORE_MAGIC != POSIX_CONDITION_VARIABLES_MAGIC,
143  POSIX_SEMAPHORE_MAGIC_7
144);
145RTEMS_STATIC_ASSERT(
146  POSIX_SEMAPHORE_MAGIC != POSIX_MUTEX_MAGIC,
147  POSIX_SEMAPHORE_MAGIC_8
148);
149RTEMS_STATIC_ASSERT(
150  POSIX_BARRIER_MAGIC != POSIX_RWLOCK_MAGIC,
151  POSIX_BARRIER_MAGIC_5
152);
153RTEMS_STATIC_ASSERT(
154  POSIX_BARRIER_MAGIC != POSIX_CONDITION_VARIABLES_MAGIC,
155  POSIX_BARRIER_MAGIC_6
156);
157RTEMS_STATIC_ASSERT(
158  POSIX_BARRIER_MAGIC != POSIX_MUTEX_MAGIC,
159  POSIX_BARRIER_MAGIC_7
160);
161RTEMS_STATIC_ASSERT(
162  POSIX_RWLOCK_MAGIC != POSIX_CONDITION_VARIABLES_MAGIC,
163  POSIX_RWLOCK_MAGIC_5
164);
165RTEMS_STATIC_ASSERT(
166  POSIX_RWLOCK_MAGIC != POSIX_MUTEX_MAGIC,
167  POSIX_RWLOCK_MAGIC_6
168);
169RTEMS_STATIC_ASSERT(
170  POSIX_CONDITION_VARIABLES_MAGIC != POSIX_MUTEX_MAGIC,
171  POSIX_CONDITION_VARIABLES_MAGIC_5
172);
173
174void _POSIX_Fatal_error( POSIX_Fatal_domain domain, int eno )
175{
176  uint32_t code = ( domain << 8 ) | ( ( uint32_t ) eno & 0xffU );
177
178  _Terminate( INTERNAL_ERROR_POSIX_API, code );
179}
Note: See TracBrowser for help on using the repository browser.