source: rtems/cpukit/include/rtems/score/basedefs.h @ a84bf96

Last change on this file since a84bf96 was a84bf96, checked in by Sebastian Huber <sebastian.huber@…>, on 04/30/21 at 13:07:14

basedefs: Add RTEMS_NOINIT

Update #3866.

  • Property mode set to 100644
File size: 26.9 KB
Line 
1/* SPDX-License-Identifier: BSD-2-Clause */
2
3/**
4 * @file
5 *
6 * @brief This header file provides basic definitions used by the API and the
7 *   implementation.
8 */
9
10/*
11 * Copyright (C) 2014 Paval Pisa
12 * Copyright (C) 2011, 2013 On-Line Applications Research Corporation (OAR)
13 * Copyright (C) 2009, 2021 embedded brains GmbH (http://www.embedded-brains.de)
14 *
15 * Redistribution and use in source and binary forms, with or without
16 * modification, are permitted provided that the following conditions
17 * are met:
18 * 1. Redistributions of source code must retain the above copyright
19 *    notice, this list of conditions and the following disclaimer.
20 * 2. Redistributions in binary form must reproduce the above copyright
21 *    notice, this list of conditions and the following disclaimer in the
22 *    documentation and/or other materials provided with the distribution.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
28 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
32 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34 * POSSIBILITY OF SUCH DAMAGE.
35 */
36
37/*
38 * This file is part of the RTEMS quality process and was automatically
39 * generated.  If you find something that needs to be fixed or
40 * worded better please post a report or patch to an RTEMS mailing list
41 * or raise a bug report:
42 *
43 * https://www.rtems.org/bugs.html
44 *
45 * For information on updating and regenerating please refer to the How-To
46 * section in the Software Requirements Engineering chapter of the
47 * RTEMS Software Engineering manual.  The manual is provided as a part of
48 * a release.  For development sources please refer to the online
49 * documentation at:
50 *
51 * https://docs.rtems.org
52 */
53
54/* Generated from spec:/rtems/basedefs/if/header */
55
56#ifndef _RTEMS_SCORE_BASEDEFS_H
57#define _RTEMS_SCORE_BASEDEFS_H
58
59#include <rtems/score/cpuopts.h>
60
61#if !defined(ASM)
62  #include <stdbool.h>
63  #include <stddef.h>
64  #include <stdint.h>
65#endif
66
67#ifdef __cplusplus
68extern "C" {
69#endif
70
71/* Generated from spec:/if/api */
72
73/**
74 * @defgroup RTEMSAPI API
75 *
76 * @brief API
77 *
78 * This group contains the RTEMS Application Programming Interface (API).
79 */
80
81/* Generated from spec:/rtems/basedefs/if/group */
82
83/**
84 * @defgroup RTEMSAPIBaseDefs Base Definitions
85 *
86 * @ingroup RTEMSAPI
87 *
88 * @brief This group contains basic macros and defines to give access to
89 *   compiler-specific features.
90 */
91
92/* Generated from spec:/rtems/basedefs/if/alias */
93
94/**
95 * @ingroup RTEMSAPIBaseDefs
96 *
97 * @brief Instructs the compiler to generate an alias to the target function.
98 *
99 * @param _target is the target function name.
100 */
101#if defined(__GNUC__)
102  #define RTEMS_ALIAS( _target ) __attribute__(( __alias__( #_target ) ))
103#else
104  #define RTEMS_ALIAS( _target )
105#endif
106
107/* Generated from spec:/rtems/basedefs/if/align-down */
108
109/**
110 * @ingroup RTEMSAPIBaseDefs
111 *
112 * @brief Aligns down the value to the alignment.
113 *
114 * @param _value is the value to align down.
115 *
116 * @param _alignment is the desired alignment in bytes.  The alignment shall be
117 *   a power of two, otherwise the returned value is undefined.  The alignment
118 *   parameter is evaluated twice.
119 *
120 * @return Returns the value aligned down to the alignment.
121 */
122#define RTEMS_ALIGN_DOWN( _value, _alignment ) \
123  ( ( _value ) & ~( ( _alignment ) - 1 ) )
124
125/* Generated from spec:/rtems/basedefs/if/align-up */
126
127/**
128 * @ingroup RTEMSAPIBaseDefs
129 *
130 * @brief Aligns up the value to the alignment.
131 *
132 * @param _value is the value to align up.
133 *
134 * @param _alignment is the desired alignment in bytes.  The alignment shall be
135 *   a power of two, otherwise the returned value is undefined.  The alignment
136 *   parameter is evaluated twice.
137 *
138 * @return Returns the value aligned up to the alignment.
139 */
140#define RTEMS_ALIGN_UP( _value, _alignment ) \
141  ( ( ( _value ) + ( _alignment ) - 1 ) & ~( ( _alignment ) - 1 ) )
142
143/* Generated from spec:/rtems/basedefs/if/aligned */
144
145/**
146 * @ingroup RTEMSAPIBaseDefs
147 *
148 * @brief Instructs the compiler in a declaration or definition to enforce the
149 *   alignment.
150 *
151 * @param _alignment is the desired alignment in bytes.
152 */
153#if defined(__GNUC__)
154  #define RTEMS_ALIGNED( _alignment ) __attribute__(( __aligned__( _alignment ) ))
155#else
156  #define RTEMS_ALIGNED( _alignment )
157#endif
158
159/* Generated from spec:/rtems/basedefs/if/alignof */
160
161/**
162 * @ingroup RTEMSAPIBaseDefs
163 *
164 * @brief Gets the alignment requirement of the type.
165 *
166 * @param _type_name is the type name to get the alignment requirement for.
167 *
168 * @return Returns the alignment requirement of the type.
169 */
170#if __cplusplus >= 201103L
171  #define RTEMS_ALIGNOF( _type_name ) alignof( _type_name )
172#elif __STDC_VERSION__ >= 201112L
173  #define RTEMS_ALIGNOF( _type_name ) _Alignof( _type_name )
174#else
175  #define RTEMS_ALIGNOF( _type_name ) sizeof( _type_name )
176#endif
177
178/* Generated from spec:/rtems/basedefs/if/alloc-align */
179
180/**
181 * @ingroup RTEMSAPIBaseDefs
182 *
183 * @brief Tells the compiler in a declaration that the memory allocation
184 *   alignment parameter of this function is similar to aligned_alloc().
185 *
186 * @param _index is the allocation alignment parameter index (starting with
187 *   one).
188 */
189#if defined(__GNUC__)
190  #define RTEMS_ALLOC_ALIGN( _index ) __attribute__(( __alloc_align__( _index ) ))
191#else
192  #define RTEMS_ALLOC_ALIGN( _index )
193#endif
194
195/* Generated from spec:/rtems/basedefs/if/alloc-size */
196
197/**
198 * @ingroup RTEMSAPIBaseDefs
199 *
200 * @brief Tells the compiler in a declaration that the memory allocation size
201 *   parameter of this function is similar to malloc().
202 *
203 * @param _index is the allocation size parameter index (starting with one).
204 */
205#if defined(__GNUC__)
206  #define RTEMS_ALLOC_SIZE( _index ) __attribute__(( __alloc_size__( _index ) ))
207#else
208  #define RTEMS_ALLOC_SIZE( _index )
209#endif
210
211/* Generated from spec:/rtems/basedefs/if/alloc-size-2 */
212
213/**
214 * @ingroup RTEMSAPIBaseDefs
215 *
216 * @brief Tells the compiler in a declaration that the memory allocation item
217 *   count and item size parameter of this function is similar to calloc().
218 *
219 * @param _count_index is the allocation item count parameter index (starting
220 *   with one).
221 *
222 * @param _size_index is the allocation item size parameter index (starting
223 *   with one).
224 */
225#if defined(__GNUC__)
226  #define RTEMS_ALLOC_SIZE_2( _count_index, _size_index ) \
227    __attribute__(( __alloc_size__( _count_index, _size_index ) ))
228#else
229  #define RTEMS_ALLOC_SIZE_2( _count_index, _size_index )
230#endif
231
232/* Generated from spec:/rtems/basedefs/if/array-size */
233
234/**
235 * @ingroup RTEMSAPIBaseDefs
236 *
237 * @brief Gets the element count of the array.
238 *
239 * @param _array is the name of the array.  This parameter is evaluated twice.
240 *
241 * @return Returns the element count of the array.
242 */
243#define RTEMS_ARRAY_SIZE( _array ) \
244  ( sizeof( _array ) / sizeof( ( _array )[ 0 ] ) )
245
246/* Generated from spec:/rtems/basedefs/if/compiler-memory-barrier */
247
248/**
249 * @ingroup RTEMSAPIBaseDefs
250 *
251 * @brief This macro forbids the compiler to reorder read and write commands
252 *   around it.
253 */
254#if defined(__GNUC__)
255  #define RTEMS_COMPILER_MEMORY_BARRIER() __asm__ volatile( "" ::: "memory" )
256#else
257  #define RTEMS_COMPILER_MEMORY_BARRIER() do { } while ( 0 )
258#endif
259
260/* Generated from spec:/rtems/basedefs/if/concat */
261
262/**
263 * @ingroup RTEMSAPIBaseDefs
264 *
265 * @brief Concatenates _x and _y without expanding.
266 *
267 * @param _x is the left hand side token of the concatenation.
268 *
269 * @param _y is the right hand side token of the concatenation.
270 *
271 * @return Returns the concatenation of the tokens _x and _y.
272 */
273#define RTEMS_CONCAT( _x, _y ) _x##_y
274
275/* Generated from spec:/rtems/basedefs/if/const */
276
277/**
278 * @ingroup RTEMSAPIBaseDefs
279 *
280 * @brief Tells the compiler in a function declaration that this function has
281 *   no effect except the return value and that the return value depends only
282 *   on the value of parameters.
283 */
284#if defined(__GNUC__)
285  #define RTEMS_CONST __attribute__(( __const__ ))
286#else
287  #define RTEMS_CONST
288#endif
289
290/* Generated from spec:/rtems/basedefs/if/container-of */
291
292/**
293 * @ingroup RTEMSAPIBaseDefs
294 *
295 * @brief Gets the container of a member.
296 *
297 * @param _m is the pointer to a member of the container.
298 *
299 * @param _type is the type of the container.
300 *
301 * @param _member_name is the designator name of the container member.
302 *
303 * @return Returns the pointer to the container of a member pointer.
304 */
305#define RTEMS_CONTAINER_OF( _m, _type, _member_name ) \
306  ( (_type *) ( (uintptr_t) ( _m ) - offsetof( _type, _member_name ) ) )
307
308/* Generated from spec:/rtems/basedefs/if/declare-global-symbol */
309
310/**
311 * @ingroup RTEMSAPIBaseDefs
312 *
313 * @brief Declares a global symbol with the name.
314 *
315 * @param _name is the name of the global symbol.  It shall be a valid
316 *   designator.
317 *
318 * This macro must be placed at file scope.
319 */
320#define RTEMS_DECLARE_GLOBAL_SYMBOL( _name ) extern char _name[]
321
322/* Generated from spec:/rtems/basedefs/if/deprecated */
323
324/**
325 * @ingroup RTEMSAPIBaseDefs
326 *
327 * @brief Instructs the compiler in a declaration to issue a warning whenever a
328 *   variable, function, or type using this declaration will be used.
329 */
330#if defined(__GNUC__)
331  #define RTEMS_DEPRECATED __attribute__(( __deprecated__ ))
332#else
333  #define RTEMS_DEPRECATED
334#endif
335
336/* Generated from spec:/rtems/basedefs/if/compiler-deprecated-attribute */
337
338/**
339 * @ingroup RTEMSAPIBaseDefs
340 *
341 * @brief Provided for backward compatibility.
342 */
343#define RTEMS_COMPILER_DEPRECATED_ATTRIBUTE RTEMS_DEPRECATED
344
345/* Generated from spec:/rtems/basedefs/if/expand */
346
347/**
348 * @ingroup RTEMSAPIBaseDefs
349 *
350 * @brief Helper macro to perform a macro expansion on the token.
351 *
352 * @param _token is the token to expand.
353 */
354#define RTEMS_EXPAND( _token ) _token
355
356/* Generated from spec:/rtems/basedefs/if/section */
357
358/**
359 * @ingroup RTEMSAPIBaseDefs
360 *
361 * @brief Instructs the compiler to place the variable or function in the
362 *   section.
363 *
364 * @param _section is the section name as a string.
365 */
366#if defined(__GNUC__)
367  #define RTEMS_SECTION( _section ) __attribute__(( __section__( _section ) ))
368#else
369  #define RTEMS_SECTION( _section )
370#endif
371
372/* Generated from spec:/rtems/basedefs/if/string */
373
374/**
375 * @ingroup RTEMSAPIBaseDefs
376 *
377 * @brief Stringifies the arguments without expanding them.
378 *
379 * @param ... are the arguments to stringify.
380 *
381 * @return Returns the stringification of the arguments.  In case of several
382 *   arguments a single string is returned not several.
383 */
384#define RTEMS_STRING( ... ) #__VA_ARGS__
385
386/* Generated from spec:/rtems/basedefs/if/typeof-refx */
387
388/**
389 * @ingroup RTEMSAPIBaseDefs
390 *
391 * @brief Gets the pointer reference type.
392 *
393 * @param _level is the pointer indirection level expressed in *.
394 *
395 * @param _target is the reference target type.
396 *
397 * The reference type idea is based on libHX by Jan Engelhardt.
398 *
399 * @return Returns the type of a pointer reference of the specified level to
400 *   the specified type.
401 */
402#if defined(__GNUC__)
403  #define RTEMS_TYPEOF_REFX( _level, _target ) \
404    __typeof__( _level( union { int _z; __typeof__( _target ) _x; } ){ 0 }._x )
405#else
406  #define RTEMS_TYPEOF_REFX( _level, _target )
407#endif
408
409/* Generated from spec:/rtems/basedefs/if/xconcat */
410
411/**
412 * @ingroup RTEMSAPIBaseDefs
413 *
414 * @brief Concatenates expansion of _x and expansion of _y.
415 *
416 * @param _x is expanded first and then used as the left hand side token of the
417 *   concatenation.
418 *
419 * @param _y is expanded first and then used as the right hand side token of
420 *   the concatenation.
421 *
422 * @return Returns the concatenation of the expansions of tokens _x and _y.
423 */
424#define RTEMS_XCONCAT( _x, _y ) RTEMS_CONCAT( _x, _y )
425
426/* Generated from spec:/score/if/assert-unreachable */
427
428/**
429 * @brief Asserts that this program point is unreachable.
430 */
431#if defined(RTEMS_DEBUG)
432  #define _Assert_Unreachable() _Assert( 0 )
433#else
434  #define _Assert_Unreachable() do { } while ( 0 )
435#endif
436
437#if !defined(ASM)
438  /* Generated from spec:/score/if/dequalify-types-not-compatible */
439
440  /**
441   * @brief A not implemented function to trigger compile time errors with an
442   *   error message.
443   */
444  #if defined(__GNUC__)
445    __attribute__((__error__("RTEMS_DEQUALIFY() types differ not only by volatile and const"))) void *
446    RTEMS_DEQUALIFY_types_not_compatible( void );
447  #else
448    void *RTEMS_DEQUALIFY_types_not_compatible( void );
449  #endif
450#endif
451
452/* Generated from spec:/rtems/basedefs/if/dequalify-depthx */
453
454/**
455 * @ingroup RTEMSAPIBaseDefs
456 *
457 * @brief Performs a type cast which removes qualifiers without warnings to the
458 *   type for the variable.
459 *
460 * @param _ptr_level is the pointer indirection level expressed in *.
461 *
462 * @param _type is the target type of the cast.
463 *
464 * @param _var is the variable.
465 */
466#if defined(__cplusplus)
467  #define RTEMS_DEQUALIFY_DEPTHX( _ptr_level, _type, _var ) \
468    ( const_cast<_type>( _var ) )
469#elif defined(__GNUC__)
470  #define RTEMS_DEQUALIFY_DEPTHX( _ptr_level, _type, _var ) \
471    __builtin_choose_expr( __builtin_types_compatible_p( \
472        RTEMS_TYPEOF_REFX( _ptr_level, _var ), \
473        RTEMS_TYPEOF_REFX( _ptr_level, _type ) \
474      ) || __builtin_types_compatible_p( _type, void * ), \
475    (_type) ( _var ), \
476    RTEMS_DEQUALIFY_types_not_compatible() )
477#else
478  #define RTEMS_DEQUALIFY_DEPTHX( _ptr_level, _type, _var ) \
479    ( (_type) (uintptr_t) (const volatile void *)( _var ) )
480#endif
481
482/* Generated from spec:/rtems/basedefs/if/deconst */
483
484/**
485 * @ingroup RTEMSAPIBaseDefs
486 *
487 * @brief Performs a type cast which removes const qualifiers without warnings
488 *   to the type for the pointer variable.
489 *
490 * @param _type is the target type of the cast.
491 *
492 * @param _var is the pointer variable.
493 */
494#define RTEMS_DECONST( _type, _var ) RTEMS_DEQUALIFY_DEPTHX( *, _type, _var )
495
496/* Generated from spec:/rtems/basedefs/if/dequalify */
497
498/**
499 * @ingroup RTEMSAPIBaseDefs
500 *
501 * @brief Performs a type cast which removes all qualifiers without warnings to
502 *   the type for the pointer variable.
503 *
504 * @param _type is the target type of the cast.
505 *
506 * @param _var is the pointer variable.
507 */
508#define RTEMS_DEQUALIFY( _type, _var ) RTEMS_DEQUALIFY_DEPTHX( *, _type, _var )
509
510/* Generated from spec:/rtems/basedefs/if/devolatile */
511
512/**
513 * @ingroup RTEMSAPIBaseDefs
514 *
515 * @brief Performs a type cast which removes volatile qualifiers without
516 *   warnings to the type for the pointer variable.
517 *
518 * @param _type is the target type of the cast.
519 *
520 * @param _var is the pointer variable.
521 */
522#define RTEMS_DEVOLATILE( _type, _var ) RTEMS_DEQUALIFY_DEPTHX( *, _type, _var )
523
524#if !defined(FALSE)
525  /* Generated from spec:/rtems/basedefs/if/false */
526
527  /**
528   * @ingroup RTEMSAPIBaseDefs
529   *
530   * @brief If FALSE is undefined, then FALSE is defined to 0.
531   */
532  #define FALSE 0
533#endif
534
535/* Generated from spec:/rtems/basedefs/if/have-member-same-type */
536
537/**
538 * @ingroup RTEMSAPIBaseDefs
539 *
540 * @brief Checks if members of two types have compatible types.
541 *
542 * @param _t_lhs is the left hand side type.
543 *
544 * @param _m_lhs is the left hand side member.
545 *
546 * @param _t_rhs is the right hand side type.
547 *
548 * @param _m_rhs is the right hand side member.
549 *
550 * @return Returns to true, if the members of two types have compatible types,
551 *   otherwise false.
552 */
553#if defined(__GNUC__)
554  #define RTEMS_HAVE_MEMBER_SAME_TYPE( _t_lhs, _m_lhs, _t_rhs, _m_rhs ) \
555    __builtin_types_compatible_p( \
556      __typeof__( ( (_t_lhs *) 0 )->_m_lhs ), \
557      __typeof__( ( (_t_rhs *) 0 )->_m_rhs ) \
558    )
559#else
560  #define RTEMS_HAVE_MEMBER_SAME_TYPE( _t_lhs, _m_lhs, _t_rhs, _m_rhs ) true
561#endif
562
563/* Generated from spec:/rtems/basedefs/if/inline-routine */
564
565/**
566 * @ingroup RTEMSAPIBaseDefs
567 *
568 * @brief Gives a hint to the compiler in a function declaration to inline this
569 *   function.
570 */
571#if defined(__GNUC__)
572  #define RTEMS_INLINE_ROUTINE static __inline__
573#else
574  #define RTEMS_INLINE_ROUTINE static inline
575#endif
576
577/* Generated from spec:/rtems/basedefs/if/malloclike */
578
579/**
580 * @ingroup RTEMSAPIBaseDefs
581 *
582 * @brief Tells the compiler in a declaration that this function is a memory
583 *   allocation function similar to malloc().
584 */
585#if defined(__GNUC__)
586  #define RTEMS_MALLOCLIKE __attribute__(( __malloc__ ))
587#else
588  #define RTEMS_MALLOCLIKE
589#endif
590
591/* Generated from spec:/rtems/basedefs/if/no-inline */
592
593/**
594 * @ingroup RTEMSAPIBaseDefs
595 *
596 * @brief Instructs the compiler in a function declaration to not inline this
597 *   function.
598 */
599#if defined(__GNUC__)
600  #define RTEMS_NO_INLINE __attribute__(( __noinline__ ))
601#else
602  #define RTEMS_NO_INLINE
603#endif
604
605/* Generated from spec:/rtems/basedefs/if/no-return */
606
607/**
608 * @ingroup RTEMSAPIBaseDefs
609 *
610 * @brief Tells the compiler in a function declaration that this function does
611 *   not return.
612 */
613#if __cplusplus >= 201103L
614  #define RTEMS_NO_RETURN [[noreturn]]
615#elif __STDC_VERSION__ >= 201112L
616  #define RTEMS_NO_RETURN _Noreturn
617#elif defined(__GNUC__)
618  #define RTEMS_NO_RETURN __attribute__(( __noreturn__ ))
619#else
620  #define RTEMS_NO_RETURN
621#endif
622
623/* Generated from spec:/rtems/basedefs/if/compiler-no-return-attribute */
624
625/**
626 * @ingroup RTEMSAPIBaseDefs
627 *
628 * @brief Provided for backward compatibility.
629 */
630#define RTEMS_COMPILER_NO_RETURN_ATTRIBUTE RTEMS_NO_RETURN
631
632/* Generated from spec:/rtems/basedefs/if/noinit */
633
634/**
635 * @ingroup RTEMSAPIBaseDefs
636 *
637 * @brief Instructs the compiler to place the variable in a section which is
638 *   not initialized.
639 */
640#define RTEMS_NOINIT RTEMS_SECTION( ".noinit" )
641
642/* Generated from spec:/rtems/basedefs/if/obfuscate-variable */
643
644/**
645 * @ingroup RTEMSAPIBaseDefs
646 *
647 * @brief Obfuscates the variable so that the compiler cannot perform
648 *   optimizations based on the variable value.
649 *
650 * @param _var is the variable to obfuscate.
651 *
652 * The variable must be simple enough to fit into a register.
653 */
654#if defined(__GNUC__)
655  #define RTEMS_OBFUSCATE_VARIABLE( _var ) __asm__( "" : "+r" ( _var ) )
656#else
657  #define RTEMS_OBFUSCATE_VARIABLE( _var ) (void) ( _var )
658#endif
659
660/* Generated from spec:/rtems/basedefs/if/packed */
661
662/**
663 * @ingroup RTEMSAPIBaseDefs
664 *
665 * @brief Instructs the compiler in a type definition to place members of a
666 *   structure or union so that the memory required is minimized.
667 */
668#if defined(__GNUC__)
669  #define RTEMS_PACKED __attribute__(( __packed__ ))
670#else
671  #define RTEMS_PACKED
672#endif
673
674/* Generated from spec:/rtems/basedefs/if/compiler-packed-attribute */
675
676/**
677 * @ingroup RTEMSAPIBaseDefs
678 *
679 * @brief Provided for backward compatibility.
680 */
681#define RTEMS_COMPILER_PACKED_ATTRIBUTE RTEMS_PACKED
682
683/* Generated from spec:/rtems/basedefs/if/predict-false */
684
685/**
686 * @ingroup RTEMSAPIBaseDefs
687 *
688 * @brief Evaluates the integral expression and tells the compiler that the
689 *   predicted value is false (0).
690 *
691 * @param _exp is the integral expression.
692 *
693 * @return Returns the value of the integral expression and tells the compiler
694 *   that the predicted value is false (0).
695 */
696#if defined(__GNUC__)
697  #define RTEMS_PREDICT_FALSE( _exp ) __builtin_expect( ( _exp ), 0 )
698#else
699  #define RTEMS_PREDICT_FALSE( _exp ) ( _exp )
700#endif
701
702/* Generated from spec:/rtems/basedefs/if/predict-true */
703
704/**
705 * @ingroup RTEMSAPIBaseDefs
706 *
707 * @brief Evaluates the integral expression and tells the compiler that the
708 *   predicted value is true (1).
709 *
710 * @param _exp is the integral expression.
711 *
712 * @return Returns the value of the integral expression and tells the compiler
713 *   that the predicted value is true (1).
714 */
715#if defined(__GNUC__)
716  #define RTEMS_PREDICT_TRUE( _exp ) __builtin_expect( ( _exp ), 1 )
717#else
718  #define RTEMS_PREDICT_TRUE( _exp ) ( _exp )
719#endif
720
721/* Generated from spec:/rtems/basedefs/if/printflike */
722
723/**
724 * @ingroup RTEMSAPIBaseDefs
725 *
726 * @brief Tells the compiler in a declaration that this function expects
727 *   printf()-like arguments.
728 *
729 * @param _format_pos is the position of the format parameter index (starting
730 *   with one).
731 *
732 * @param _ap_pos is the position of the argument pointer parameter index
733 *   (starting with one).
734 */
735#if defined(__GNUC__)
736  #define RTEMS_PRINTFLIKE( _format_pos, _ap_pos ) \
737    __attribute__(( __format__( __printf__, _format_pos, _ap_pos ) ))
738#else
739  #define RTEMS_PRINTFLIKE( _format_pos, _ap_pos )
740#endif
741
742/* Generated from spec:/rtems/basedefs/if/pure */
743
744/**
745 * @ingroup RTEMSAPIBaseDefs
746 *
747 * @brief Tells the compiler in a function declaration that this function has
748 *   no effect except the return value and that the return value depends only
749 *   on the value of parameters and/or global variables.
750 */
751#if defined(__GNUC__)
752  #define RTEMS_PURE __attribute__(( __pure__ ))
753#else
754  #define RTEMS_PURE
755#endif
756
757/* Generated from spec:/rtems/basedefs/if/compiler-pure-attribute */
758
759/**
760 * @ingroup RTEMSAPIBaseDefs
761 *
762 * @brief Provided for backward compatibility.
763 */
764#define RTEMS_COMPILER_PURE_ATTRIBUTE RTEMS_PURE
765
766/* Generated from spec:/rtems/basedefs/if/return-address */
767
768/**
769 * @ingroup RTEMSAPIBaseDefs
770 *
771 * @brief Gets the return address of the current function.
772 *
773 * @return Returns the return address of the current function.
774 */
775#if defined(__GNUC__)
776  #define RTEMS_RETURN_ADDRESS() __builtin_return_address( 0 )
777#else
778  #define RTEMS_RETURN_ADDRESS() NULL
779#endif
780
781/* Generated from spec:/rtems/basedefs/if/static-analysis */
782
783/**
784 * @ingroup RTEMSAPIBaseDefs
785 *
786 * @brief It is defined if a static analysis run is performed.
787 */
788#if defined(__COVERITY__)
789  #define RTEMS_STATIC_ANALYSIS
790#endif
791
792/* Generated from spec:/rtems/basedefs/if/static-assert */
793
794/**
795 * @ingroup RTEMSAPIBaseDefs
796 *
797 * @brief Asserts at compile time that the condition is satisfied.
798 *
799 * @param _cond is the condition this static assertion shall satisfy.
800 *
801 * @param _msg is the error message in case the static assertion fails.
802 */
803#if __cplusplus >= 201103L
804  #define RTEMS_STATIC_ASSERT( _cond, _msg ) static_assert( _cond, # _msg )
805#elif __STDC_VERSION__ >= 201112L
806  #define RTEMS_STATIC_ASSERT( _cond, _msg ) _Static_assert( _cond, # _msg )
807#else
808  #define RTEMS_STATIC_ASSERT( _cond, _msg ) \
809    struct rtems_static_assert_ ## _msg \
810      { int rtems_static_assert_ ## _msg : ( _cond ) ? 1 : -1; }
811#endif
812
813/* Generated from spec:/rtems/basedefs/if/symbol-name */
814
815/**
816 * @ingroup RTEMSAPIBaseDefs
817 *
818 * @brief Maps the name to the associated symbol name.
819 *
820 * @param _name is the user defined name of the symbol.  The name shall be a
821 *   valid designator.  On the name a macro expansion is performed.
822 *
823 * @return Returns the symbol name associated with the name.
824 */
825#if defined(__USER_LABEL_PREFIX__)
826  #define RTEMS_SYMBOL_NAME( _name ) RTEMS_XCONCAT( __USER_LABEL_PREFIX__, _name )
827#else
828  #define RTEMS_SYMBOL_NAME( _name ) RTEMS_EXPAND( _name )
829#endif
830
831#if !defined(TRUE)
832  /* Generated from spec:/rtems/basedefs/if/true */
833
834  /**
835   * @ingroup RTEMSAPIBaseDefs
836   *
837   * @brief If TRUE is undefined, then TRUE is defined to 1.
838   */
839  #define TRUE 1
840#endif
841
842/* Generated from spec:/rtems/basedefs/if/unreachable */
843
844/**
845 * @brief Tells the compiler that this program point is unreachable.
846 */
847#if defined(__GNUC__)
848  #define RTEMS_UNREACHABLE() \
849    do { \
850      __builtin_unreachable(); \
851      _Assert_Unreachable(); \
852    } while ( 0 )
853#else
854  #define RTEMS_UNREACHABLE() _Assert_Unreachable()
855#endif
856
857/* Generated from spec:/rtems/basedefs/if/unused */
858
859/**
860 * @ingroup RTEMSAPIBaseDefs
861 *
862 * @brief Tells the compiler that the variable or function is deliberately
863 *   unused.
864 */
865#if defined(__GNUC__)
866  #define RTEMS_UNUSED __attribute__(( __unused__ ))
867#else
868  #define RTEMS_UNUSED
869#endif
870
871/* Generated from spec:/rtems/basedefs/if/compiler-unused-attribute */
872
873/**
874 * @ingroup RTEMSAPIBaseDefs
875 *
876 * @brief Provided for backward compatibility.
877 */
878#define RTEMS_COMPILER_UNUSED_ATTRIBUTE RTEMS_UNUSED
879
880/* Generated from spec:/rtems/basedefs/if/used */
881
882/**
883 * @ingroup RTEMSAPIBaseDefs
884 *
885 * @brief Tells the compiler that the variable or function is used.
886 */
887#if defined(__GNUC__)
888  #define RTEMS_USED __attribute__(( __used__ ))
889#else
890  #define RTEMS_USED
891#endif
892
893/* Generated from spec:/rtems/basedefs/if/warn-unused-result */
894
895/**
896 * @ingroup RTEMSAPIBaseDefs
897 *
898 * @brief Tells the compiler in a declaration that the result of this function
899 *   should be used.
900 */
901#if defined(__GNUC__)
902  #define RTEMS_WARN_UNUSED_RESULT __attribute__(( __warn_unused_result__ ))
903#else
904  #define RTEMS_WARN_UNUSED_RESULT
905#endif
906
907/* Generated from spec:/rtems/basedefs/if/weak */
908
909/**
910 * @ingroup RTEMSAPIBaseDefs
911 *
912 * @brief Tells the compiler in a function definition that this function should
913 *   be weak.
914 *
915 * Use this attribute for function definitions.  Do not use it for function
916 * declarations.
917 */
918#if defined(__GNUC__)
919  #define RTEMS_WEAK __attribute__(( __weak__ ))
920#else
921  #define RTEMS_WEAK
922#endif
923
924/* Generated from spec:/rtems/basedefs/if/weak-alias */
925
926/**
927 * @ingroup RTEMSAPIBaseDefs
928 *
929 * @brief Instructs the compiler to generate a weak alias to the target
930 *   function.
931 *
932 * @param _target is the target function name.
933 */
934#if defined(__GNUC__)
935  #define RTEMS_WEAK_ALIAS( _target ) \
936    __attribute__(( __weak__, __alias__( #_target ) ))
937#else
938  #define RTEMS_WEAK_ALIAS( _target )
939#endif
940
941/* Generated from spec:/rtems/basedefs/if/xstring */
942
943/**
944 * @ingroup RTEMSAPIBaseDefs
945 *
946 * @brief Stringifies the expansion of the arguments.
947 *
948 * @param ... are the arguments to expand and stringify.
949 *
950 * @return Returns the stringification of the expansion of the arguments.  In
951 *   case of several arguments a single string is returned not several.
952 */
953#define RTEMS_XSTRING( ... ) RTEMS_STRING( __VA_ARGS__ )
954
955/* Generated from spec:/rtems/basedefs/if/define-global-symbol */
956
957/**
958 * @ingroup RTEMSAPIBaseDefs
959 *
960 * @brief Defines a global symbol with the name and value.
961 *
962 * @param _name is the user defined name of the symbol.  The name shall be a
963 *   valid designator.  On the name a macro expansion is performed and
964 *   afterwards it is stringified.
965 *
966 * @param _value is the value of the symbol.  On the value a macro expansion is
967 *   performed and afterwards it is stringified.  It shall expand to an integer
968 *   expression understood by the assembler.
969 *
970 * This macro shall be placed at file scope.
971 */
972#if defined(__USER_LABEL_PREFIX__)
973  #define RTEMS_DEFINE_GLOBAL_SYMBOL( _name, _value ) \
974    __asm__( \
975      "\t.globl " RTEMS_XSTRING( RTEMS_SYMBOL_NAME( _name ) ) \
976      "\n\t.set " RTEMS_XSTRING( RTEMS_SYMBOL_NAME( _name ) ) \
977      ", " RTEMS_STRING( _value ) "\n" \
978    )
979#else
980  #define RTEMS_DEFINE_GLOBAL_SYMBOL( _name, _value )
981#endif
982
983/* Generated from spec:/rtems/basedefs/if/zero-length-array */
984
985/**
986 * @ingroup RTEMSAPIBaseDefs
987 *
988 * @brief This constant represents the element count of a zero-length array.
989 *
990 * Zero-length arrays are valid in C99 as flexible array members.  C++11 does
991 * not allow flexible array members.  Use the GNU extension which is also
992 * supported by other compilers.
993 */
994#if __STDC_VERSION__ >= 199409L
995  #define RTEMS_ZERO_LENGTH_ARRAY
996#else
997  #define RTEMS_ZERO_LENGTH_ARRAY 0
998#endif
999
1000#ifdef __cplusplus
1001}
1002#endif
1003
1004#endif /* _RTEMS_SCORE_BASEDEFS_H */
Note: See TracBrowser for help on using the repository browser.