diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2016-12-06 11:35:34 +0100 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2016-12-06 11:37:20 +0100 |
commit | 4b579c5f5170e1fb6a0573729444c289643b7d84 (patch) | |
tree | a6a05fc98d9193b216fb73a4bf4373603452210f /cpukit/score | |
parent | smplock01: Fix fairness plot script (diff) | |
download | rtems-4b579c5f5170e1fb6a0573729444c289643b7d84.tar.bz2 |
score: Simplify linker set API
Resurrect RTEMS_LINKER_SET_BEGIN() and RTEMS_LINKER_SET_END().
Add new macros RTEMS_LINKER_SET_ITEM_COUNT(),
RTEMS_LINKER_SET_IS_EMPTY(), and
RTEMS_LINKER_SET_FOREACH().
Remove confusing RTEMS_LINKER_SET_ASSIGN_BEGIN() and
RTEMS_LINKER_SET_ASSIGN_END().
Fix RTEMS_LINKER_SET_SIZE() to return the size in characters as
specified by the documentation.
Update #2408.
Update #2790.
Diffstat (limited to 'cpukit/score')
-rw-r--r-- | cpukit/score/include/rtems/linkersets.h | 63 |
1 files changed, 38 insertions, 25 deletions
diff --git a/cpukit/score/include/rtems/linkersets.h b/cpukit/score/include/rtems/linkersets.h index 390d2cba34..bad046999c 100644 --- a/cpukit/score/include/rtems/linkersets.h +++ b/cpukit/score/include/rtems/linkersets.h @@ -21,35 +21,20 @@ extern "C" { #endif /* __cplusplus */ -#define _LINKER_SET_BEGIN( set ) \ +#define RTEMS_LINKER_SET_BEGIN( set ) \ _Linker_set_##set##_begin -#define _LINKER_SET_END( set ) \ +#define RTEMS_LINKER_SET_END( set ) \ _Linker_set_##set##_end -#define RTEMS_LINKER_SET_ASSIGN_BEGIN( set, item ) \ - do { \ - item = _LINKER_SET_BEGIN( set ); \ - RTEMS_OBFUSCATE_VARIABLE( item ); \ - } while ( 0 ) - -#define RTEMS_LINKER_SET_ASSIGN_END( set, item ) \ - do { \ - item = _LINKER_SET_END( set ); \ - RTEMS_OBFUSCATE_VARIABLE( item ); \ - } while ( 0 ) - -#define RTEMS_LINKER_SET_SIZE( set ) \ - ( (size_t) ( _Linker_set_##set##_end - _Linker_set_##set##_begin ) ) - #define RTEMS_LINKER_ROSET_DECLARE( set, type ) \ - extern type const _LINKER_SET_BEGIN( set )[0]; \ - extern type const _LINKER_SET_END( set )[0] + extern type const RTEMS_LINKER_SET_BEGIN( set )[0]; \ + extern type const RTEMS_LINKER_SET_END( set )[0] #define RTEMS_LINKER_ROSET( set, type ) \ - type const _LINKER_SET_BEGIN( set )[0] \ + type const RTEMS_LINKER_SET_BEGIN( set )[0] \ RTEMS_SECTION( ".rtemsroset." #set ".begin" ) RTEMS_USED; \ - type const _LINKER_SET_END( set )[0] \ + type const RTEMS_LINKER_SET_END( set )[0] \ RTEMS_SECTION( ".rtemsroset." #set ".end" ) RTEMS_USED #define RTEMS_LINKER_ROSET_ITEM_DECLARE( set, type, item ) \ @@ -74,13 +59,13 @@ extern "C" { RTEMS_SECTION( ".rtemsroset." #set ".content" ) #define RTEMS_LINKER_RWSET_DECLARE( set, type ) \ - extern type _LINKER_SET_BEGIN( set )[0]; \ - extern type _LINKER_SET_END( set )[0] + extern type RTEMS_LINKER_SET_BEGIN( set )[0]; \ + extern type RTEMS_LINKER_SET_END( set )[0] #define RTEMS_LINKER_RWSET( set, type ) \ - type _LINKER_SET_BEGIN( set )[0] \ + type RTEMS_LINKER_SET_BEGIN( set )[0] \ RTEMS_SECTION( ".rtemsrwset." #set ".begin" ) RTEMS_USED; \ - type _LINKER_SET_END( set )[0] \ + type RTEMS_LINKER_SET_END( set )[0] \ RTEMS_SECTION( ".rtemsrwset." #set ".end" ) RTEMS_USED #define RTEMS_LINKER_RWSET_ITEM_DECLARE( set, type, item ) \ @@ -109,6 +94,34 @@ extern "C" { decl \ RTEMS_SECTION( ".rtemsrwset." #set ".content" ) +RTEMS_INLINE_ROUTINE uintptr_t _Linker_set_Obfuscate( const void *ptr ) +{ + uintptr_t addr; + + addr = (uintptr_t) ptr; + RTEMS_OBFUSCATE_VARIABLE( addr ); + + return addr; +} + +#define RTEMS_LINKER_SET_SIZE( set ) \ + ( _Linker_set_Obfuscate( RTEMS_LINKER_SET_END( set ) ) \ + - _Linker_set_Obfuscate( RTEMS_LINKER_SET_BEGIN( set ) ) ) + +#define RTEMS_LINKER_SET_ITEM_COUNT( set ) \ + ( RTEMS_LINKER_SET_SIZE( set ) \ + / sizeof( RTEMS_LINKER_SET_BEGIN( set )[ 0 ] ) ) + +#define RTEMS_LINKER_SET_IS_EMPTY( set ) \ + ( RTEMS_LINKER_SET_SIZE( set ) == 0 ) + +#define RTEMS_LINKER_SET_FOREACH( set, item ) \ + for ( \ + item = (void *) _Linker_set_Obfuscate( RTEMS_LINKER_SET_BEGIN( set ) ) ; \ + item != RTEMS_LINKER_SET_END( set ) ; \ + ++item \ + ) + #ifdef __cplusplus } #endif /* __cplusplus */ |