Generalize linker sets

Add ability to create linker sets for items with an arbitrary type.
This commit is contained in:
Sebastian Huber
2014-10-01 13:19:35 +02:00
parent 454d6825c0
commit 9cea6da780
2 changed files with 30 additions and 18 deletions

View File

@@ -51,25 +51,39 @@
static void const * const __set_##set##_sym_##sym \ static void const * const __set_##set##_sym_##sym \
__section("set_" #set) __used = &sym __section("set_" #set) __used = &sym
#else /* __rtems__ */ #else /* __rtems__ */
#define RTEMS_BSD_DEFINE_SET(set, ptype) \ #define RTEMS_BSD_DEFINE_SET(set, type) \
ptype * const __CONCAT(_bsd__start_set_,set)[0] \ type const __CONCAT(_bsd__start_set_,set)[0] \
__section(".rtemsroset.bsd." __STRING(set) ".begin") __used; \ __section(".rtemsroset.bsd." __STRING(set) ".begin") __used; \
ptype * const __CONCAT(_bsd__stop_set_,set)[0] \ type const __CONCAT(_bsd__stop_set_,set)[0] \
__section(".rtemsroset.bsd." __STRING(set) ".end") __used __section(".rtemsroset.bsd." __STRING(set) ".end") __used
#define __MAKE_SET(set, sym) \ #define RTEMS_BSD_DECLARE_SET(set, type) \
static const void * const __set_##set##_sym_##sym \ extern type const __CONCAT(_bsd__start_set_,set)[0]; \
__section(".rtemsroset.bsd." __STRING(set) ".content") __used = &sym extern type const __CONCAT(_bsd__stop_set_,set)[0]
#define RTEMS_BSD_DEFINE_RWSET(set, ptype) \ #define RTEMS_BSD_DEFINE_SET_ITEM(set, sym, type) \
ptype *__CONCAT(_bsd__start_set_,set)[0] \ static type const __set_##set##_sym_##sym \
__section(".rtemsroset.bsd." __STRING(set) ".content") __used
#define __MAKE_SET(set, sym) \
RTEMS_BSD_DEFINE_SET_ITEM(set, sym, const void *) = &sym
#define RTEMS_BSD_DEFINE_RWSET(set, type) \
type __CONCAT(_bsd__start_set_,set)[0] \
__section(".rtemsrwset.bsd." __STRING(set) ".begin") __used; \ __section(".rtemsrwset.bsd." __STRING(set) ".begin") __used; \
ptype *__CONCAT(_bsd__stop_set_,set)[0] \ type __CONCAT(_bsd__stop_set_,set)[0] \
__section(".rtemsrwset.bsd." __STRING(set) ".end") __used __section(".rtemsrwset.bsd." __STRING(set) ".end") __used
#define RTEMS_BSD_DECLARE_RWSET(set, type) \
extern type __CONCAT(_bsd__start_set_,set)[0]; \
extern type __CONCAT(_bsd__stop_set_,set)[0]
#define RTEMS_BSD_DEFINE_RWSET_ITEM(set, sym, type) \
static type __set_##set##_sym_##sym \
__section(".rtemsrwset.bsd." __STRING(set) ".content") __used
#define __MAKE_RWSET(set, sym) \ #define __MAKE_RWSET(set, sym) \
static const void * __set_##set##_sym_##sym \ RTEMS_BSD_DEFINE_RWSET_ITEM(set, sym, const void *) = &sym
__section(".rtemsrwset.bsd." __STRING(set) ".content") __used = &sym
#endif /* __rtems__ */ #endif /* __rtems__ */
#else /* !__GNUCLIKE___SECTION */ #else /* !__GNUCLIKE___SECTION */
#ifndef lint #ifndef lint
@@ -104,12 +118,10 @@
(&__CONCAT(__stop_set_,set)) (&__CONCAT(__stop_set_,set))
#else /* __rtems__ */ #else /* __rtems__ */
#define SET_DECLARE(set, ptype) \ #define SET_DECLARE(set, ptype) \
extern ptype * const __CONCAT(_bsd__start_set_,set)[]; \ RTEMS_BSD_DECLARE_SET(set, ptype *)
extern ptype * const __CONCAT(_bsd__stop_set_,set)[]
#define RWSET_DECLARE(set, ptype) \ #define RWSET_DECLARE(set, ptype) \
extern ptype *__CONCAT(_bsd__start_set_,set)[]; \ RTEMS_BSD_DECLARE_RWSET(set, ptype *)
extern ptype *__CONCAT(_bsd__stop_set_,set)[]
#define SET_BEGIN(set) \ #define SET_BEGIN(set) \
(__CONCAT(_bsd__start_set_,set)) (__CONCAT(_bsd__start_set_,set))

View File

@@ -58,10 +58,10 @@ SYSINIT_REFERENCE(linker_kernel);
SYSINIT_MODULE_REFERENCE(rootbus); SYSINIT_MODULE_REFERENCE(rootbus);
SYSINIT_DRIVER_REFERENCE(nexus, root); SYSINIT_DRIVER_REFERENCE(nexus, root);
RTEMS_BSD_DEFINE_SET(modmetadata_set, struct mod_metadata); RTEMS_BSD_DEFINE_SET(modmetadata_set, struct mod_metadata *);
RTEMS_BSD_DEFINE_SET(sysctl_set, struct sysctl_oid); RTEMS_BSD_DEFINE_SET(sysctl_set, struct sysctl_oid *);
RTEMS_BSD_DEFINE_RWSET(sysinit_set, struct sysinit); RTEMS_BSD_DEFINE_RWSET(sysinit_set, struct sysinit *);
/* In FreeBSD this is a local function */ /* In FreeBSD this is a local function */
void mi_startup(void); void mi_startup(void);