summaryrefslogtreecommitdiffstats
path: root/cpukit/include/rtems/score/basedefs.h
blob: c682106c53b5f8ff5d1bf430e700e494c1faa382 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
/* SPDX-License-Identifier: BSD-2-Clause */

/**
 * @file
 *
 * @brief This header file provides basic definitions used by the API and the
 *   implementation.
 */

/*
 * Copyright (C) 2014 Paval Pisa
 * Copyright (C) 2011, 2013 On-Line Applications Research Corporation (OAR)
 * Copyright (C) 2009, 2021 embedded brains GmbH (http://www.embedded-brains.de)
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 */

/*
 * This file is part of the RTEMS quality process and was automatically
 * generated.  If you find something that needs to be fixed or
 * worded better please post a report or patch to an RTEMS mailing list
 * or raise a bug report:
 *
 * https://www.rtems.org/bugs.html
 *
 * For information on updating and regenerating please refer to the How-To
 * section in the Software Requirements Engineering chapter of the
 * RTEMS Software Engineering manual.  The manual is provided as a part of
 * a release.  For development sources please refer to the online
 * documentation at:
 *
 * https://docs.rtems.org
 */

/* Generated from spec:/rtems/basedefs/if/header */

#ifndef _RTEMS_SCORE_BASEDEFS_H
#define _RTEMS_SCORE_BASEDEFS_H

#include <rtems/score/cpuopts.h>

#if !defined(ASM)
  #include <stdbool.h>
  #include <stddef.h>
  #include <stdint.h>
#endif

