source: rtems/cpukit/include/rtems/score/basedefs.h @ 14bb077

Last change on this file since 14bb077 was 14bb077, checked in by Frank Kühndel <frank.kuehndel@…>, on 03/09/21 at 12:01:11

basedefs: Clarify RTEMS_STRING(), RTEMS_XSTRING()

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