36#ifndef _RTEMS_LINKERSET_H
37#define _RTEMS_LINKERSET_H
55static inline uintptr_t _Linker_set_Obfuscate(
const void *ptr )
59 addr = (uintptr_t) ptr;
75#define RTEMS_LINKER_SET_BEGIN( set ) \
76 _Linker_set_##set##_begin
78#define RTEMS_LINKER_SET_END( set ) \
79 _Linker_set_##set##_end
86#define RTEMS_LINKER_SET_ALIGN( type ) \
87 RTEMS_ALIGNED( RTEMS_ALIGNOF( type ) )
89#define RTEMS_LINKER_ROSET_DECLARE( set, type ) \
90 extern RTEMS_LINKER_SET_ALIGN( type ) type \
91 const RTEMS_LINKER_SET_BEGIN( set )[]; \
92 extern RTEMS_LINKER_SET_ALIGN( type ) type \
93 const RTEMS_LINKER_SET_END( set )[]
95#define RTEMS_LINKER_ROSET( set, type ) \
96 RTEMS_LINKER_SET_ALIGN( type ) type const RTEMS_LINKER_SET_BEGIN( set )[ 0 ] \
97 RTEMS_SECTION( ".rtemsroset." #set ".begin" ) RTEMS_USED; \
98 RTEMS_LINKER_SET_ALIGN( type ) type const RTEMS_LINKER_SET_END( set )[ 0 ] \
99 RTEMS_SECTION( ".rtemsroset." #set ".end" ) RTEMS_USED
101#define RTEMS_LINKER_ROSET_ITEM_ORDERED_DECLARE( set, type, item, order ) \
102 extern RTEMS_LINKER_SET_ALIGN( type ) type const _Linker_set_##set##_##item \
103 RTEMS_SECTION( ".rtemsroset." #set ".content.0." RTEMS_XSTRING( order ) )
105#define RTEMS_LINKER_ROSET_ITEM_DECLARE( set, type, item ) \
106 extern RTEMS_LINKER_SET_ALIGN( type ) type const _Linker_set_##set##_##item \
107 RTEMS_SECTION( ".rtemsroset." #set ".content.1" )
109#define RTEMS_LINKER_ROSET_ITEM_REFERENCE( set, type, item ) \
110 static RTEMS_LINKER_SET_ALIGN( type ) type \
111 const * const _Set_reference_##set##_##item \
112 RTEMS_SECTION( ".rtemsroset.reference" ) RTEMS_USED = \
113 &_Linker_set_##set##_##item
115#define RTEMS_LINKER_ROSET_ITEM_ORDERED( set, type, item, order ) \
116 RTEMS_LINKER_SET_ALIGN( type ) type const _Linker_set_##set##_##item \
117 RTEMS_SECTION( ".rtemsroset." #set ".content.0." RTEMS_XSTRING( order ) ) \
120#define RTEMS_LINKER_ROSET_ITEM( set, type, item ) \
121 RTEMS_LINKER_SET_ALIGN( type ) type const _Linker_set_##set##_##item \
122 RTEMS_SECTION( ".rtemsroset." #set ".content.1" ) RTEMS_USED
124#define RTEMS_LINKER_ROSET_CONTENT( set, decl ) \
126 RTEMS_SECTION( ".rtemsroset." #set ".content" )
128#define RTEMS_LINKER_RWSET_DECLARE( set, type ) \
129 extern RTEMS_LINKER_SET_ALIGN( type ) type RTEMS_LINKER_SET_BEGIN( set )[]; \
130 extern RTEMS_LINKER_SET_ALIGN( type ) type RTEMS_LINKER_SET_END( set )[]
132#define RTEMS_LINKER_RWSET( set, type ) \
133 RTEMS_LINKER_SET_ALIGN( type ) type RTEMS_LINKER_SET_BEGIN( set )[ 0 ] \
134 RTEMS_SECTION( ".rtemsrwset." #set ".begin" ) RTEMS_USED; \
135 RTEMS_LINKER_SET_ALIGN( type ) type RTEMS_LINKER_SET_END( set )[ 0 ] \
136 RTEMS_SECTION( ".rtemsrwset." #set ".end" ) RTEMS_USED
138#define RTEMS_LINKER_RWSET_ITEM_ORDERED_DECLARE( set, type, item, order ) \
139 extern RTEMS_LINKER_SET_ALIGN( type ) type _Linker_set_##set##_##item \
140 RTEMS_SECTION( ".rtemsrwset." #set ".content.0." RTEMS_XSTRING( order ) )
142#define RTEMS_LINKER_RWSET_ITEM_DECLARE( set, type, item ) \
143 extern RTEMS_LINKER_SET_ALIGN( type ) type _Linker_set_##set##_##item \
144 RTEMS_SECTION( ".rtemsrwset." #set ".content.1" )
151#define RTEMS_LINKER_RWSET_ITEM_REFERENCE( set, type, item ) \
152 static RTEMS_LINKER_SET_ALIGN( type ) type \
153 * const _Set_reference_##set##_##item \
154 RTEMS_SECTION( ".rtemsroset.reference" ) RTEMS_USED = \
155 &_Linker_set_##set##_##item
157#define RTEMS_LINKER_RWSET_ITEM_ORDERED( set, type, item, order ) \
158 RTEMS_LINKER_SET_ALIGN( type ) type _Linker_set_##set##_##item \
159 RTEMS_SECTION( ".rtemsrwset." #set ".content.0." RTEMS_XSTRING( order ) ) \
162#define RTEMS_LINKER_RWSET_ITEM( set, type, item ) \
163 RTEMS_LINKER_SET_ALIGN( type ) type _Linker_set_##set##_##item \
164 RTEMS_SECTION( ".rtemsrwset." #set ".content.1" ) RTEMS_USED
166#define RTEMS_LINKER_RWSET_CONTENT( set, decl ) \
168 RTEMS_SECTION( ".rtemsrwset." #set ".content" )
170#define RTEMS_LINKER_SET_SIZE( set ) \
171 ( _Linker_set_Obfuscate( RTEMS_LINKER_SET_END( set ) ) \
172 - _Linker_set_Obfuscate( RTEMS_LINKER_SET_BEGIN( set ) ) )
174#define RTEMS_LINKER_SET_ITEM_COUNT( set ) \
175 ( RTEMS_LINKER_SET_SIZE( set ) \
176 / sizeof( RTEMS_LINKER_SET_BEGIN( set )[ 0 ] ) )
178#define RTEMS_LINKER_SET_IS_EMPTY( set ) \
179 ( RTEMS_LINKER_SET_SIZE( set ) == 0 )
181#define RTEMS_LINKER_SET_FOREACH( set, item ) \
183 item = (void *) _Linker_set_Obfuscate( RTEMS_LINKER_SET_BEGIN( set ) ) ; \
184 item != RTEMS_LINKER_SET_END( set ) ; \
This header file provides basic definitions used by the API and the implementation.
#define RTEMS_OBFUSCATE_VARIABLE(_var)
Obfuscates the variable so that the compiler cannot perform optimizations based on the variable value...
Definition: basedefs.h:690