#ifdef __cplusplus
extern "C" {
#endif

/* Generated from spec:/if/api */

/**
 * @defgroup RTEMSAPI API
 *
 * @brief API
 *
 * This group contains the RTEMS Application Programming Interface (API).
 */

/* Generated from spec:/rtems/basedefs/if/group */

/**
 * @defgroup RTEMSAPIBaseDefs Base Definitions
 *
 * @ingroup RTEMSAPI
 *
 * @brief This group contains basic macros and defines to give access to
 *   compiler-specific features.
 */

/* Generated from spec:/rtems/basedefs/if/alias */

/**
 * @ingroup RTEMSAPIBaseDefs
 *
 * @brief Instructs the compiler to generate an alias to the target function.
 *
 * @param _target is the target function name.
 */
#if defined(__GNUC__)
  #define RTEMS_ALIAS( _target ) __attribute__(( __alias__( #_target ) ))
#else
  #define RTEMS_ALIAS( _target )
#endif

/* Generated from spec:/rtems/basedefs/if/align-down */

/**
 * @ingroup RTEMSAPIBaseDefs
 *
 * @brief Aligns down the value to the alignment.
 *
 * @param _value is the value to align down.
 *
 * @param _alignment is the desired alignment in bytes.  The alignment shall be
 *   a power of two, otherwise the returned value is undefined.  The alignment
 *   parameter is evaluated twice.
 *
 * @return Returns the value aligned down to the alignment.
 */
#define RTEMS_ALIGN_DOWN( _value, _alignment ) \
  ( ( _value ) & ~( ( _alignment ) - 1 ) )

/* Generated from spec:/rtems/basedefs/if/align-up */

/**
 * @ingroup RTEMSAPIBaseDefs
 *
 * @brief Aligns up the value to the alignment.
 *
 * @param _value is the value to align up.
 *
 * @param _alignment is the desired alignment in bytes.  The alignment shall be
 *   a power of two, otherwise the returned value is undefined.  The alignment
 *   parameter is evaluated twice.
 *
 * @return Returns the value aligned up to the alignment.
 */
#define RTEMS_ALIGN_UP( _value, _alignment ) \
  ( ( ( _value ) + ( _alignment ) - 1 ) & ~( ( _alignment ) - 1 ) )

/* Generated from spec:/rtems/basedefs/if/aligned */

/**
 * @ingroup RTEMSAPIBaseDefs
 *
 * @brief Instructs the compiler in a declaration or definition to enforce the
 *   alignment.
 *
 * @param _alignment is the desired alignment in bytes.
 */
#if defined(__GNUC__)
  #define RTEMS_ALIGNED( _alignment ) __attribute__(( __aligned__( _alignment ) ))
#else
  #define RTEMS_ALIGNED( _alignment )
#endif

/* Generated from spec:/rtems/basedefs/if/alignof */

/**
 * @ingroup RTEMSAPIBaseDefs
 *
 * @brief Gets the alignment requirement of the type.
 *
 * @param _type_name is the type name to get the alignment requirement for.
 *
 * @return Returns the alignment requirement of the type.
 */
#if __cplusplus >= 201103L
  #define RTEMS_ALIGNOF( _type_name ) alignof( _type_name )
#elif __STDC_VERSION__ >= 201112L
  #define RTEMS_ALIGNOF( _type_name ) _Alignof( _type_name )
#else
  #define RTEMS_ALIGNOF( _type_name ) sizeof( _type_name )
#endif

/* Generated from spec:/rtems/basedefs/if/alloc-align */

/**
 * @ingroup RTEMSAPIBaseDefs
 *
 * @brief Tells the compiler in a declaration that the memory allocation
 *   alignment parameter of this function is similar to aligned_alloc().
 *
 * @param _index is the allocation alignment parameter index (starting with
 *   one).
 */
#if defined(__GNUC__)
  #define RTEMS_ALLOC_ALIGN( _index ) __attribute__(( __alloc_align__( _index ) ))
#else
  #define RTEMS_ALLOC_ALIGN( _index )
#endif

/* Generated from spec:/rtems/basedefs/if/alloc-size */

/**
 * @ingroup RTEMSAPIBaseDefs
 *
 * @brief Tells the compiler in a declaration that the memory allocation size
 *   parameter of this function is similar to malloc().
 *
 * @param _index is the allocation size parameter index (starting with one).
 */
#if defined(__GNUC__)
  #define RTEMS_ALLOC_SIZE( _index ) __attribute__(( __alloc_size__( _index ) ))
#else
  #define RTEMS_ALLOC_SIZE( _index )
#endif

/* Generated from spec:/rtems/basedefs/if/alloc-size-2 */

/**
 * @ingroup RTEMSAPIBaseDefs
 *
 * @brief Tells the compiler in a declaration that the memory allocation item
 *   count and item size parameter of this function is similar to calloc().
 *
 * @param _count_index is the allocation item count parameter index (starting
 *   with one).
 *
 * @param _size_index is the allocation item size parameter index (starting
 *   with one).
 */
#if defined(__GNUC__)
  #define RTEMS_ALLOC_SIZE_2( _count_index, _size_index ) \
    __attribute__(( __alloc_size__( _count_index, _size_index ) ))
#else
  #define RTEMS_ALLOC_SIZE_2( _count_index, _size_index )
#endif

/* Generated from spec:/rtems/basedefs/if/array-size */

/**
 * @ingroup RTEMSAPIBaseDefs
 *
 * @brief Gets the element count of the array.
 *
 * @param _array is the name of the array.  This parameter is evaluated twice.
 *
 * @return Returns the element count of the array.
 */
#define RTEMS_ARRAY_SIZE( _array ) \
  ( sizeof( _array ) / sizeof( ( _array )[ 0 ] ) )

/* Generated from spec:/rtems/basedefs/if/compiler-memory-barrier */

/**
 * @ingroup RTEMSAPIBaseDefs
 *
 * @brief This macro forbids the compiler to reorder read and write commands
 *   around it.
 */
#if defined(__GNUC__)
  #define RTEMS_COMPILER_MEMORY_BARRIER() __asm__ volatile( "" ::: "memory" )
#else
  #define RTEMS_COMPILER_MEMORY_BARRIER() do { } while ( 0 )
#endif

/* Generated from spec:/rtems/basedefs/if/concat */

/**
 * @ingroup RTEMSAPIBaseDefs
 *
 * @brief Concatenates _x and _y without expanding.
 *
 * @param _x is the left hand side token of the concatenation.
 *
 * @param _y is the right hand side token of the concatenation.
 *
 * @return Returns the concatenation of the tokens _x and _y.
 */
#define RTEMS_CONCAT( _x, _y ) _x##_y

/* Generated from spec:/rtems/basedefs/if/const */

/**
 * @ingroup RTEMSAPIBaseDefs
 *
 * @brief Tells the compiler in a function declaration that this function has
 *   no effect except the return value and that the return value depends only
 *   on the value of parameters.
 */
#if defined(__GNUC__)
  #define RTEMS_CONST __attribute__(( __const__ ))
#else
  #define RTEMS_CONST
#endif

/* Generated from spec:/rtems/basedefs/if/container-of */

/**
 * @ingroup RTEMSAPIBaseDefs
 *
 * @brief Gets the container of a member.
 *
 * @param _m is the pointer to a member of the container.
 *
 * @param _type is the type of the container.
 *
 * @param _member_name is the designator name of the container member.
 *
 * @return Returns the pointer to the container of a member pointer.
 */
#define RTEMS_CONTAINER_OF( _m, _type, _member_name ) \
  ( (_type *) ( (uintptr_t) ( _m ) - offsetof( _type, _member_name ) ) )

/* Generated from spec:/rtems/basedefs/if/declare-global-symbol */

/**
 * @ingroup RTEMSAPIBaseDefs
 *
 * @brief Declares a global symbol with the name.
 *
 * @param _name is the name of the global symbol.  It shall be a valid
 *   designator.
 *
 * This macro must be placed at file scope.
 */
#define RTEMS_DECLARE_GLOBAL_SYMBOL( _name ) extern char _name[]

/* Generated from spec:/rtems/basedefs/if/deprecated */

/**
 * @ingroup RTEMSAPIBaseDefs
 *
 * @brief Instructs the compiler in a declaration to issue a warning whenever a
 *   variable, function, or type using this declaration will be used.
 */
#if defined(__GNUC__)
  #define RTEMS_DEPRECATED __attribute__(( __deprecated__ ))
#else
  #define RTEMS_DEPRECATED
#endif

/* Generated from spec:/rtems/basedefs/if/compiler-deprecated-attribute */

/**
 * @ingroup RTEMSAPIBaseDefs
 *
 * @brief Provided for backward compatibility.
 */
#define RTEMS_COMPILER_DEPRECATED_ATTRIBUTE RTEMS_DEPRECATED

/* Generated from spec:/rtems/basedefs/if/expand */

/**
 * @ingroup RTEMSAPIBaseDefs
 *
 * @brief Helper macro to perform a macro expansion on the token.
 *
 * @param _token is the token to expand.
 */
#define RTEMS_EXPAND( _token ) _token

/* Generated from spec:/rtems/basedefs/if/section */

/**
 * @ingroup RTEMSAPIBaseDefs
 *
 * @brief Instructs the compiler to place the variable or function in the
 *   section.
 *
 * @param _section is the section name as a string.
 */
#if defined(__GNUC__)
  #define RTEMS_SECTION( _section ) __attribute__(( __section__( _section ) ))
#else
  #define RTEMS_SECTION( _section )
#endif

/* Generated from spec:/rtems/basedefs/if/string */

/**
 * @ingroup RTEMSAPIBaseDefs
 *
 * @brief Stringifies the arguments without expanding them.
 *
 * @param ... are the arguments to stringify.
 *
 * @return Returns the stringification of the arguments.  In case of several
 *   arguments a single string is returned not several.
 */
#define RTEMS_STRING( ... ) #__VA_ARGS__

/* Generated from spec:/rtems/basedefs/if/typeof-refx */

/**
 * @ingroup RTEMSAPIBaseDefs
 *
 * @brief Gets the pointer reference type.
 *
 * @param _level is the pointer indirection level expressed in *.
 *
 * @param _target is the reference target type.
 *
 * The reference type idea is based on libHX by Jan Engelhardt.
 *
 * @return Returns the type of a pointer reference of the specified level to
 *   the specified type.
 */
#if defined(__GNUC__)
  #define RTEMS_TYPEOF_REFX( _level, _target ) \
    __typeof__( _level( union { int _z; __typeof__( _target ) _x; } ){ 0 }._x )
#else
  #define RTEMS_TYPEOF_REFX( _level, _target )
#endif

/* Generated from spec:/rtems/basedefs/if/xconcat */

/**
 * @ingroup RTEMSAPIBaseDefs
 *
 * @brief Concatenates expansion of _x and expansion of _y.
 *
 * @param _x is expanded first and then used as the left hand side token of the
 *   concatenation.
 *
 * @param _y is expanded first and then used as the right hand side token of
 *   the concatenation.
 *
 * @return Returns the concatenation of the expansions of tokens _x and _y.
 */
#define RTEMS_XCONCAT( _x, _y ) RTEMS_CONCAT( _x, _y )

/* Generated from spec:/score/if/assert-unreachable */

/**
 * @brief Asserts that this program point is unreachable.
 */
#if defined(RTEMS_DEBUG)
  #define _Assert_Unreachable() _Assert( 0 )
#else
  #define _Assert_Unreachable() do { } while ( 0 )
#endif

#if !defined(ASM)
  /* Generated from spec:/score/if/dequalify-types-not-compatible */

  /**
   * @brief A not implemented function to trigger compile time errors with an
   *   error message.
   */
  #if defined(__GNUC__)
    __attribute__((__error__("RTEMS_DEQUALIFY() types differ not only by volatile and const"))) void *
    RTEMS_DEQUALIFY_types_not_compatible( void );
  #else
    void *RTEMS_DEQUALIFY_types_not_compatible( void );
  #endif
#endif

/* Generated from spec:/rtems/basedefs/if/dequalify-depthx */

/**
 * @ingroup RTEMSAPIBaseDefs
 *
 * @brief Performs a type cast which removes qualifiers without warnings to the
 *   type for the variable.
 *
 * @param _ptr_level is the pointer indirection level expressed in *.
 *
 * @param _type is the target type of the cast.
 *
 * @param _var is the variable.
 */
#if defined(__cplusplus)
  #define RTEMS_DEQUALIFY_DEPTHX( _ptr_level, _type, _var ) \
    ( const_cast<_type>( _var ) )
#elif defined(__GNUC__)
  #define RTEMS_DEQUALIFY_DEPTHX( _ptr_level, _type, _var ) \
    __builtin_choose_expr( __builtin_types_compatible_p( \
        RTEMS_TYPEOF_REFX( _ptr_level, _var ), \
        RTEMS_TYPEOF_REFX( _ptr_level, _type ) \
      ) || __builtin_types_compatible_p( _type, void * ), \
    (_type) ( _var ), \
    RTEMS_DEQUALIFY_types_not_compatible() )
#else
  #define RTEMS_DEQUALIFY_DEPTHX( _ptr_level, _type, _var ) \
    ( (_type) (uintptr_t) (const volatile void *)( _var ) )
#endif

/* Generated from spec:/rtems/basedefs/if/deconst */

/**
 * @ingroup RTEMSAPIBaseDefs
 *
 * @brief Performs a type cast which removes const qualifiers without warnings
 *   to the type for the pointer variable.
 *
 * @param _type is the target type of the cast.
 *
 * @param _var is the pointer variable.
 */
#define RTEMS_DECONST( _type, _var ) RTEMS_DEQUALIFY_DEPTHX( *, _type, _var )

/* Generated from spec:/rtems/basedefs/if/dequalify */

/**
 * @ingroup RTEMSAPIBaseDefs
 *
 * @brief Performs a type cast which removes all qualifiers without warnings to
 *   the type for the pointer variable.
 *
 * @param _type is the target type of the cast.
 *
 * @param _var is the pointer variable.
 */
#define RTEMS_DEQUALIFY( _type, _var ) RTEMS_DEQUALIFY_DEPTHX( *, _type, _var )

/* Generated from spec:/rtems/basedefs/if/devolatile */

/**
 * @ingroup RTEMSAPIBaseDefs
 *
 * @brief Performs a type cast which removes volatile qualifiers without
 *   warnings to the type for the pointer variable.
 *
 * @param _type is the target type of the cast.
 *
 * @param _var is the pointer variable.
 */
#define RTEMS_DEVOLATILE( _type, _var ) RTEMS_DEQUALIFY_DEPTHX( *, _type, _var )

#if !defined(FALSE)
  /* Generated from spec:/rtems/basedefs/if/false */

  /**
   * @ingroup RTEMSAPIBaseDefs
   *
   * @brief If FALSE is undefined, then FALSE is defined to 0.
   */
  #define FALSE 0
#endif

/* Generated from spec:/rtems/basedefs/if/have-member-same-type */

/**
 * @ingroup RTEMSAPIBaseDefs
 *
 * @brief Checks if members of two types have compatible types.
 *
 * @param _t_lhs is the left hand side type.
 *
 * @param _m_lhs is the left hand side member.
 *
 * @param _t_rhs is the right hand side type.
 *
 * @param _m_rhs is the right hand side member.
 *
 * @return Returns to true, if the members of two types have compatible types,
 *   otherwise false.
 */
#if defined(__GNUC__)
  #define RTEMS_HAVE_MEMBER_SAME_TYPE( _t_lhs, _m_lhs, _t_rhs, _m_rhs ) \
    __builtin_types_compatible_p( \
      __typeof__( ( (_t_lhs *) 0 )->_m_lhs ), \
      __typeof__( ( (_t_rhs *) 0 )->_m_rhs ) \
    )
#else
  #define RTEMS_HAVE_MEMBER_SAME_TYPE( _t_lhs, _m_lhs, _t_rhs, _m_rhs ) true
#endif

/* Generated from spec:/rtems/basedefs/if/inline-routine */

/**
 * @ingroup RTEMSAPIBaseDefs
 *
 * @brief Gives a hint to the compiler in a function declaration to inline this
 *   function.
 */
#if defined(__GNUC__)
  #define RTEMS_INLINE_ROUTINE static __inline__
#else
  #define RTEMS_INLINE_ROUTINE static inline
#endif

/* Generated from spec:/rtems/basedefs/if/malloclike */

/**
 * @ingroup RTEMSAPIBaseDefs
 *
 * @brief Tells the compiler in a declaration that this function is a memory
 *   allocation function similar to malloc().
 */
#if defined(__GNUC__)
  #define RTEMS_MALLOCLIKE __attribute__(( __malloc__ ))
#else
  #define RTEMS_MALLOCLIKE
#endif

/* Generated from spec:/rtems/basedefs/if/no-inline */

/**
 * @ingroup RTEMSAPIBaseDefs
 *
 * @brief Instructs the compiler in a function declaration to not inline this
 *   function.
 */
#if defined(__GNUC__)
  #define RTEMS_NO_INLINE __attribute__(( __noinline__ ))
#else
  #define RTEMS_NO_INLINE
#endif

/* Generated from spec:/rtems/basedefs/if/no-return */

/**
 * @ingroup RTEMSAPIBaseDefs
 *
 * @brief Tells the compiler in a function declaration that this function does
 *   not return.
 */
#if __cplusplus >= 201103L
  #define RTEMS_NO_RETURN [[noreturn]]
#elif __STDC_VERSION__ >= 201112L
  #define RTEMS_NO_RETURN _Noreturn
#elif defined(__GNUC__)
  #define RTEMS_NO_RETURN __attribute__(( __noreturn__ ))
#else
  #define RTEMS_NO_RETURN
#endif

/* Generated from spec:/rtems/basedefs/if/compiler-no-return-attribute */

/**
 * @ingroup RTEMSAPIBaseDefs
 *
 * @brief Provided for backward compatibility.
 */
#define RTEMS_COMPILER_NO_RETURN_ATTRIBUTE RTEMS_NO_RETURN

/* Generated from spec:/rtems/basedefs/if/noinit */

/**
 * @ingroup RTEMSAPIBaseDefs
 *
 * @brief Instructs the compiler to place the variable in a section which is
 *   not initialized.
 */
#define RTEMS_NOINIT RTEMS_SECTION( ".noinit" )

/* Generated from spec:/rtems/basedefs/if/obfuscate-variable */

/**
 * @ingroup RTEMSAPIBaseDefs
 *
 * @brief Obfuscates the variable so that the compiler cannot perform
 *   optimizations based on the variable value.
 *
 * @param _var is the variable to obfuscate.
 *
 * The variable must be simple enough to fit into a register.
 */
#if defined(__GNUC__)
  #define RTEMS_OBFUSCATE_VARIABLE( _var ) __asm__( "" : "+r" ( _var ) )
#else
  #define RTEMS_OBFUSCATE_VARIABLE( _var ) (void) ( _var )
#endif

/* Generated from spec:/rtems/basedefs/if/packed */

/**
 * @ingroup RTEMSAPIBaseDefs
 *
 * @brief Instructs the compiler in a type definition to place members of a
 *   structure or union so that the memory required is minimized.
 */
#if defined(__GNUC__)
  #define RTEMS_PACKED __attribute__(( __packed__ ))
#else
  #define RTEMS_PACKED
#endif

/* Generated from spec:/rtems/basedefs/if/compiler-packed-attribute */

/**
 * @ingroup RTEMSAPIBaseDefs
 *
 * @brief Provided for backward compatibility.
 */
#define RTEMS_COMPILER_PACKED_ATTRIBUTE RTEMS_PACKED

/* Generated from spec:/rtems/basedefs/if/predict-false */

/**
 * @ingroup RTEMSAPIBaseDefs
 *
 * @brief Evaluates the integral expression and tells the compiler that the
 *   predicted value is false (0).
 *
 * @param _exp is the integral expression.
 *
 * @return Returns the value of the integral expression and tells the compiler
 *   that the predicted value is false (0).
 */
#if defined(__GNUC__)
  #define RTEMS_PREDICT_FALSE( _exp ) __builtin_expect( ( _exp ), 0 )
#else
  #define RTEMS_PREDICT_FALSE( _exp ) ( _exp )
#endif

/* Generated from spec:/rtems/basedefs/if/predict-true */

/**
 * @ingroup RTEMSAPIBaseDefs
 *
 * @brief Evaluates the integral expression and tells the compiler that the
 *   predicted value is true (1).
 *
 * @param _exp is the integral expression.
 *
 * @return Returns the value of the integral expression and tells the compiler
 *   that the predicted value is true (1).
 */
#if defined(__GNUC__)
  #define RTEMS_PREDICT_TRUE( _exp ) __builtin_expect( ( _exp ), 1 )
#else
  #define RTEMS_PREDICT_TRUE( _exp ) ( _exp )
#endif

/* Generated from spec:/rtems/basedefs/if/printflike */

/**
 * @ingroup RTEMSAPIBaseDefs
 *
 * @brief Tells the compiler in a declaration that this function expects
 *   printf()-like arguments.
 *
 * @param _format_pos is the position of the format parameter index (starting
 *   with one).
 *
 * @param _ap_pos is the position of the argument pointer parameter index
 *   (starting with one).
 */
#if defined(__GNUC__)
  #define RTEMS_PRINTFLIKE( _format_pos, _ap_pos ) \
    __attribute__(( __format__( __printf__, _format_pos, _ap_pos ) ))
#else
  #define RTEMS_PRINTFLIKE( _format_pos, _ap_pos )
#endif

/* Generated from spec:/rtems/basedefs/if/pure */

/**
 * @ingroup RTEMSAPIBaseDefs
 *
 * @brief Tells the compiler in a function declaration that this function has
 *   no effect except the return value and that the return value depends only
 *   on the value of parameters and/or global variables.
 */
#if defined(__GNUC__)
  #define RTEMS_PURE __attribute__(( __pure__ ))
#else
  #define RTEMS_PURE
#endif

/* Generated from spec:/rtems/basedefs/if/compiler-pure-attribute */

/**
 * @ingroup RTEMSAPIBaseDefs
 *
 * @brief Provided for backward compatibility.
 */
#define RTEMS_COMPILER_PURE_ATTRIBUTE RTEMS_PURE

/* Generated from spec:/rtems/basedefs/if/return-address */

/**
 * @ingroup RTEMSAPIBaseDefs
 *
 * @brief Gets the return address of the current function.
 *
 * @return Returns the return address of the current function.
 */
#if defined(__GNUC__)
  #define RTEMS_RETURN_ADDRESS() __builtin_return_address( 0 )
#else
  #define RTEMS_RETURN_ADDRESS() NULL
#endif

/* Generated from spec:/rtems/basedefs/if/static-analysis */

/**
 * @ingroup RTEMSAPIBaseDefs
 *
 * @brief It is defined if a static analysis run is performed.
 */
#if defined(__COVERITY__)
  #define RTEMS_STATIC_ANALYSIS
#endif

/* Generated from spec:/rtems/basedefs/if/static-assert */

/**
 * @ingroup RTEMSAPIBaseDefs
 *
 * @brief Asserts at compile time that the condition is satisfied.
 *
 * @param _cond is the condition this static assertion shall satisfy.
 *
 * @param _msg is the error message in case the static assertion fails.
 */
#if __cplusplus >= 201103L
  #define RTEMS_STATIC_ASSERT( _cond, _msg ) static_assert( _cond, # _msg )
#elif __STDC_VERSION__ >= 201112L
  #define RTEMS_STATIC_ASSERT( _cond, _msg ) _Static_assert( _cond, # _msg )
#else
  #define RTEMS_STATIC_ASSERT( _cond, _msg ) \
    struct rtems_static_assert_ ## _msg \
      { int rtems_static_assert_ ## _msg : ( _cond ) ? 1 : -1; }
#endif

/* Generated from spec:/rtems/basedefs/if/symbol-name */

/**
 * @ingroup RTEMSAPIBaseDefs
 *
 * @brief Maps the name to the associated symbol name.
 *
 * @param _name is the user defined name of the symbol.  The name shall be a
 *   valid designator.  On the name a macro expansion is performed.
 *
 * @return Returns the symbol name associated with the name.
 */
#if defined(__USER_LABEL_PREFIX__)
  #define RTEMS_SYMBOL_NAME( _name ) RTEMS_XCONCAT( __USER_LABEL_PREFIX__, _name )
#else
  #define RTEMS_SYMBOL_NAME( _name ) RTEMS_EXPAND( _name )
#endif

#if !defined(TRUE)
  /* Generated from spec:/rtems/basedefs/if/true */

  /**
   * @ingroup RTEMSAPIBaseDefs
   *
   * @brief If TRUE is undefined, then TRUE is defined to 1.
   */
  #define TRUE 1
#endif

/* Generated from spec:/rtems/basedefs/if/unreachable */

/**
 * @ingroup RTEMSAPIBaseDefs
 *
 * @brief Tells the compiler that this program point is unreachable.
 */
#if defined(__GNUC__)
  #define RTEMS_UNREACHABLE() \
    do { \
      __builtin_unreachable(); \
      _Assert_Unreachable(); \
    } while ( 0 )
#else
  #define RTEMS_UNREACHABLE() _Assert_Unreachable()
#endif

/* Generated from spec:/rtems/basedefs/if/unused */

/**
 * @ingroup RTEMSAPIBaseDefs
 *
 * @brief Tells the compiler that the variable or function is deliberately
 *   unused.
 */
#if defined(__GNUC__)
  #define RTEMS_UNUSED __attribute__(( __unused__ ))
#else
  #define RTEMS_UNUSED
#endif

/* Generated from spec:/rtems/basedefs/if/compiler-unused-attribute */

/**
 * @ingroup RTEMSAPIBaseDefs
 *
 * @brief Provided for backward compatibility.
 */
#define RTEMS_COMPILER_UNUSED_ATTRIBUTE RTEMS_UNUSED

/* Generated from spec:/rtems/basedefs/if/used */

/**
 * @ingroup RTEMSAPIBaseDefs
 *
 * @brief Tells the compiler that the variable or function is used.
 */
#if defined(__GNUC__)
  #define RTEMS_USED __attribute__(( __used__ ))
#else
  #define RTEMS_USED
#endif

/* Generated from spec:/rtems/basedefs/if/warn-unused-result */

/**
 * @ingroup RTEMSAPIBaseDefs
 *
 * @brief Tells the compiler in a declaration that the result of this function
 *   should be used.
 */
#if defined(__GNUC__)
  #define RTEMS_WARN_UNUSED_RESULT __attribute__(( __warn_unused_result__ ))
#else
  #define RTEMS_WARN_UNUSED_RESULT
#endif

/* Generated from spec:/rtems/basedefs/if/weak */

/**
 * @ingroup RTEMSAPIBaseDefs
 *
 * @brief Tells the compiler in a function definition that this function should
 *   be weak.
 *
 * Use this attribute for function definitions.  Do not use it for function
 * declarations.
 */
#if defined(__GNUC__)
  #define RTEMS_WEAK __attribute__(( __weak__ ))
#else
  #define RTEMS_WEAK
#endif

/* Generated from spec:/rtems/basedefs/if/weak-alias */

/**
 * @ingroup RTEMSAPIBaseDefs
 *
 * @brief Instructs the compiler to generate a weak alias to the target
 *   function.
 *
 * @param _target is the target function name.
 */
#if defined(__GNUC__)
  #define RTEMS_WEAK_ALIAS( _target ) \
    __attribute__(( __weak__, __alias__( #_target ) ))
#else
  #define RTEMS_WEAK_ALIAS( _target )
#endif

/* Generated from spec:/rtems/basedefs/if/xstring */

/**
 * @ingroup RTEMSAPIBaseDefs
 *
 * @brief Stringifies the expansion of the arguments.
 *
 * @param ... are the arguments to expand and stringify.
 *
 * @return Returns the stringification of the expansion of the arguments.  In
 *   case of several arguments a single string is returned not several.
 */
#define RTEMS_XSTRING( ... ) RTEMS_STRING( __VA_ARGS__ )

/* Generated from spec:/rtems/basedefs/if/define-global-symbol */

/**
 * @ingroup RTEMSAPIBaseDefs
 *
 * @brief Defines a global symbol with the name and value.
 *
 * @param _name is the user defined name of the symbol.  The name shall be a
 *   valid designator.  On the name a macro expansion is performed and
 *   afterwards it is stringified.
 *
 * @param _value is the value of the symbol.  On the value a macro expansion is
 *   performed and afterwards it is stringified.  It shall expand to an integer
 *   expression understood by the assembler.
 *
 * This macro shall be placed at file scope.
 */
#if defined(__USER_LABEL_PREFIX__)
  #define RTEMS_DEFINE_GLOBAL_SYMBOL( _name, _value ) \
    __asm__( \
      "\t.globl " RTEMS_XSTRING( RTEMS_SYMBOL_NAME( _name ) ) \
      "\n\t.set " RTEMS_XSTRING( RTEMS_SYMBOL_NAME( _name ) ) \
      ", " RTEMS_STRING( _value ) "\n" \
    )
#else
  #define RTEMS_DEFINE_GLOBAL_SYMBOL( _name, _value )
#endif

/* Generated from spec:/rtems/basedefs/if/zero-length-array */

/**
 * @ingroup RTEMSAPIBaseDefs
 *
 * @brief This constant represents the element count of a zero-length array.
 *
 * Zero-length arrays are valid in C99 as flexible array members.  C++11 does
 * not allow flexible array members.  Use the GNU extension which is also
 * supported by other compilers.
 */
#if __STDC_VERSION__ >= 199409L
  #define RTEMS_ZERO_LENGTH_ARRAY
#else
  #define RTEMS_ZERO_LENGTH_ARRAY 0
#endif

#ifdef __cplusplus
}
#endif

#endif /* _RTEMS_SCORE_BASEDEFS_H */