RTEMS
objectsposix.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: BSD-2-Clause */
2 
13 /*
14  * Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de)
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_CONFDEFS_OBJECTSPOSIX_H
39 #define _RTEMS_CONFDEFS_OBJECTSPOSIX_H
40 
41 #ifndef __CONFIGURATION_TEMPLATE_h
42 #error "Do not include this file directly, use <rtems/confdefs.h> instead"
43 #endif
44 
45 #ifdef CONFIGURE_INIT
46 
47 #include <rtems/confdefs/threads.h>
49 #include <rtems/config.h>
50 
51 #include <limits.h>
52 
53 #define _Configure_Memory_for_named_objects( _number, _size ) \
54  ( rtems_resource_maximum_per_allocation( _number ) \
55  * _Configure_From_workspace( _POSIX_PATH_MAX + 1 ) )
56 
57 #ifndef CONFIGURE_MAXIMUM_POSIX_KEYS
58  #define CONFIGURE_MAXIMUM_POSIX_KEYS 0
59 #endif
60 
61 #ifndef CONFIGURE_MAXIMUM_POSIX_KEY_VALUE_PAIRS
62  #define CONFIGURE_MAXIMUM_POSIX_KEY_VALUE_PAIRS \
63  ( CONFIGURE_MAXIMUM_POSIX_KEYS * \
64  ( CONFIGURE_MAXIMUM_POSIX_THREADS + CONFIGURE_MAXIMUM_TASKS ) )
65 #endif
66 
67 #if CONFIGURE_MAXIMUM_POSIX_KEYS > 0 \
68  && CONFIGURE_MAXIMUM_POSIX_KEY_VALUE_PAIRS < CONFIGURE_MAXIMUM_POSIX_KEYS
69  #error "CONFIGURE_MAXIMUM_POSIX_KEY_VALUE_PAIRS must be greater than or equal to CONFIGURE_MAXIMUM_POSIX_KEYS"
70 #endif
71 
72 #if CONFIGURE_MAXIMUM_POSIX_KEYS == 0 \
73  && CONFIGURE_MAXIMUM_POSIX_KEY_VALUE_PAIRS > 0
74  #warning "If CONFIGURE_MAXIMUM_POSIX_KEYS is zero, then CONFIGURE_MAXIMUM_POSIX_KEY_VALUE_PAIRS should be zero as well"
75 #endif
76 
77 #if CONFIGURE_MAXIMUM_POSIX_KEYS > 0 || CONFIGURE_MAXIMUM_POSIX_KEY_VALUE_PAIRS > 0
78  #include <rtems/posix/key.h>
79 #endif
80 
81 #if CONFIGURE_MAXIMUM_POSIX_MESSAGE_QUEUES > 0
82  #include <rtems/posix/mqueue.h>
83 #endif
84 
85 #if CONFIGURE_MAXIMUM_POSIX_QUEUED_SIGNALS > 0
86  #include <rtems/posix/psignal.h>
87 #endif
88 
89 #if CONFIGURE_MAXIMUM_POSIX_SEMAPHORES > 0
90  #include <rtems/posix/semaphore.h>
91 #endif
92 
93 #if CONFIGURE_MAXIMUM_POSIX_SHMS > 0
94  #include <rtems/posix/shm.h>
95 #endif
96 
97 #if CONFIGURE_MAXIMUM_POSIX_TIMERS > 0
98  #include <rtems/posix/timer.h>
99 #endif
100 
101 #ifdef __cplusplus
102 extern "C" {
103 #endif
104 
105 #if CONFIGURE_MAXIMUM_POSIX_KEYS > 0
106  POSIX_KEYS_INFORMATION_DEFINE( CONFIGURE_MAXIMUM_POSIX_KEYS );
107 #endif
108 
109 #if CONFIGURE_MAXIMUM_POSIX_KEY_VALUE_PAIRS > 0
110  POSIX_Keys_Key_value_pair _POSIX_Keys_Key_value_pairs[
113  )
114  ];
115 
116  const uint32_t _POSIX_Keys_Key_value_pair_maximum =
118 #endif
119 
120 #if CONFIGURE_MAXIMUM_POSIX_MESSAGE_QUEUES > 0
121  POSIX_MESSAGE_QUEUE_INFORMATION_DEFINE(
123  );
124 
125  #define _CONFIGURE_MEMORY_FOR_POSIX_MESSAGE_QUEUES \
126  _Configure_Memory_for_named_objects( \
127  CONFIGURE_MAXIMUM_POSIX_MESSAGE_QUEUES, \
128  sizeof( POSIX_Message_queue_Control ) \
129  )
130 #else
131  #define _CONFIGURE_MEMORY_FOR_POSIX_MESSAGE_QUEUES 0
132 #endif
133 
134 #if CONFIGURE_MAXIMUM_POSIX_SEMAPHORES > 0
135  POSIX_SEMAPHORE_INFORMATION_DEFINE( CONFIGURE_MAXIMUM_POSIX_SEMAPHORES );
136 
137  #define _CONFIGURE_MEMORY_FOR_POSIX_SEMAPHORES \
138  _Configure_Memory_for_named_objects( \
139  CONFIGURE_MAXIMUM_POSIX_SEMAPHORES, \
140  sizeof( POSIX_Semaphore_Control ) \
141  )
142 #else
143  #define _CONFIGURE_MEMORY_FOR_POSIX_SEMAPHORES 0
144 #endif
145 
146 #if CONFIGURE_MAXIMUM_POSIX_SHMS > 0
147  POSIX_SHM_INFORMATION_DEFINE( CONFIGURE_MAXIMUM_POSIX_SHMS );
148 
149  #define _CONFIGURE_MEMORY_FOR_POSIX_SHMS \
150  _Configure_Memory_for_named_objects( \
151  CONFIGURE_MAXIMUM_POSIX_SHMS, \
152  sizeof( POSIX_Shm_Control ) \
153  )
154 #else
155  #define _CONFIGURE_MEMORY_FOR_POSIX_SHMS 0
156 #endif
157 
158 #if CONFIGURE_MAXIMUM_POSIX_QUEUED_SIGNALS > 0
159  #ifndef RTEMS_POSIX_API
160  #error "CONFIGURE_MAXIMUM_POSIX_QUEUED_SIGNALS must be zero if POSIX API is disabled"
161  #endif
162 
163  const uint32_t _POSIX_signals_Maximum_queued_signals =
165 
166  POSIX_signals_Siginfo_node _POSIX_signals_Siginfo_nodes[
168  ];
169 
170  #define _CONFIGURE_MEMORY_FOR_POSIX_QUEUED_SIGNALS \
171  _Configure_From_workspace( CONFIGURE_MAXIMUM_POSIX_QUEUED_SIGNALS \
172  * sizeof( POSIX_signals_Siginfo_node ) )
173 #else
174  #define _CONFIGURE_MEMORY_FOR_POSIX_QUEUED_SIGNALS 0
175 #endif
176 
177 #if CONFIGURE_MAXIMUM_POSIX_TIMERS > 0
178  #ifndef RTEMS_POSIX_API
179  #error "CONFIGURE_MAXIMUM_POSIX_TIMERS must be zero if POSIX API is disabled"
180  #endif
181 
182  POSIX_TIMER_INFORMATION_DEFINE( CONFIGURE_MAXIMUM_POSIX_TIMERS );
183 #endif
184 
185 #ifdef __cplusplus
186 }
187 #endif
188 
189 #define _CONFIGURE_MEMORY_FOR_POSIX_OBJECTS \
190  ( _CONFIGURE_MEMORY_FOR_POSIX_MESSAGE_QUEUES \
191  + _CONFIGURE_MEMORY_FOR_POSIX_QUEUED_SIGNALS \
192  + _CONFIGURE_MEMORY_FOR_POSIX_SEMAPHORES \
193  + _CONFIGURE_MEMORY_FOR_POSIX_SHMS )
194 
195 #endif /* CONFIGURE_INIT */
196 
197 #endif /* _RTEMS_CONFDEFS_OBJECTSPOSIX_H */
Configuration Options Workspace Support Macros.
#define CONFIGURE_MAXIMUM_POSIX_MESSAGE_QUEUES
This configuration option is an integer define.
Definition: appl-config.h:3568
#define CONFIGURE_MAXIMUM_POSIX_SHMS
This configuration option is an integer define.
Definition: appl-config.h:3697
Evaluate Thread Configuration Options.
#define CONFIGURE_MAXIMUM_POSIX_KEYS
This configuration option is an integer define.
Definition: appl-config.h:3482
#define CONFIGURE_MAXIMUM_POSIX_QUEUED_SIGNALS
This configuration option is an integer define.
Definition: appl-config.h:3609
#define rtems_resource_maximum_per_allocation(_resource)
Returns the maximum number per allocation of a resource number.
Definition: config.h:375
#define CONFIGURE_MAXIMUM_POSIX_SEMAPHORES
This configuration option is an integer define.
Definition: appl-config.h:3656
#define CONFIGURE_MAXIMUM_POSIX_TIMERS
This configuration option is an integer define.
Definition: appl-config.h:3792
#define CONFIGURE_MAXIMUM_POSIX_KEY_VALUE_PAIRS
This configuration option is an integer define.
Definition: appl-config.h:3526