RTEMS 7.0-rc1
Loading...
Searching...
No Matches
basedefs.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: BSD-2-Clause */
2
12/*
13 * Copyright (C) 2014 Pavel Pisa
14 * Copyright (C) 2011, 2025 On-Line Applications Research Corporation (OAR)
15 * Copyright (C) 2009, 2023 embedded brains GmbH & Co. KG
16 *
17 * Redistribution and use in source and binary forms, with or without
18 * modification, are permitted provided that the following conditions
19 * are met:
20 * 1. Redistributions of source code must retain the above copyright
21 * notice, this list of conditions and the following disclaimer.
22 * 2. Redistributions in binary form must reproduce the above copyright
23 * notice, this list of conditions and the following disclaimer in the
24 * documentation and/or other materials provided with the distribution.
25 *
26 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
27 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
30 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 * POSSIBILITY OF SUCH DAMAGE.
37 */
38
39/*
40 * This file is part of the RTEMS quality process and was automatically
41 * generated. If you find something that needs to be fixed or
42 * worded better please post a report or patch to an RTEMS mailing list
43 * or raise a bug report:
44 *
45 * https://www.rtems.org/bugs.html
46 *
47 * For information on updating and regenerating please refer to the How-To
48 * section in the Software Requirements Engineering chapter of the
49 * RTEMS Software Engineering manual. The manual is provided as a part of
50 * a release. For development sources please refer to the online
51 * documentation at:
52 *
53 * https://docs.rtems.org
54 */
55
56/* Generated from spec:/rtems/basedefs/if/header */
57
58#ifndef _RTEMS_SCORE_BASEDEFS_H
59#define _RTEMS_SCORE_BASEDEFS_H
60
61#include <rtems/score/cpuopts.h>
62
63#if !defined(ASM)
64 #include <stdbool.h>
65 #include <stddef.h>
66 #include <stdint.h>
67#endif
68
69#ifdef __cplusplus
70extern "C" {
71#endif
72
73/* Generated from spec:/if/group */
74
82/* Generated from spec:/rtems/basedefs/if/group */
83
93/* Generated from spec:/rtems/basedefs/if/alias */
94
102#if defined(__GNUC__)
103 #define RTEMS_ALIAS( _target ) __attribute__(( __alias__( #_target ) ))
104#else
105 #define RTEMS_ALIAS( _target )
106#endif
107
108/* Generated from spec:/rtems/basedefs/if/align-down */
109
123#define RTEMS_ALIGN_DOWN( _value, _alignment ) \
124 ( ( _value ) & ~( ( _alignment ) - 1 ) )
125
126/* Generated from spec:/rtems/basedefs/if/align-up */
127
141#define RTEMS_ALIGN_UP( _value, _alignment ) \
142 ( ( ( _value ) + ( _alignment ) - 1 ) & ~( ( _alignment ) - 1 ) )
143
144/* Generated from spec:/rtems/basedefs/if/aligned */
145
154#if defined(__GNUC__)
155 #define RTEMS_ALIGNED( _alignment ) __attribute__(( __aligned__( _alignment ) ))
156#else
157 #define RTEMS_ALIGNED( _alignment )
158#endif
159
160/* Generated from spec:/rtems/basedefs/if/alignof */
161
171#if defined( __cplusplus ) && __cplusplus >= 201103L
172 #define RTEMS_ALIGNOF( _type_name ) alignof( _type_name )
173#elif defined( __STDC_VERSION__ ) && __STDC_VERSION__ >= 201112L
174 #define RTEMS_ALIGNOF( _type_name ) _Alignof( _type_name )
175#else
176 #define RTEMS_ALIGNOF( _type_name ) sizeof( _type_name )
177#endif
178
179/* Generated from spec:/rtems/basedefs/if/alloc-align */
180
190#if defined(__GNUC__)
191 #define RTEMS_ALLOC_ALIGN( _index ) __attribute__(( __alloc_align__( _index ) ))
192#else
193 #define RTEMS_ALLOC_ALIGN( _index )
194#endif
195
196/* Generated from spec:/rtems/basedefs/if/alloc-size */
197
206#if defined(__GNUC__)
207 #define RTEMS_ALLOC_SIZE( _index ) __attribute__(( __alloc_size__( _index ) ))
208#else
209 #define RTEMS_ALLOC_SIZE( _index )
210#endif
211
212/* Generated from spec:/rtems/basedefs/if/alloc-size-2 */
213
226#if defined(__GNUC__)
227 #define RTEMS_ALLOC_SIZE_2( _count_index, _size_index ) \
228 __attribute__(( __alloc_size__( _count_index, _size_index ) ))
229#else
230 #define RTEMS_ALLOC_SIZE_2( _count_index, _size_index )
231#endif
232
233/* Generated from spec:/rtems/basedefs/if/array-size */
234
244#define RTEMS_ARRAY_SIZE( _array ) \
245 ( sizeof( _array ) / sizeof( ( _array )[ 0 ] ) )
246
247/* Generated from spec:/rtems/basedefs/if/compiler-memory-barrier */
248
255#if defined(__GNUC__)
256 #define RTEMS_COMPILER_MEMORY_BARRIER() __asm__ volatile( "" ::: "memory" )
257#else
258 #define RTEMS_COMPILER_MEMORY_BARRIER() do { } while ( 0 )
259#endif
260
261/* Generated from spec:/rtems/basedefs/if/concat */
262
274#define RTEMS_CONCAT( _x, _y ) _x##_y
275
276/* Generated from spec:/rtems/basedefs/if/const */
277
285#if defined(__GNUC__)
286 #define RTEMS_CONST __attribute__(( __const__ ))
287#else
288 #define RTEMS_CONST
289#endif
290
291/* Generated from spec:/rtems/basedefs/if/container-of */
292
306#define RTEMS_CONTAINER_OF( _m, _type, _member_name ) \
307 ( (_type *) ( (uintptr_t) ( _m ) - offsetof( _type, _member_name ) ) )
308
309/* Generated from spec:/rtems/basedefs/if/declare-global-symbol */
310
321#define RTEMS_DECLARE_GLOBAL_SYMBOL( _name ) extern char _name[]
322
323/* Generated from spec:/rtems/basedefs/if/deprecated */
324
331#if defined(__GNUC__)
332 #define RTEMS_DEPRECATED __attribute__(( __deprecated__ ))
333#else
334 #define RTEMS_DEPRECATED
335#endif
336
337/* Generated from spec:/rtems/basedefs/if/compiler-deprecated-attribute */
338
344#define RTEMS_COMPILER_DEPRECATED_ATTRIBUTE RTEMS_DEPRECATED
345
346/* Generated from spec:/rtems/basedefs/if/expand */
347
355#define RTEMS_EXPAND( _token ) _token
356
357/* Generated from spec:/rtems/basedefs/if/function-name */
358
365#if defined(__cplusplus) && defined(__GNUC__)
366 #define RTEMS_FUNCTION_NAME __PRETTY_FUNCTION__
367#else
368 #define RTEMS_FUNCTION_NAME __func__
369#endif
370
371/* Generated from spec:/rtems/basedefs/if/no-return */
372
379#if defined( __cplusplus ) && __cplusplus >= 201103L
380 #define RTEMS_NO_RETURN [[noreturn]]
381#elif defined( __STDC_VERSION__ ) && __STDC_VERSION__ >= 201112L
382 #define RTEMS_NO_RETURN _Noreturn
383#elif defined(__GNUC__)
384 #define RTEMS_NO_RETURN __attribute__(( __noreturn__ ))
385#else
386 #define RTEMS_NO_RETURN
387#endif
388
389/* Generated from spec:/rtems/basedefs/if/compiler-no-return-attribute */
390
396#define RTEMS_COMPILER_NO_RETURN_ATTRIBUTE RTEMS_NO_RETURN
397
398/* Generated from spec:/rtems/basedefs/if/section */
399
408#if defined(__GNUC__)
409 #define RTEMS_SECTION( _section ) __attribute__(( __section__( _section ) ))
410#else
411 #define RTEMS_SECTION( _section )
412#endif
413
414/* Generated from spec:/rtems/basedefs/if/string */
415
426#define RTEMS_STRING( ... ) #__VA_ARGS__
427
428/* Generated from spec:/rtems/basedefs/if/typeof-refx */
429
444#if defined(__GNUC__)
445 #define RTEMS_TYPEOF_REFX( _level, _target ) \
446 __typeof__( _level( union { int _z; __typeof__( _target ) _x; } ){ 0 }._x )
447#else
448 #define RTEMS_TYPEOF_REFX( _level, _target )
449#endif
450
451/* Generated from spec:/rtems/basedefs/if/xconcat */
452
466#define RTEMS_XCONCAT( _x, _y ) RTEMS_CONCAT( _x, _y )
467
468#if !defined(ASM) && defined(RTEMS_DEBUG)
469 /* Generated from spec:/score/basedefs/if/debug-unreachable */
470
482 RTEMS_NO_RETURN void _Debug_Unreachable(
483 const char *file,
484 int line,
485 const char *func
486 );
487#endif
488
489#if !defined(ASM)
490 /* Generated from spec:/score/basedefs/if/dequalify-types-not-compatible */
491
498 #if defined(__GNUC__)
499 __attribute__((__error__("RTEMS_DEQUALIFY() types differ not only by volatile and const"))) void *
501 #else
503 #endif
504#endif
505
506/* Generated from spec:/rtems/basedefs/if/dequalify-depthx */
507
520#if defined(__cplusplus)
521 #define RTEMS_DEQUALIFY_DEPTHX( _ptr_level, _type, _var ) \
522 ( const_cast<_type>( _var ) )
523#elif defined(__GNUC__)
524 #define RTEMS_DEQUALIFY_DEPTHX( _ptr_level, _type, _var ) \
525 __builtin_choose_expr( \
526 __builtin_types_compatible_p( \
527 RTEMS_TYPEOF_REFX( _ptr_level, _var ), \
528 RTEMS_TYPEOF_REFX( _ptr_level, _type ) \
529 ) || \
530 __builtin_types_compatible_p( \
531 _type, \
532 void * \
533 ), \
534 (_type) ( _var ), \
535 RTEMS_DEQUALIFY_types_not_compatible() \
536 )
537#else
538 #define RTEMS_DEQUALIFY_DEPTHX( _ptr_level, _type, _var ) \
539 ( (_type) (uintptr_t) (const volatile void *)( _var ) )
540#endif
541
542/* Generated from spec:/rtems/basedefs/if/deconst */
543
554#define RTEMS_DECONST( _type, _var ) RTEMS_DEQUALIFY_DEPTHX( *, _type, _var )
555
556/* Generated from spec:/rtems/basedefs/if/dequalify */
557
568#define RTEMS_DEQUALIFY( _type, _var ) RTEMS_DEQUALIFY_DEPTHX( *, _type, _var )
569
570/* Generated from spec:/rtems/basedefs/if/devolatile */
571
582#define RTEMS_DEVOLATILE( _type, _var ) RTEMS_DEQUALIFY_DEPTHX( *, _type, _var )
583
584/* Generated from spec:/rtems/basedefs/if/fallthrough */
585
601#if defined( __STDC_VERSION__ ) && __STDC_VERSION__ >= 202311L
602 #define RTEMS_FALL_THROUGH() [[fallthrough]]
603#elif defined(__GNUC__)
604 #define RTEMS_FALL_THROUGH() __attribute__(( __fallthrough__ ))
605#else
606 #define RTEMS_FALL_THROUGH() do {} while ( 0 ) /* Fall through */
607#endif
608
609#if !defined(FALSE)
610 /* Generated from spec:/rtems/basedefs/if/false */
611
617 #define FALSE 0
618#endif
619
620/* Generated from spec:/rtems/basedefs/if/have-member-same-type */
621
638#if defined(__GNUC__)
639 #define RTEMS_HAVE_MEMBER_SAME_TYPE( _t_lhs, _m_lhs, _t_rhs, _m_rhs ) \
640 __builtin_types_compatible_p( \
641 __typeof__( ( (_t_lhs *) 0 )->_m_lhs ), \
642 __typeof__( ( (_t_rhs *) 0 )->_m_rhs ) \
643 )
644#else
645 #define RTEMS_HAVE_MEMBER_SAME_TYPE( _t_lhs, _m_lhs, _t_rhs, _m_rhs ) true
646#endif
647
648/* Generated from spec:/rtems/basedefs/if/inline-routine */
649
656#if defined(__GNUC__)
657 #define RTEMS_INLINE_ROUTINE static __inline__
658#else
659 #define RTEMS_INLINE_ROUTINE static inline
660#endif
661
662/* Generated from spec:/rtems/basedefs/if/malloclike */
663
670#if defined(__GNUC__)
671 #define RTEMS_MALLOCLIKE __attribute__(( __malloc__ ))
672#else
673 #define RTEMS_MALLOCLIKE
674#endif
675
676/* Generated from spec:/rtems/basedefs/if/no-inline */
677
684#if defined(__GNUC__)
685 #define RTEMS_NO_INLINE __attribute__(( __noinline__ ))
686#else
687 #define RTEMS_NO_INLINE
688#endif
689
690/* Generated from spec:/rtems/basedefs/if/noinit */
691
698#define RTEMS_NOINIT RTEMS_SECTION( ".noinit" )
699
700/* Generated from spec:/rtems/basedefs/if/obfuscate-variable */
701
712#if defined(__GNUC__)
713 #define RTEMS_OBFUSCATE_VARIABLE( _var ) __asm__( "" : "+r" ( _var ) )
714#else
715 #define RTEMS_OBFUSCATE_VARIABLE( _var ) (void) ( _var )
716#endif
717
718/* Generated from spec:/rtems/basedefs/if/packed */
719
726#if defined(__GNUC__)
727 #define RTEMS_PACKED __attribute__(( __packed__ ))
728#else
729 #define RTEMS_PACKED
730#endif
731
732/* Generated from spec:/rtems/basedefs/if/compiler-packed-attribute */
733
739#define RTEMS_COMPILER_PACKED_ATTRIBUTE RTEMS_PACKED
740
741/* Generated from spec:/rtems/basedefs/if/predict-false */
742
754#if defined(__GNUC__)
755 #define RTEMS_PREDICT_FALSE( _exp ) __builtin_expect( ( _exp ), 0 )
756#else
757 #define RTEMS_PREDICT_FALSE( _exp ) ( _exp )
758#endif
759
760/* Generated from spec:/rtems/basedefs/if/predict-true */
761
773#if defined(__GNUC__)
774 #define RTEMS_PREDICT_TRUE( _exp ) __builtin_expect( ( _exp ), 1 )
775#else
776 #define RTEMS_PREDICT_TRUE( _exp ) ( _exp )
777#endif
778
779/* Generated from spec:/rtems/basedefs/if/printflike */
780
793#if defined(__GNUC__)
794 #define RTEMS_PRINTFLIKE( _format_pos, _ap_pos ) \
795 __attribute__(( __format__( __printf__, _format_pos, _ap_pos ) ))
796#else
797 #define RTEMS_PRINTFLIKE( _format_pos, _ap_pos )
798#endif
799
800/* Generated from spec:/rtems/basedefs/if/pure */
801
809#if defined(__GNUC__)
810 #define RTEMS_PURE __attribute__(( __pure__ ))
811#else
812 #define RTEMS_PURE
813#endif
814
815/* Generated from spec:/rtems/basedefs/if/compiler-pure-attribute */
816
822#define RTEMS_COMPILER_PURE_ATTRIBUTE RTEMS_PURE
823
824/* Generated from spec:/rtems/basedefs/if/return-address */
825
833#if defined(__GNUC__)
834 #define RTEMS_RETURN_ADDRESS() __builtin_return_address( 0 )
835#else
836 #define RTEMS_RETURN_ADDRESS() NULL
837#endif
838
839/* Generated from spec:/rtems/basedefs/if/static-analysis */
840
846#if defined(__COVERITY__)
847 #define RTEMS_STATIC_ANALYSIS
848#endif
849
850/* Generated from spec:/rtems/basedefs/if/static-assert */
851
861#if defined( __cplusplus ) && __cplusplus >= 201103L
862 #define RTEMS_STATIC_ASSERT( _cond, _msg ) static_assert( _cond, # _msg )
863#elif defined( __STDC_VERSION__ ) && __STDC_VERSION__ >= 201112L
864 #define RTEMS_STATIC_ASSERT( _cond, _msg ) _Static_assert( _cond, # _msg )
865#else
866 #define RTEMS_STATIC_ASSERT( _cond, _msg ) \
867 struct rtems_static_assert_ ## _msg \
868 { int rtems_static_assert_ ## _msg : ( _cond ) ? 1 : -1; }
869#endif
870
871/* Generated from spec:/rtems/basedefs/if/symbol-name */
872
883#if defined(__USER_LABEL_PREFIX__)
884 #define RTEMS_SYMBOL_NAME( _name ) RTEMS_XCONCAT( __USER_LABEL_PREFIX__, _name )
885#else
886 #define RTEMS_SYMBOL_NAME( _name ) RTEMS_EXPAND( _name )
887#endif
888
889#if !defined(TRUE)
890 /* Generated from spec:/rtems/basedefs/if/true */
891
897 #define TRUE 1
898#endif
899
900/* Generated from spec:/rtems/basedefs/if/unreachable */
901
907#if defined(RTEMS_DEBUG)
908 #define RTEMS_UNREACHABLE() \
909 _Debug_Unreachable( __FILE__, __LINE__, RTEMS_FUNCTION_NAME )
910#elif defined(__GNUC__)
911 #define RTEMS_UNREACHABLE() __builtin_unreachable()
912#else
913 #define RTEMS_UNREACHABLE() do { } while ( 0 )
914#endif
915
916/* Generated from spec:/rtems/basedefs/if/unused */
917
924#if defined(__GNUC__)
925 #define RTEMS_UNUSED __attribute__(( __unused__ ))
926#else
927 #define RTEMS_UNUSED
928#endif
929
930/* Generated from spec:/rtems/basedefs/if/compiler-unused-attribute */
931
937#define RTEMS_COMPILER_UNUSED_ATTRIBUTE RTEMS_UNUSED
938
939/* Generated from spec:/rtems/basedefs/if/used */
940
946#if defined(__GNUC__)
947 #define RTEMS_USED __attribute__(( __used__ ))
948#else
949 #define RTEMS_USED
950#endif
951
952/* Generated from spec:/rtems/basedefs/if/warn-unused-result */
953
960#if defined(__GNUC__)
961 #define RTEMS_WARN_UNUSED_RESULT __attribute__(( __warn_unused_result__ ))
962#else
963 #define RTEMS_WARN_UNUSED_RESULT
964#endif
965
966/* Generated from spec:/rtems/basedefs/if/weak */
967
977#if defined(__GNUC__)
978 #define RTEMS_WEAK __attribute__(( __weak__ ))
979#else
980 #define RTEMS_WEAK
981#endif
982
983/* Generated from spec:/rtems/basedefs/if/weak-alias */
984
993#if defined(__GNUC__)
994 #define RTEMS_WEAK_ALIAS( _target ) \
995 __attribute__(( __weak__, __alias__( #_target ) ))
996#else
997 #define RTEMS_WEAK_ALIAS( _target )
998#endif
999
1000/* Generated from spec:/rtems/basedefs/if/xstring */
1001
1012#define RTEMS_XSTRING( ... ) RTEMS_STRING( __VA_ARGS__ )
1013
1014/* Generated from spec:/rtems/basedefs/if/define-global-symbol */
1015
1032#if defined(__GNUC__)
1033 #define RTEMS_DEFINE_GLOBAL_SYMBOL( _name, _value ) \
1034 __asm__( \
1035 "\t.globl " RTEMS_XSTRING( RTEMS_SYMBOL_NAME( _name ) ) \
1036 "\n\t.set " RTEMS_XSTRING( RTEMS_SYMBOL_NAME( _name ) ) \
1037 ", " RTEMS_STRING( _value ) "\n" \
1038 )
1039#else
1040 #define RTEMS_DEFINE_GLOBAL_SYMBOL( _name, _value )
1041#endif
1042
1043/* Generated from spec:/rtems/basedefs/if/zero-length-array */
1044
1054#if __STDC_VERSION__ >= 199409L
1055 #define RTEMS_ZERO_LENGTH_ARRAY
1056#else
1057 #define RTEMS_ZERO_LENGTH_ARRAY 0
1058#endif
1059
1060#ifdef __cplusplus
1061}
1062#endif
1063
1064#endif /* _RTEMS_SCORE_BASEDEFS_H */
#define RTEMS_NO_RETURN
Tells the compiler in a function declaration that this function does not return.
Definition: basedefs.h:386
void * RTEMS_DEQUALIFY_types_not_compatible(void)
A not implemented function to trigger compile time errors with an error message.
Definition: xnandpsu_onfi.h:185