RTEMS
basedefs.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: BSD-2-Clause */
2 
13 /*
14  * Copyright (C) 2014 Paval Pisa
15  * Copyright (C) 2011, 2013 On-Line Applications Research Corporation (OAR)
16  * Copyright (C) 2009, 2020 embedded brains GmbH (http://www.embedded-brains.de)
17  *
18  * Redistribution and use in source and binary forms, with or without
19  * modification, are permitted provided that the following conditions
20  * are met:
21  * 1. Redistributions of source code must retain the above copyright
22  * notice, this list of conditions and the following disclaimer.
23  * 2. Redistributions in binary form must reproduce the above copyright
24  * notice, this list of conditions and the following disclaimer in the
25  * documentation and/or other materials provided with the distribution.
26  *
27  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
28  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
29  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
30  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
31  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
32  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
33  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
34  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
35  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
36  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
37  * POSSIBILITY OF SUCH DAMAGE.
38  */
39 
40 /*
41  * Do not manually edit this file. It is part of the RTEMS quality process
42  * and was automatically generated.
43  *
44  * If you find something that needs to be fixed or worded better please
45  * post a report to an RTEMS mailing list or raise a bug report:
46  *
47  * https://docs.rtems.org/branches/master/user/support/bugs.html
48  *
49  * For information on updating and regenerating please refer to:
50  *
51  * https://docs.rtems.org/branches/master/eng/req/howto.html
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
68 extern "C" {
69 #endif
70 
71 /* Generated from spec:/if/api */
72 
81 /* Generated from spec:/rtems/basedefs/if/group */
82 
92 /* Generated from spec:/rtems/basedefs/if/concat */
93 
105 #define RTEMS_CONCAT( _x, _y ) _x##_y
106 
107 #if !defined(ASM)
108  /* Generated from spec:/score/if/dequalify-types-not-compatible */
109 
114  #if defined(__GNUC__)
115  __attribute__((__error__("RTEMS_DEQUALIFY() types differ not only by volatile and const"))) void *
117  #else
119  #endif
120 #endif
121 
122 /* Generated from spec:/rtems/basedefs/if/typeof-refx */
123 
136 #if defined(__GNUC__)
137  #define RTEMS_TYPEOF_REFX( _level, _target ) \
138  __typeof__(_level(union { int z; __typeof__(_target) x; }){0}.x)
139 #else
140  #define RTEMS_TYPEOF_REFX( _level, _target )
141 #endif
142 
143 /* Generated from spec:/rtems/basedefs/if/string */
144 
154 #define RTEMS_STRING( _x ) #_x
155 
156 /* Generated from spec:/rtems/basedefs/if/xconcat */
157 
171 #define RTEMS_XCONCAT( _x, _y ) RTEMS_CONCAT( _x, _y )
172 
173 /* Generated from spec:/rtems/basedefs/if/expand */
174 
182 #define RTEMS_EXPAND( _token ) _token
183 
184 /* Generated from spec:/rtems/basedefs/if/deprecated */
185 
192 #if defined(__GNUC__)
193  #define RTEMS_DEPRECATED __attribute__((__deprecated__))
194 #else
195  #define RTEMS_DEPRECATED
196 #endif
197 
198 /* Generated from spec:/rtems/basedefs/if/no-return */
199 
206 #if defined(__GNUC__)
207  #define RTEMS_NO_RETURN __attribute__((__noreturn__))
208 #else
209  #define RTEMS_NO_RETURN
210 #endif
211 
212 /* Generated from spec:/rtems/basedefs/if/packed */
213 
220 #if defined(__GNUC__)
221  #define RTEMS_PACKED __attribute__((__packed__))
222 #else
223  #define RTEMS_PACKED
224 #endif
225 
226 /* Generated from spec:/rtems/basedefs/if/pure */
227 
235 #if defined(__GNUC__)
236  #define RTEMS_PURE __attribute__((__pure__))
237 #else
238  #define RTEMS_PURE
239 #endif
240 
241 /* Generated from spec:/rtems/basedefs/if/used */
242 
248 #if defined(__GNUC__)
249  #define RTEMS_USED __attribute__((__used__))
250 #else
251  #define RTEMS_USED
252 #endif
253 
254 /* Generated from spec:/rtems/basedefs/if/dequalify-depthx */
255 
268 #if defined(__cplusplus)
269  #define RTEMS_DEQUALIFY_DEPTHX( _ptr_level, _type, _var ) \
270  (const_cast<_type>(_var))
271 #elif defined(__GNUC__)
272  #define RTEMS_DEQUALIFY_DEPTHX( _ptr_level, _type, _var ) \
273  __builtin_choose_expr(__builtin_types_compatible_p( \
274  RTEMS_TYPEOF_REFX(_ptr_level, _var), \
275  RTEMS_TYPEOF_REFX(_ptr_level, _type) \
276  ) || __builtin_types_compatible_p(_type, void *), \
277  (_type)(_var), \
278  RTEMS_DEQUALIFY_types_not_compatible())
279 #else
280  #define RTEMS_DEQUALIFY_DEPTHX( _ptr_level, _type, _var ) \
281  ((_type)(uintptr_t)(const volatile void *)(_var))
282 #endif
283 
284 /* Generated from spec:/rtems/basedefs/if/xstring */
285 
295 #define RTEMS_XSTRING( _x ) RTEMS_STRING( _x )
296 
297 /* Generated from spec:/rtems/basedefs/if/symbol-name */
298 
307 #if defined(__USER_LABEL_PREFIX__)
308  #define RTEMS_SYMBOL_NAME( _name ) RTEMS_XCONCAT(__USER_LABEL_PREFIX__, _name)
309 #else
310  #define RTEMS_SYMBOL_NAME( _name ) RTEMS_EXPAND(_name)
311 #endif
312 
313 /* Generated from spec:/score/if/assert-unreachable */
314 
318 #if defined(RTEMS_DEBUG)
319  #define _Assert_Unreachable() _Assert( 0 )
320 #else
321  #define _Assert_Unreachable() do { } while ( 0 )
322 #endif
323 
324 /* Generated from spec:/rtems/basedefs/if/alias */
325 
334 #if defined(__GNUC__)
335  #define RTEMS_ALIAS( _target ) __attribute__((__alias__(#_target)))
336 #else
337  #define RTEMS_ALIAS( _target )
338 #endif
339 
340 /* Generated from spec:/rtems/basedefs/if/align-down */
341 
356 #define RTEMS_ALIGN_DOWN( _value, _alignment ) \
357  ( ( _value ) & ~( ( _alignment ) - 1 ) )
358 
359 /* Generated from spec:/rtems/basedefs/if/align-up */
360 
375 #define RTEMS_ALIGN_UP( _value, _alignment ) \
376  ( ( ( _value ) + ( _alignment ) - 1 ) & ~( ( _alignment ) - 1 ) )
377 
378 /* Generated from spec:/rtems/basedefs/if/aligned */
379 
388 #if defined(__GNUC__)
389  #define RTEMS_ALIGNED( _alignment ) __attribute__((__aligned__(_alignment)))
390 #else
391  #define RTEMS_ALIGNED( _alignment )
392 #endif
393 
394 /* Generated from spec:/rtems/basedefs/if/alloc-align */
395 
405 #if defined(__GNUC__)
406  #define RTEMS_ALLOC_ALIGN( _index ) __attribute__((__alloc_align__(_index)))
407 #else
408  #define RTEMS_ALLOC_ALIGN( _index )
409 #endif
410 
411 /* Generated from spec:/rtems/basedefs/if/alloc-size */
412 
421 #if defined(__GNUC__)
422  #define RTEMS_ALLOC_SIZE( _index ) __attribute__((__alloc_size__(_index)))
423 #else
424  #define RTEMS_ALLOC_SIZE( _index )
425 #endif
426 
427 /* Generated from spec:/rtems/basedefs/if/alloc-size-2 */
428 
441 #if defined(__GNUC__)
442  #define RTEMS_ALLOC_SIZE_2( _count_index, _size_index ) \
443  __attribute__((__alloc_size__(_count_index, _size_index)))
444 #else
445  #define RTEMS_ALLOC_SIZE_2( _count_index, _size_index )
446 #endif
447 
448 /* Generated from spec:/rtems/basedefs/if/array-size */
449 
459 #define RTEMS_ARRAY_SIZE( _array ) (sizeof(_array) / sizeof((_array)[0]))
460 
461 /* Generated from spec:/rtems/basedefs/if/compiler-deprecated-attribute */
462 
468 #define RTEMS_COMPILER_DEPRECATED_ATTRIBUTE RTEMS_DEPRECATED
469 
470 /* Generated from spec:/rtems/basedefs/if/compiler-memory-barrier */
471 
478 #if defined(__GNUC__)
479  #define RTEMS_COMPILER_MEMORY_BARRIER() __asm__ volatile( "" ::: "memory" )
480 #else
481  #define RTEMS_COMPILER_MEMORY_BARRIER() do { } while ( 0 )
482 #endif
483 
484 /* Generated from spec:/rtems/basedefs/if/compiler-no-return-attribute */
485 
491 #define RTEMS_COMPILER_NO_RETURN_ATTRIBUTE RTEMS_NO_RETURN
492 
493 /* Generated from spec:/rtems/basedefs/if/compiler-packed-attribute */
494 
500 #define RTEMS_COMPILER_PACKED_ATTRIBUTE RTEMS_PACKED
501 
502 /* Generated from spec:/rtems/basedefs/if/compiler-pure-attribute */
503 
509 #define RTEMS_COMPILER_PURE_ATTRIBUTE RTEMS_PURE
510 
511 /* Generated from spec:/rtems/basedefs/if/compiler-used-attribute */
512 
518 #define RTEMS_COMPILER_USED_ATTRIBUTE RTEMS_USED
519 
520 /* Generated from spec:/rtems/basedefs/if/const */
521 
529 #if defined(__GNUC__)
530  #define RTEMS_CONST __attribute__((__const__))
531 #else
532  #define RTEMS_CONST
533 #endif
534 
535 /* Generated from spec:/rtems/basedefs/if/container-of */
536 
550 #define RTEMS_CONTAINER_OF( _m, _type, _member_name ) \
551  ( (_type *) ( (uintptr_t) ( _m ) - offsetof( _type, _member_name ) ) )
552 
553 /* Generated from spec:/rtems/basedefs/if/declare-global-symbol */
554 
565 #define RTEMS_DECLARE_GLOBAL_SYMBOL( _name ) extern char _name[]
566 
567 /* Generated from spec:/rtems/basedefs/if/deconst */
568 
579 #define RTEMS_DECONST( _type, _var ) RTEMS_DEQUALIFY_DEPTHX(*, _type, _var)
580 
581 /* Generated from spec:/rtems/basedefs/if/define-global-symbol */
582 
598 #if defined(__USER_LABEL_PREFIX__)
599  #define RTEMS_DEFINE_GLOBAL_SYMBOL( _name, _value ) \
600  __asm__( \
601  "\t.globl " RTEMS_XSTRING( RTEMS_SYMBOL_NAME( _name ) ) \
602  "\n\t.set " RTEMS_XSTRING( RTEMS_SYMBOL_NAME( _name ) ) \
603  ", " RTEMS_STRING( _value ) "\n" \
604  )
605 #else
606  #define RTEMS_DEFINE_GLOBAL_SYMBOL( _name, _value )
607 #endif
608 
609 /* Generated from spec:/rtems/basedefs/if/dequalify */
610 
621 #define RTEMS_DEQUALIFY( _type, _var ) RTEMS_DEQUALIFY_DEPTHX(*, _type, _var)
622 
623 /* Generated from spec:/rtems/basedefs/if/devolatile */
624 
635 #define RTEMS_DEVOLATILE( _type, _var ) RTEMS_DEQUALIFY_DEPTHX(*, _type, _var)
636 
637 #if !defined(FALSE)
638  /* Generated from spec:/rtems/basedefs/if/false */
639 
645  #define FALSE 0
646 #endif
647 
648 /* Generated from spec:/rtems/basedefs/if/have-member-same-type */
649 
664 #if defined(__GNUC__)
665  #define RTEMS_HAVE_MEMBER_SAME_TYPE( _t_lhs, _m_lhs, _t_rhs, _m_rhs ) \
666  __builtin_types_compatible_p( \
667  __typeof__( ( (_t_lhs *) 0 )->_m_lhs ), \
668  __typeof__( ( (_t_rhs *) 0 )->_m_rhs ) \
669  )
670 #else
671  #define RTEMS_HAVE_MEMBER_SAME_TYPE( _t_lhs, _m_lhs, _t_rhs, _m_rhs ) true
672 #endif
673 
674 /* Generated from spec:/rtems/basedefs/if/inline-routine */
675 
682 #if defined(__GNUC__)
683  #define RTEMS_INLINE_ROUTINE static __inline__
684 #else
685  #define RTEMS_INLINE_ROUTINE static inline
686 #endif
687 
688 /* Generated from spec:/rtems/basedefs/if/malloclike */
689 
696 #if defined(__GNUC__)
697  #define RTEMS_MALLOCLIKE __attribute__((__malloc__))
698 #else
699  #define RTEMS_MALLOCLIKE
700 #endif
701 
702 /* Generated from spec:/rtems/basedefs/if/no-inline */
703 
710 #if defined(__GNUC__)
711  #define RTEMS_NO_INLINE __attribute__((__noinline__))
712 #else
713  #define RTEMS_NO_INLINE
714 #endif
715 
716 /* Generated from spec:/rtems/basedefs/if/obfuscate-variable */
717 
728 #if defined(__GNUC__)
729  #define RTEMS_OBFUSCATE_VARIABLE( _var ) __asm__( "" : "+r" ( _var ) )
730 #else
731  #define RTEMS_OBFUSCATE_VARIABLE( _var ) (void) (_var)
732 #endif
733 
734 /* Generated from spec:/rtems/basedefs/if/predict-false */
735 
746 #if defined(__GNUC__)
747  #define RTEMS_PREDICT_FALSE( _exp ) __builtin_expect( ( _exp ), 0 )
748 #else
749  #define RTEMS_PREDICT_FALSE( _exp ) ( _exp )
750 #endif
751 
752 /* Generated from spec:/rtems/basedefs/if/predict-true */
753 
764 #if defined(__GNUC__)
765  #define RTEMS_PREDICT_TRUE( _exp ) __builtin_expect( ( _exp ), 1 )
766 #else
767  #define RTEMS_PREDICT_TRUE( _exp ) ( _exp )
768 #endif
769 
770 /* Generated from spec:/rtems/basedefs/if/printflike */
771 
784 #if defined(__GNUC__)
785  #define RTEMS_PRINTFLIKE( _format_pos, _ap_pos ) \
786  __attribute__((__format__(__printf__, _format_pos, _ap_pos)))
787 #else
788  #define RTEMS_PRINTFLIKE( _format_pos, _ap_pos )
789 #endif
790 
791 /* Generated from spec:/rtems/basedefs/if/return-address */
792 
800 #if defined(__GNUC__)
801  #define RTEMS_RETURN_ADDRESS() __builtin_return_address(0)
802 #else
803  #define RTEMS_RETURN_ADDRESS() NULL
804 #endif
805 
806 /* Generated from spec:/rtems/basedefs/if/section */
807 
816 #if defined(__GNUC__)
817  #define RTEMS_SECTION( _section ) __attribute__((__section__(_section)))
818 #else
819  #define RTEMS_SECTION( _section )
820 #endif
821 
822 /* Generated from spec:/rtems/basedefs/if/static-assert */
823 
833 #if __cplusplus >= 201103L
834  #define RTEMS_STATIC_ASSERT( _cond, _msg ) static_assert(_cond, # _msg)
835 #elif __STDC_VERSION__ >= 201112L
836  #define RTEMS_STATIC_ASSERT( _cond, _msg ) _Static_assert(_cond, # _msg)
837 #else
838  #define RTEMS_STATIC_ASSERT( _cond, _msg ) \
839  struct rtems_static_assert_ ## _msg \
840  { int rtems_static_assert_ ## _msg : (_cond) ? 1 : -1; }
841 #endif
842 
843 #if !defined(TRUE)
844  /* Generated from spec:/rtems/basedefs/if/true */
845 
851  #define TRUE 1
852 #endif
853 
854 /* Generated from spec:/rtems/basedefs/if/unreachable */
855 
859 #if defined(__GNUC__)
860  #define RTEMS_UNREACHABLE() \
861  do { \
862  __builtin_unreachable(); \
863  _Assert_Unreachable(); \
864  } while ( 0 )
865 #else
866  #define RTEMS_UNREACHABLE() _Assert_Unreachable()
867 #endif
868 
869 /* Generated from spec:/rtems/basedefs/if/unused */
870 
877 #if defined(__GNUC__)
878  #define RTEMS_UNUSED __attribute__((__unused__))
879 #else
880  #define RTEMS_UNUSED
881 #endif
882 
883 /* Generated from spec:/rtems/basedefs/if/warn-unused-result */
884 
891 #if defined(__GNUC__)
892  #define RTEMS_WARN_UNUSED_RESULT __attribute__((__warn_unused_result__))
893 #else
894  #define RTEMS_WARN_UNUSED_RESULT
895 #endif
896 
897 /* Generated from spec:/rtems/basedefs/if/weak */
898 
908 #if defined(__GNUC__)
909  #define RTEMS_WEAK __attribute__((__weak__))
910 #else
911  #define RTEMS_WEAK
912 #endif
913 
914 /* Generated from spec:/rtems/basedefs/if/weak-alias */
915 
924 #if defined(__GNUC__)
925  #define RTEMS_WEAK_ALIAS( _target ) \
926  __attribute__((__weak__, __alias__(#_target)))
927 #else
928  #define RTEMS_WEAK_ALIAS( _target )
929 #endif
930 
931 /* Generated from spec:/rtems/basedefs/if/zero-length-array */
932 
942 #if __STDC_VERSION__ >= 199409L
943  #define RTEMS_ZERO_LENGTH_ARRAY
944 #else
945  #define RTEMS_ZERO_LENGTH_ARRAY 0
946 #endif
947 
948 #ifdef __cplusplus
949 }
950 #endif
951 
952 #endif /* _RTEMS_SCORE_BASEDEFS_H */
void * RTEMS_DEQUALIFY_types_not_compatible(void)
A not implemented function to trigger compile time errors with an error message.