![]() |
|
|||
File indexing completed on 2025-05-11 08:24:12
0001 /* SPDX-License-Identifier: BSD-2-Clause */ 0002 0003 /** 0004 * @file 0005 * 0006 * @ingroup RTEMSScore 0007 * 0008 * @brief This header file provides basic definitions used by the API and the 0009 * implementation. 0010 */ 0011 0012 /* 0013 * Copyright (C) 2014 Pavel Pisa 0014 * Copyright (C) 2011, 2013 On-Line Applications Research Corporation (OAR) 0015 * Copyright (C) 2009, 2023 embedded brains GmbH & Co. KG 0016 * 0017 * Redistribution and use in source and binary forms, with or without 0018 * modification, are permitted provided that the following conditions 0019 * are met: 0020 * 1. Redistributions of source code must retain the above copyright 0021 * notice, this list of conditions and the following disclaimer. 0022 * 2. Redistributions in binary form must reproduce the above copyright 0023 * notice, this list of conditions and the following disclaimer in the 0024 * documentation and/or other materials provided with the distribution. 0025 * 0026 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 0027 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 0028 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 0029 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 0030 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 0031 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 0032 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 0033 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 0034 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 0035 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 0036 * POSSIBILITY OF SUCH DAMAGE. 0037 */ 0038 0039 /* 0040 * This file is part of the RTEMS quality process and was automatically 0041 * generated. If you find something that needs to be fixed or 0042 * worded better please post a report or patch to an RTEMS mailing list 0043 * or raise a bug report: 0044 * 0045 * https://www.rtems.org/bugs.html 0046 * 0047 * For information on updating and regenerating please refer to the How-To 0048 * section in the Software Requirements Engineering chapter of the 0049 * RTEMS Software Engineering manual. The manual is provided as a part of 0050 * a release. For development sources please refer to the online 0051 * documentation at: 0052 * 0053 * https://docs.rtems.org 0054 */ 0055 0056 /* Generated from spec:/rtems/basedefs/if/header */ 0057 0058 #ifndef _RTEMS_SCORE_BASEDEFS_H 0059 #define _RTEMS_SCORE_BASEDEFS_H 0060 0061 #include <rtems/score/cpuopts.h> 0062 0063 #if !defined(ASM) 0064 #include <stdbool.h> 0065 #include <stddef.h> 0066 #include <stdint.h> 0067 #endif 0068 0069 #ifdef __cplusplus 0070 extern "C" { 0071 #endif 0072 0073 /* Generated from spec:/if/group */ 0074 0075 /** 0076 * @defgroup RTEMSAPI API 0077 * 0078 * @brief This group contains the RTEMS Application Programming Interface 0079 * (API). 0080 */ 0081 0082 /* Generated from spec:/rtems/basedefs/if/group */ 0083 0084 /** 0085 * @defgroup RTEMSAPIBaseDefs Base Definitions 0086 * 0087 * @ingroup RTEMSAPI 0088 * 0089 * @brief This group contains basic macros and defines to give access to 0090 * compiler-specific features. 0091 */ 0092 0093 /* Generated from spec:/rtems/basedefs/if/alias */ 0094 0095 /** 0096 * @ingroup RTEMSAPIBaseDefs 0097 * 0098 * @brief Instructs the compiler to generate an alias to the target function. 0099 * 0100 * @param _target is the target function name. 0101 */ 0102 #if defined(__GNUC__) 0103 #define RTEMS_ALIAS( _target ) __attribute__(( __alias__( #_target ) )) 0104 #else 0105 #define RTEMS_ALIAS( _target ) 0106 #endif 0107 0108 /* Generated from spec:/rtems/basedefs/if/align-down */ 0109 0110 /** 0111 * @ingroup RTEMSAPIBaseDefs 0112 * 0113 * @brief Aligns down the value to the alignment. 0114 * 0115 * @param _value is the value to align down. 0116 * 0117 * @param _alignment is the desired alignment in bytes. The alignment shall be 0118 * a power of two, otherwise the returned value is undefined. The alignment 0119 * parameter is evaluated twice. 0120 * 0121 * @return Returns the value aligned down to the alignment. 0122 */ 0123 #define RTEMS_ALIGN_DOWN( _value, _alignment ) \ 0124 ( ( _value ) & ~( ( _alignment ) - 1 ) ) 0125 0126 /* Generated from spec:/rtems/basedefs/if/align-up */ 0127 0128 /** 0129 * @ingroup RTEMSAPIBaseDefs 0130 * 0131 * @brief Aligns up the value to the alignment. 0132 * 0133 * @param _value is the value to align up. 0134 * 0135 * @param _alignment is the desired alignment in bytes. The alignment shall be 0136 * a power of two, otherwise the returned value is undefined. The alignment 0137 * parameter is evaluated twice. 0138 * 0139 * @return Returns the value aligned up to the alignment. 0140 */ 0141 #define RTEMS_ALIGN_UP( _value, _alignment ) \ 0142 ( ( ( _value ) + ( _alignment ) - 1 ) & ~( ( _alignment ) - 1 ) ) 0143 0144 /* Generated from spec:/rtems/basedefs/if/aligned */ 0145 0146 /** 0147 * @ingroup RTEMSAPIBaseDefs 0148 * 0149 * @brief Instructs the compiler in a declaration or definition to enforce the 0150 * alignment. 0151 * 0152 * @param _alignment is the desired alignment in bytes. 0153 */ 0154 #if defined(__GNUC__) 0155 #define RTEMS_ALIGNED( _alignment ) __attribute__(( __aligned__( _alignment ) )) 0156 #else 0157 #define RTEMS_ALIGNED( _alignment ) 0158 #endif 0159 0160 /* Generated from spec:/rtems/basedefs/if/alignof */ 0161 0162 /** 0163 * @ingroup RTEMSAPIBaseDefs 0164 * 0165 * @brief Gets the alignment requirement of the type. 0166 * 0167 * @param _type_name is the type name to get the alignment requirement for. 0168 * 0169 * @return Returns the alignment requirement of the type. 0170 */ 0171 #if defined( __cplusplus ) && __cplusplus >= 201103L 0172 #define RTEMS_ALIGNOF( _type_name ) alignof( _type_name ) 0173 #elif defined( __STDC_VERSION__ ) && __STDC_VERSION__ >= 201112L 0174 #define RTEMS_ALIGNOF( _type_name ) _Alignof( _type_name ) 0175 #else 0176 #define RTEMS_ALIGNOF( _type_name ) sizeof( _type_name ) 0177 #endif 0178 0179 /* Generated from spec:/rtems/basedefs/if/alloc-align */ 0180 0181 /** 0182 * @ingroup RTEMSAPIBaseDefs 0183 * 0184 * @brief Tells the compiler in a declaration that the memory allocation 0185 * alignment parameter of this function is similar to aligned_alloc(). 0186 * 0187 * @param _index is the allocation alignment parameter index (starting with 0188 * one). 0189 */ 0190 #if defined(__GNUC__) 0191 #define RTEMS_ALLOC_ALIGN( _index ) __attribute__(( __alloc_align__( _index ) )) 0192 #else 0193 #define RTEMS_ALLOC_ALIGN( _index ) 0194 #endif 0195 0196 /* Generated from spec:/rtems/basedefs/if/alloc-size */ 0197 0198 /** 0199 * @ingroup RTEMSAPIBaseDefs 0200 * 0201 * @brief Tells the compiler in a declaration that the memory allocation size 0202 * parameter of this function is similar to malloc(). 0203 * 0204 * @param _index is the allocation size parameter index (starting with one). 0205 */ 0206 #if defined(__GNUC__) 0207 #define RTEMS_ALLOC_SIZE( _index ) __attribute__(( __alloc_size__( _index ) )) 0208 #else 0209 #define RTEMS_ALLOC_SIZE( _index ) 0210 #endif 0211 0212 /* Generated from spec:/rtems/basedefs/if/alloc-size-2 */ 0213 0214 /** 0215 * @ingroup RTEMSAPIBaseDefs 0216 * 0217 * @brief Tells the compiler in a declaration that the memory allocation item 0218 * count and item size parameter of this function is similar to calloc(). 0219 * 0220 * @param _count_index is the allocation item count parameter index (starting 0221 * with one). 0222 * 0223 * @param _size_index is the allocation item size parameter index (starting 0224 * with one). 0225 */ 0226 #if defined(__GNUC__) 0227 #define RTEMS_ALLOC_SIZE_2( _count_index, _size_index ) \ 0228 __attribute__(( __alloc_size__( _count_index, _size_index ) )) 0229 #else 0230 #define RTEMS_ALLOC_SIZE_2( _count_index, _size_index ) 0231 #endif 0232 0233 /* Generated from spec:/rtems/basedefs/if/array-size */ 0234 0235 /** 0236 * @ingroup RTEMSAPIBaseDefs 0237 * 0238 * @brief Gets the element count of the array. 0239 * 0240 * @param _array is the name of the array. This parameter is evaluated twice. 0241 * 0242 * @return Returns the element count of the array. 0243 */ 0244 #define RTEMS_ARRAY_SIZE( _array ) \ 0245 ( sizeof( _array ) / sizeof( ( _array )[ 0 ] ) ) 0246 0247 /* Generated from spec:/rtems/basedefs/if/compiler-memory-barrier */ 0248 0249 /** 0250 * @ingroup RTEMSAPIBaseDefs 0251 * 0252 * @brief This macro forbids the compiler to reorder read and write commands 0253 * around it. 0254 */ 0255 #if defined(__GNUC__) 0256 #define RTEMS_COMPILER_MEMORY_BARRIER() __asm__ volatile( "" ::: "memory" ) 0257 #else 0258 #define RTEMS_COMPILER_MEMORY_BARRIER() do { } while ( 0 ) 0259 #endif 0260 0261 /* Generated from spec:/rtems/basedefs/if/concat */ 0262 0263 /** 0264 * @ingroup RTEMSAPIBaseDefs 0265 * 0266 * @brief Concatenates _x and _y without expanding. 0267 * 0268 * @param _x is the left hand side token of the concatenation. 0269 * 0270 * @param _y is the right hand side token of the concatenation. 0271 * 0272 * @return Returns the concatenation of the tokens _x and _y. 0273 */ 0274 #define RTEMS_CONCAT( _x, _y ) _x##_y 0275 0276 /* Generated from spec:/rtems/basedefs/if/const */ 0277 0278 /** 0279 * @ingroup RTEMSAPIBaseDefs 0280 * 0281 * @brief Tells the compiler in a function declaration that this function has 0282 * no effect except the return value and that the return value depends only 0283 * on the value of parameters. 0284 */ 0285 #if defined(__GNUC__) 0286 #define RTEMS_CONST __attribute__(( __const__ )) 0287 #else 0288 #define RTEMS_CONST 0289 #endif 0290 0291 /* Generated from spec:/rtems/basedefs/if/container-of */ 0292 0293 /** 0294 * @ingroup RTEMSAPIBaseDefs 0295 * 0296 * @brief Gets the container of a member. 0297 * 0298 * @param _m is the pointer to a member of the container. 0299 * 0300 * @param _type is the type of the container. 0301 * 0302 * @param _member_name is the designator name of the container member. 0303 * 0304 * @return Returns the pointer to the container of a member pointer. 0305 */ 0306 #define RTEMS_CONTAINER_OF( _m, _type, _member_name ) \ 0307 ( (_type *) ( (uintptr_t) ( _m ) - offsetof( _type, _member_name ) ) ) 0308 0309 /* Generated from spec:/rtems/basedefs/if/declare-global-symbol */ 0310 0311 /** 0312 * @ingroup RTEMSAPIBaseDefs 0313 * 0314 * @brief Declares a global symbol with the name. 0315 * 0316 * @param _name is the name of the global symbol. It shall be a valid 0317 * designator. 0318 * 0319 * This macro must be placed at file scope. 0320 */ 0321 #define RTEMS_DECLARE_GLOBAL_SYMBOL( _name ) extern char _name[] 0322 0323 /* Generated from spec:/rtems/basedefs/if/deprecated */ 0324 0325 /** 0326 * @ingroup RTEMSAPIBaseDefs 0327 * 0328 * @brief Instructs the compiler in a declaration to issue a warning whenever a 0329 * variable, function, or type using this declaration will be used. 0330 */ 0331 #if defined(__GNUC__) 0332 #define RTEMS_DEPRECATED __attribute__(( __deprecated__ )) 0333 #else 0334 #define RTEMS_DEPRECATED 0335 #endif 0336 0337 /* Generated from spec:/rtems/basedefs/if/compiler-deprecated-attribute */ 0338 0339 /** 0340 * @ingroup RTEMSAPIBaseDefs 0341 * 0342 * @brief Provided for backward compatibility. 0343 */ 0344 #define RTEMS_COMPILER_DEPRECATED_ATTRIBUTE RTEMS_DEPRECATED 0345 0346 /* Generated from spec:/rtems/basedefs/if/expand */ 0347 0348 /** 0349 * @ingroup RTEMSAPIBaseDefs 0350 * 0351 * @brief Helper macro to perform a macro expansion on the token. 0352 * 0353 * @param _token is the token to expand. 0354 */ 0355 #define RTEMS_EXPAND( _token ) _token 0356 0357 /* Generated from spec:/rtems/basedefs/if/function-name */ 0358 0359 /** 0360 * @ingroup RTEMSAPIBaseDefs 0361 * 0362 * @brief Expands to the name of the function containing the use of this 0363 * define. 0364 */ 0365 #if defined(__cplusplus) && defined(__GNUC__) 0366 #define RTEMS_FUNCTION_NAME __PRETTY_FUNCTION__ 0367 #else 0368 #define RTEMS_FUNCTION_NAME __func__ 0369 #endif 0370 0371 /* Generated from spec:/rtems/basedefs/if/no-return */ 0372 0373 /** 0374 * @ingroup RTEMSAPIBaseDefs 0375 * 0376 * @brief Tells the compiler in a function declaration that this function does 0377 * not return. 0378 */ 0379 #if defined( __cplusplus ) && __cplusplus >= 201103L 0380 #define RTEMS_NO_RETURN [[noreturn]] 0381 #elif defined( __STDC_VERSION__ ) && __STDC_VERSION__ >= 201112L 0382 #define RTEMS_NO_RETURN _Noreturn 0383 #elif defined(__GNUC__) 0384 #define RTEMS_NO_RETURN __attribute__(( __noreturn__ )) 0385 #else 0386 #define RTEMS_NO_RETURN 0387 #endif 0388 0389 /* Generated from spec:/rtems/basedefs/if/compiler-no-return-attribute */ 0390 0391 /** 0392 * @ingroup RTEMSAPIBaseDefs 0393 * 0394 * @brief Provided for backward compatibility. 0395 */ 0396 #define RTEMS_COMPILER_NO_RETURN_ATTRIBUTE RTEMS_NO_RETURN 0397 0398 /* Generated from spec:/rtems/basedefs/if/section */ 0399 0400 /** 0401 * @ingroup RTEMSAPIBaseDefs 0402 * 0403 * @brief Instructs the compiler to place the variable or function in the 0404 * section. 0405 * 0406 * @param _section is the section name as a string. 0407 */ 0408 #if defined(__GNUC__) 0409 #define RTEMS_SECTION( _section ) __attribute__(( __section__( _section ) )) 0410 #else 0411 #define RTEMS_SECTION( _section ) 0412 #endif 0413 0414 /* Generated from spec:/rtems/basedefs/if/string */ 0415 0416 /** 0417 * @ingroup RTEMSAPIBaseDefs 0418 * 0419 * @brief Stringifies the arguments without expanding them. 0420 * 0421 * @param ... are the arguments to stringify. 0422 * 0423 * @return Returns the stringification of the arguments. In case of several 0424 * arguments a single string is returned not several. 0425 */ 0426 #define RTEMS_STRING( ... ) #__VA_ARGS__ 0427 0428 /* Generated from spec:/rtems/basedefs/if/typeof-refx */ 0429 0430 /** 0431 * @ingroup RTEMSAPIBaseDefs 0432 * 0433 * @brief Gets the pointer reference type. 0434 * 0435 * @param _level is the pointer indirection level expressed in ``*``. 0436 * 0437 * @param _target is the reference target type. 0438 * 0439 * The reference type idea is based on libHX by Jan Engelhardt. 0440 * 0441 * @return Returns the type of a pointer reference of the specified level to 0442 * the specified type. 0443 */ 0444 #if defined(__GNUC__) 0445 #define RTEMS_TYPEOF_REFX( _level, _target ) \ 0446 __typeof__( _level( union { int _z; __typeof__( _target ) _x; } ){ 0 }._x ) 0447 #else 0448 #define RTEMS_TYPEOF_REFX( _level, _target ) 0449 #endif 0450 0451 /* Generated from spec:/rtems/basedefs/if/xconcat */ 0452 0453 /** 0454 * @ingroup RTEMSAPIBaseDefs 0455 * 0456 * @brief Concatenates expansion of _x and expansion of _y. 0457 * 0458 * @param _x is expanded first and then used as the left hand side token of the 0459 * concatenation. 0460 * 0461 * @param _y is expanded first and then used as the right hand side token of 0462 * the concatenation. 0463 * 0464 * @return Returns the concatenation of the expansions of tokens _x and _y. 0465 */ 0466 #define RTEMS_XCONCAT( _x, _y ) RTEMS_CONCAT( _x, _y ) 0467 0468 #if !defined(ASM) && defined(RTEMS_DEBUG) 0469 /* Generated from spec:/score/basedefs/if/debug-unreachable */ 0470 0471 /** 0472 * @ingroup RTEMSScore 0473 * 0474 * @brief Terminates the program with a failed assertion. 0475 * 0476 * @param file is the file name. 0477 * 0478 * @param line is the line of the file. 0479 * 0480 * @param func is the function name. 0481 */ 0482 RTEMS_NO_RETURN void _Debug_Unreachable( 0483 const char *file, 0484 int line, 0485 const char *func 0486 ); 0487 #endif 0488 0489 #if !defined(ASM) 0490 /* Generated from spec:/score/basedefs/if/dequalify-types-not-compatible */ 0491 0492 /** 0493 * @ingroup RTEMSScore 0494 * 0495 * @brief A not implemented function to trigger compile time errors with an 0496 * error message. 0497 */ 0498 #if defined(__GNUC__) 0499 __attribute__((__error__("RTEMS_DEQUALIFY() types differ not only by volatile and const"))) void * 0500 RTEMS_DEQUALIFY_types_not_compatible( void ); 0501 #else 0502 void *RTEMS_DEQUALIFY_types_not_compatible( void ); 0503 #endif 0504 #endif 0505 0506 /* Generated from spec:/rtems/basedefs/if/dequalify-depthx */ 0507 0508 /** 0509 * @ingroup RTEMSAPIBaseDefs 0510 * 0511 * @brief Performs a type cast which removes qualifiers without warnings to the 0512 * type for the variable. 0513 * 0514 * @param _ptr_level is the pointer indirection level expressed in ``*``. 0515 * 0516 * @param _type is the target type of the cast. 0517 * 0518 * @param _var is the variable. 0519 */ 0520 #if defined(__cplusplus) 0521 #define RTEMS_DEQUALIFY_DEPTHX( _ptr_level, _type, _var ) \ 0522 ( const_cast<_type>( _var ) ) 0523 #elif defined(__GNUC__) 0524 #define RTEMS_DEQUALIFY_DEPTHX( _ptr_level, _type, _var ) \ 0525 __builtin_choose_expr( \ 0526 __builtin_types_compatible_p( \ 0527 RTEMS_TYPEOF_REFX( _ptr_level, _var ), \ 0528 RTEMS_TYPEOF_REFX( _ptr_level, _type ) \ 0529 ) || \ 0530 __builtin_types_compatible_p( \ 0531 _type, \ 0532 void * \ 0533 ), \ 0534 (_type) ( _var ), \ 0535 RTEMS_DEQUALIFY_types_not_compatible() \ 0536 ) 0537 #else 0538 #define RTEMS_DEQUALIFY_DEPTHX( _ptr_level, _type, _var ) \ 0539 ( (_type) (uintptr_t) (const volatile void *)( _var ) ) 0540 #endif 0541 0542 /* Generated from spec:/rtems/basedefs/if/deconst */ 0543 0544 /** 0545 * @ingroup RTEMSAPIBaseDefs 0546 * 0547 * @brief Performs a type cast which removes const qualifiers without warnings 0548 * to the type for the pointer variable. 0549 * 0550 * @param _type is the target type of the cast. 0551 * 0552 * @param _var is the pointer variable. 0553 */ 0554 #define RTEMS_DECONST( _type, _var ) RTEMS_DEQUALIFY_DEPTHX( *, _type, _var ) 0555 0556 /* Generated from spec:/rtems/basedefs/if/dequalify */ 0557 0558 /** 0559 * @ingroup RTEMSAPIBaseDefs 0560 * 0561 * @brief Performs a type cast which removes all qualifiers without warnings to 0562 * the type for the pointer variable. 0563 * 0564 * @param _type is the target type of the cast. 0565 * 0566 * @param _var is the pointer variable. 0567 */ 0568 #define RTEMS_DEQUALIFY( _type, _var ) RTEMS_DEQUALIFY_DEPTHX( *, _type, _var ) 0569 0570 /* Generated from spec:/rtems/basedefs/if/devolatile */ 0571 0572 /** 0573 * @ingroup RTEMSAPIBaseDefs 0574 * 0575 * @brief Performs a type cast which removes volatile qualifiers without 0576 * warnings to the type for the pointer variable. 0577 * 0578 * @param _type is the target type of the cast. 0579 * 0580 * @param _var is the pointer variable. 0581 */ 0582 #define RTEMS_DEVOLATILE( _type, _var ) RTEMS_DEQUALIFY_DEPTHX( *, _type, _var ) 0583 0584 #if !defined(FALSE) 0585 /* Generated from spec:/rtems/basedefs/if/false */ 0586 0587 /** 0588 * @ingroup RTEMSAPIBaseDefs 0589 * 0590 * @brief If FALSE is undefined, then FALSE is defined to 0. 0591 */ 0592 #define FALSE 0 0593 #endif 0594 0595 /* Generated from spec:/rtems/basedefs/if/have-member-same-type */ 0596 0597 /** 0598 * @ingroup RTEMSAPIBaseDefs 0599 * 0600 * @brief Checks if members of two types have compatible types. 0601 * 0602 * @param _t_lhs is the left hand side type. 0603 * 0604 * @param _m_lhs is the left hand side member. 0605 * 0606 * @param _t_rhs is the right hand side type. 0607 * 0608 * @param _m_rhs is the right hand side member. 0609 * 0610 * @return Returns to true, if the members of two types have compatible types, 0611 * otherwise false. 0612 */ 0613 #if defined(__GNUC__) 0614 #define RTEMS_HAVE_MEMBER_SAME_TYPE( _t_lhs, _m_lhs, _t_rhs, _m_rhs ) \ 0615 __builtin_types_compatible_p( \ 0616 __typeof__( ( (_t_lhs *) 0 )->_m_lhs ), \ 0617 __typeof__( ( (_t_rhs *) 0 )->_m_rhs ) \ 0618 ) 0619 #else 0620 #define RTEMS_HAVE_MEMBER_SAME_TYPE( _t_lhs, _m_lhs, _t_rhs, _m_rhs ) true 0621 #endif 0622 0623 /* Generated from spec:/rtems/basedefs/if/inline-routine */ 0624 0625 /** 0626 * @ingroup RTEMSAPIBaseDefs 0627 * 0628 * @brief Gives a hint to the compiler in a function declaration to inline this 0629 * function. 0630 */ 0631 #if defined(__GNUC__) 0632 #define RTEMS_INLINE_ROUTINE static __inline__ 0633 #else 0634 #define RTEMS_INLINE_ROUTINE static inline 0635 #endif 0636 0637 /* Generated from spec:/rtems/basedefs/if/malloclike */ 0638 0639 /** 0640 * @ingroup RTEMSAPIBaseDefs 0641 * 0642 * @brief Tells the compiler in a declaration that this function is a memory 0643 * allocation function similar to malloc(). 0644 */ 0645 #if defined(__GNUC__) 0646 #define RTEMS_MALLOCLIKE __attribute__(( __malloc__ )) 0647 #else 0648 #define RTEMS_MALLOCLIKE 0649 #endif 0650 0651 /* Generated from spec:/rtems/basedefs/if/no-inline */ 0652 0653 /** 0654 * @ingroup RTEMSAPIBaseDefs 0655 * 0656 * @brief Instructs the compiler in a function declaration to not inline this 0657 * function. 0658 */ 0659 #if defined(__GNUC__) 0660 #define RTEMS_NO_INLINE __attribute__(( __noinline__ )) 0661 #else 0662 #define RTEMS_NO_INLINE 0663 #endif 0664 0665 /* Generated from spec:/rtems/basedefs/if/noinit */ 0666 0667 /** 0668 * @ingroup RTEMSAPIBaseDefs 0669 * 0670 * @brief Instructs the compiler to place the variable in a section which is 0671 * not initialized. 0672 */ 0673 #define RTEMS_NOINIT RTEMS_SECTION( ".noinit" ) 0674 0675 /* Generated from spec:/rtems/basedefs/if/obfuscate-variable */ 0676 0677 /** 0678 * @ingroup RTEMSAPIBaseDefs 0679 * 0680 * @brief Obfuscates the variable so that the compiler cannot perform 0681 * optimizations based on the variable value. 0682 * 0683 * @param _var is the variable to obfuscate. 0684 * 0685 * The variable must be simple enough to fit into a register. 0686 */ 0687 #if defined(__GNUC__) 0688 #define RTEMS_OBFUSCATE_VARIABLE( _var ) __asm__( "" : "+r" ( _var ) ) 0689 #else 0690 #define RTEMS_OBFUSCATE_VARIABLE( _var ) (void) ( _var ) 0691 #endif 0692 0693 /* Generated from spec:/rtems/basedefs/if/packed */ 0694 0695 /** 0696 * @ingroup RTEMSAPIBaseDefs 0697 * 0698 * @brief Instructs the compiler in a type definition to place members of a 0699 * structure or union so that the memory required is minimized. 0700 */ 0701 #if defined(__GNUC__) 0702 #define RTEMS_PACKED __attribute__(( __packed__ )) 0703 #else 0704 #define RTEMS_PACKED 0705 #endif 0706 0707 /* Generated from spec:/rtems/basedefs/if/compiler-packed-attribute */ 0708 0709 /** 0710 * @ingroup RTEMSAPIBaseDefs 0711 * 0712 * @brief Provided for backward compatibility. 0713 */ 0714 #define RTEMS_COMPILER_PACKED_ATTRIBUTE RTEMS_PACKED 0715 0716 /* Generated from spec:/rtems/basedefs/if/predict-false */ 0717 0718 /** 0719 * @ingroup RTEMSAPIBaseDefs 0720 * 0721 * @brief Evaluates the integral expression and tells the compiler that the 0722 * predicted value is false (0). 0723 * 0724 * @param _exp is the integral expression. 0725 * 0726 * @return Returns the value of the integral expression and tells the compiler 0727 * that the predicted value is false (0). 0728 */ 0729 #if defined(__GNUC__) 0730 #define RTEMS_PREDICT_FALSE( _exp ) __builtin_expect( ( _exp ), 0 ) 0731 #else 0732 #define RTEMS_PREDICT_FALSE( _exp ) ( _exp ) 0733 #endif 0734 0735 /* Generated from spec:/rtems/basedefs/if/predict-true */ 0736 0737 /** 0738 * @ingroup RTEMSAPIBaseDefs 0739 * 0740 * @brief Evaluates the integral expression and tells the compiler that the 0741 * predicted value is true (1). 0742 * 0743 * @param _exp is the integral expression. 0744 * 0745 * @return Returns the value of the integral expression and tells the compiler 0746 * that the predicted value is true (1). 0747 */ 0748 #if defined(__GNUC__) 0749 #define RTEMS_PREDICT_TRUE( _exp ) __builtin_expect( ( _exp ), 1 ) 0750 #else 0751 #define RTEMS_PREDICT_TRUE( _exp ) ( _exp ) 0752 #endif 0753 0754 /* Generated from spec:/rtems/basedefs/if/printflike */ 0755 0756 /** 0757 * @ingroup RTEMSAPIBaseDefs 0758 * 0759 * @brief Tells the compiler in a declaration that this function expects 0760 * printf()-like arguments. 0761 * 0762 * @param _format_pos is the position of the format parameter index (starting 0763 * with one). 0764 * 0765 * @param _ap_pos is the position of the argument pointer parameter index 0766 * (starting with one). 0767 */ 0768 #if defined(__GNUC__) 0769 #define RTEMS_PRINTFLIKE( _format_pos, _ap_pos ) \ 0770 __attribute__(( __format__( __printf__, _format_pos, _ap_pos ) )) 0771 #else 0772 #define RTEMS_PRINTFLIKE( _format_pos, _ap_pos ) 0773 #endif 0774 0775 /* Generated from spec:/rtems/basedefs/if/pure */ 0776 0777 /** 0778 * @ingroup RTEMSAPIBaseDefs 0779 * 0780 * @brief Tells the compiler in a function declaration that this function has 0781 * no effect except the return value and that the return value depends only 0782 * on the value of parameters and/or global variables. 0783 */ 0784 #if defined(__GNUC__) 0785 #define RTEMS_PURE __attribute__(( __pure__ )) 0786 #else 0787 #define RTEMS_PURE 0788 #endif 0789 0790 /* Generated from spec:/rtems/basedefs/if/compiler-pure-attribute */ 0791 0792 /** 0793 * @ingroup RTEMSAPIBaseDefs 0794 * 0795 * @brief Provided for backward compatibility. 0796 */ 0797 #define RTEMS_COMPILER_PURE_ATTRIBUTE RTEMS_PURE 0798 0799 /* Generated from spec:/rtems/basedefs/if/return-address */ 0800 0801 /** 0802 * @ingroup RTEMSAPIBaseDefs 0803 * 0804 * @brief Gets the return address of the current function. 0805 * 0806 * @return Returns the return address of the current function. 0807 */ 0808 #if defined(__GNUC__) 0809 #define RTEMS_RETURN_ADDRESS() __builtin_return_address( 0 ) 0810 #else 0811 #define RTEMS_RETURN_ADDRESS() NULL 0812 #endif 0813 0814 /* Generated from spec:/rtems/basedefs/if/static-analysis */ 0815 0816 /** 0817 * @ingroup RTEMSAPIBaseDefs 0818 * 0819 * @brief It is defined if a static analysis run is performed. 0820 */ 0821 #if defined(__COVERITY__) 0822 #define RTEMS_STATIC_ANALYSIS 0823 #endif 0824 0825 /* Generated from spec:/rtems/basedefs/if/static-assert */ 0826 0827 /** 0828 * @ingroup RTEMSAPIBaseDefs 0829 * 0830 * @brief Asserts at compile time that the condition is satisfied. 0831 * 0832 * @param _cond is the condition this static assertion shall satisfy. 0833 * 0834 * @param _msg is the error message in case the static assertion fails. 0835 */ 0836 #if defined( __cplusplus ) && __cplusplus >= 201103L 0837 #define RTEMS_STATIC_ASSERT( _cond, _msg ) static_assert( _cond, # _msg ) 0838 #elif defined( __STDC_VERSION__ ) && __STDC_VERSION__ >= 201112L 0839 #define RTEMS_STATIC_ASSERT( _cond, _msg ) _Static_assert( _cond, # _msg ) 0840 #else 0841 #define RTEMS_STATIC_ASSERT( _cond, _msg ) \ 0842 struct rtems_static_assert_ ## _msg \ 0843 { int rtems_static_assert_ ## _msg : ( _cond ) ? 1 : -1; } 0844 #endif 0845 0846 /* Generated from spec:/rtems/basedefs/if/symbol-name */ 0847 0848 /** 0849 * @ingroup RTEMSAPIBaseDefs 0850 * 0851 * @brief Maps the name to the associated symbol name. 0852 * 0853 * @param _name is the user defined name of the symbol. The name shall be a 0854 * valid designator. On the name a macro expansion is performed. 0855 * 0856 * @return Returns the symbol name associated with the name. 0857 */ 0858 #if defined(__USER_LABEL_PREFIX__) 0859 #define RTEMS_SYMBOL_NAME( _name ) RTEMS_XCONCAT( __USER_LABEL_PREFIX__, _name ) 0860 #else 0861 #define RTEMS_SYMBOL_NAME( _name ) RTEMS_EXPAND( _name ) 0862 #endif 0863 0864 #if !defined(TRUE) 0865 /* Generated from spec:/rtems/basedefs/if/true */ 0866 0867 /** 0868 * @ingroup RTEMSAPIBaseDefs 0869 * 0870 * @brief If TRUE is undefined, then TRUE is defined to 1. 0871 */ 0872 #define TRUE 1 0873 #endif 0874 0875 /* Generated from spec:/rtems/basedefs/if/unreachable */ 0876 0877 /** 0878 * @ingroup RTEMSAPIBaseDefs 0879 * 0880 * @brief Tells the compiler that this program point is unreachable. 0881 */ 0882 #if defined(RTEMS_DEBUG) 0883 #define RTEMS_UNREACHABLE() \ 0884 _Debug_Unreachable( __FILE__, __LINE__, RTEMS_FUNCTION_NAME ) 0885 #elif defined(__GNUC__) 0886 #define RTEMS_UNREACHABLE() __builtin_unreachable() 0887 #else 0888 #define RTEMS_UNREACHABLE() do { } while ( 0 ) 0889 #endif 0890 0891 /* Generated from spec:/rtems/basedefs/if/unused */ 0892 0893 /** 0894 * @ingroup RTEMSAPIBaseDefs 0895 * 0896 * @brief Tells the compiler that the variable or function is deliberately 0897 * unused. 0898 */ 0899 #if defined(__GNUC__) 0900 #define RTEMS_UNUSED __attribute__(( __unused__ )) 0901 #else 0902 #define RTEMS_UNUSED 0903 #endif 0904 0905 /* Generated from spec:/rtems/basedefs/if/compiler-unused-attribute */ 0906 0907 /** 0908 * @ingroup RTEMSAPIBaseDefs 0909 * 0910 * @brief Provided for backward compatibility. 0911 */ 0912 #define RTEMS_COMPILER_UNUSED_ATTRIBUTE RTEMS_UNUSED 0913 0914 /* Generated from spec:/rtems/basedefs/if/used */ 0915 0916 /** 0917 * @ingroup RTEMSAPIBaseDefs 0918 * 0919 * @brief Tells the compiler that the variable or function is used. 0920 */ 0921 #if defined(__GNUC__) 0922 #define RTEMS_USED __attribute__(( __used__ )) 0923 #else 0924 #define RTEMS_USED 0925 #endif 0926 0927 /* Generated from spec:/rtems/basedefs/if/warn-unused-result */ 0928 0929 /** 0930 * @ingroup RTEMSAPIBaseDefs 0931 * 0932 * @brief Tells the compiler in a declaration that the result of this function 0933 * should be used. 0934 */ 0935 #if defined(__GNUC__) 0936 #define RTEMS_WARN_UNUSED_RESULT __attribute__(( __warn_unused_result__ )) 0937 #else 0938 #define RTEMS_WARN_UNUSED_RESULT 0939 #endif 0940 0941 /* Generated from spec:/rtems/basedefs/if/weak */ 0942 0943 /** 0944 * @ingroup RTEMSAPIBaseDefs 0945 * 0946 * @brief Tells the compiler in a function definition that this function should 0947 * be weak. 0948 * 0949 * Use this attribute for function definitions. Do not use it for function 0950 * declarations. 0951 */ 0952 #if defined(__GNUC__) 0953 #define RTEMS_WEAK __attribute__(( __weak__ )) 0954 #else 0955 #define RTEMS_WEAK 0956 #endif 0957 0958 /* Generated from spec:/rtems/basedefs/if/weak-alias */ 0959 0960 /** 0961 * @ingroup RTEMSAPIBaseDefs 0962 * 0963 * @brief Instructs the compiler to generate a weak alias to the target 0964 * function. 0965 * 0966 * @param _target is the target function name. 0967 */ 0968 #if defined(__GNUC__) 0969 #define RTEMS_WEAK_ALIAS( _target ) \ 0970 __attribute__(( __weak__, __alias__( #_target ) )) 0971 #else 0972 #define RTEMS_WEAK_ALIAS( _target ) 0973 #endif 0974 0975 /* Generated from spec:/rtems/basedefs/if/xstring */ 0976 0977 /** 0978 * @ingroup RTEMSAPIBaseDefs 0979 * 0980 * @brief Stringifies the expansion of the arguments. 0981 * 0982 * @param ... are the arguments to expand and stringify. 0983 * 0984 * @return Returns the stringification of the expansion of the arguments. In 0985 * case of several arguments a single string is returned not several. 0986 */ 0987 #define RTEMS_XSTRING( ... ) RTEMS_STRING( __VA_ARGS__ ) 0988 0989 /* Generated from spec:/rtems/basedefs/if/define-global-symbol */ 0990 0991 /** 0992 * @ingroup RTEMSAPIBaseDefs 0993 * 0994 * @brief Defines a global symbol with the name and value. 0995 * 0996 * @param _name is the user defined name of the symbol. The name shall be a 0997 * valid designator. On the name a macro expansion is performed and 0998 * afterwards it is stringified. 0999 * 1000 * @param _value is the value of the symbol. On the value a macro expansion is 1001 * performed and afterwards it is stringified. It shall expand to an integer 1002 * expression understood by the assembler. The value shall be representable 1003 * in the code model of the target architecture. 1004 * 1005 * This macro shall be placed at file scope. 1006 */ 1007 #if defined(__GNUC__) 1008 #define RTEMS_DEFINE_GLOBAL_SYMBOL( _name, _value ) \ 1009 __asm__( \ 1010 "\t.globl " RTEMS_XSTRING( RTEMS_SYMBOL_NAME( _name ) ) \ 1011 "\n\t.set " RTEMS_XSTRING( RTEMS_SYMBOL_NAME( _name ) ) \ 1012 ", " RTEMS_STRING( _value ) "\n" \ 1013 ) 1014 #else 1015 #define RTEMS_DEFINE_GLOBAL_SYMBOL( _name, _value ) 1016 #endif 1017 1018 /* Generated from spec:/rtems/basedefs/if/zero-length-array */ 1019 1020 /** 1021 * @ingroup RTEMSAPIBaseDefs 1022 * 1023 * @brief This constant represents the element count of a zero-length array. 1024 * 1025 * Zero-length arrays are valid in C99 as flexible array members. C++11 does 1026 * not allow flexible array members. Use the GNU extension which is also 1027 * supported by other compilers. 1028 */ 1029 #if __STDC_VERSION__ >= 199409L 1030 #define RTEMS_ZERO_LENGTH_ARRAY 1031 #else 1032 #define RTEMS_ZERO_LENGTH_ARRAY 0 1033 #endif 1034 1035 #ifdef __cplusplus 1036 } 1037 #endif 1038 1039 #endif /* _RTEMS_SCORE_BASEDEFS_H */
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |