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

Last change on this file since c13fd2d was c13fd2d, checked in by Sebastian Huber <sebastian.huber@…>, on 11/20/20 at 07:10:06

score: Restore RTEMS_COMPILER_UNUSED_ATTRIBUTE

Commit 21af87199297460470578479293ec6bc8c4e04b2 accidentally removed the
RTEMS_COMPILER_UNUSED_ATTRIBUTE and added RTEMS_COMPILER_USED_ATTRIBUTE.

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