[rtems-libbsd commit] Simplify linker set handling
Sebastian Huber
sebh at rtems.org
Mon Dec 16 14:29:33 UTC 2013
Module: rtems-libbsd
Branch: master
Commit: 5084ad89e4690c1a375172c6a28c738530c5c4c2
Changeset: http://git.rtems.org/rtems-libbsd/commit/?id=5084ad89e4690c1a375172c6a28c738530c5c4c2
Author: Sebastian Huber <sebastian.huber at embedded-brains.de>
Date: Wed Dec 4 15:38:28 2013 +0100
Simplify linker set handling
---
freebsd/sys/kern/init_main.c | 4 ++--
freebsd/sys/sys/kernel.h | 2 +-
freebsd/sys/sys/linker_set.h | 31 +++++++++++++++++++++++++++----
rtemsbsd/rtems/rtems-bsd-init.c | 9 +++++++--
4 files changed, 37 insertions(+), 9 deletions(-)
diff --git a/freebsd/sys/kern/init_main.c b/freebsd/sys/kern/init_main.c
index 40fcacb..88f5f68 100644
--- a/freebsd/sys/kern/init_main.c
+++ b/freebsd/sys/kern/init_main.c
@@ -122,9 +122,7 @@ SYSINIT(placeholder, SI_SUB_DUMMY, SI_ORDER_ANY, NULL, NULL);
* The sysinit table itself. Items are checked off as the are run.
* If we want to register new sysinit types, add them to newsysinit.
*/
-#endif /* __rtems__ */
SET_DECLARE(sysinit_set, struct sysinit);
-#ifndef __rtems__
struct sysinit **sysinit, **sysinit_end;
struct sysinit **newsysinit, **newsysinit_end;
@@ -162,6 +160,8 @@ sysinit_add(struct sysinit **set, struct sysinit **set_end)
newsysinit = newset;
newsysinit_end = newset + count;
}
+#else /* __rtems__ */
+RWSET_DECLARE(sysinit_set, struct sysinit);
#endif /* __rtems__ */
#if defined (DDB) && defined(VERBOSE_SYSINIT)
diff --git a/freebsd/sys/sys/kernel.h b/freebsd/sys/sys/kernel.h
index e276f8e..c3e8302 100644
--- a/freebsd/sys/sys/kernel.h
+++ b/freebsd/sys/sys/kernel.h
@@ -255,7 +255,7 @@ struct sysinit {
func, \
(ident) \
}; \
- DATA_SET(sysinit_set,SYSINIT_ENTRY_NAME(uniquifier))
+ RWDATA_SET(sysinit_set,SYSINIT_ENTRY_NAME(uniquifier))
#define SYSINIT_REFERENCE(uniquifier) \
extern struct sysinit SYSINIT_ENTRY_NAME(uniquifier); \
static struct sysinit const * const \
diff --git a/freebsd/sys/sys/linker_set.h b/freebsd/sys/sys/linker_set.h
index b915302..4795781 100644
--- a/freebsd/sys/sys/linker_set.h
+++ b/freebsd/sys/sys/linker_set.h
@@ -51,9 +51,25 @@
static void const * const __set_##set##_sym_##sym \
__section("set_" #set) __used = &sym
#else /* __rtems__ */
+#define RTEMS_BSD_DEFINE_SET(set, ptype) \
+ ptype * const __CONCAT(_bsd__start_set_,set)[0] \
+ __section(".rtemsroset.bsd." __STRING(set) ".begin") __used; \
+ ptype * const __CONCAT(_bsd__stop_set_,set)[0] \
+ __section(".rtemsroset.bsd." __STRING(set) ".end") __used
+
#define __MAKE_SET(set, sym) \
- static void const * const __set_##set##_sym_##sym \
- __section("_bsd_set_" #set) __used = &sym
+ static const void * const __set_##set##_sym_##sym \
+ __section(".rtemsroset.bsd." __STRING(set) ".content") __used = &sym
+
+#define RTEMS_BSD_DEFINE_RWSET(set, ptype) \
+ ptype *__CONCAT(_bsd__start_set_,set)[0] \
+ __section(".rtemsrwset.bsd." __STRING(set) ".begin") __used; \
+ ptype *__CONCAT(_bsd__stop_set_,set)[0] \
+ __section(".rtemsrwset.bsd." __STRING(set) ".end") __used
+
+#define __MAKE_RWSET(set, sym) \
+ static const void * __set_##set##_sym_##sym \
+ __section(".rtemsrwset.bsd." __STRING(set) ".content") __used = &sym
#endif /* __rtems__ */
#else /* !__GNUCLIKE___SECTION */
#ifndef lint
@@ -70,6 +86,9 @@
#define BSS_SET(set, sym) __MAKE_SET(set, sym)
#define ABS_SET(set, sym) __MAKE_SET(set, sym)
#define SET_ENTRY(set, sym) __MAKE_SET(set, sym)
+#ifdef __rtems__
+#define RWDATA_SET(set, sym) __MAKE_RWSET(set, sym)
+#endif /* __rtems__ */
/*
* Initialize before referring to a given linker set.
@@ -85,8 +104,12 @@
(&__CONCAT(__stop_set_,set))
#else /* __rtems__ */
#define SET_DECLARE(set, ptype) \
- extern ptype *__CONCAT(_bsd__start_set_,set) []; \
- extern ptype *__CONCAT(_bsd__stop_set_,set) []
+ extern ptype * const __CONCAT(_bsd__start_set_,set)[]; \
+ extern ptype * const __CONCAT(_bsd__stop_set_,set)[]
+
+#define RWSET_DECLARE(set, ptype) \
+ extern ptype *__CONCAT(_bsd__start_set_,set)[]; \
+ extern ptype *__CONCAT(_bsd__stop_set_,set)[]
#define SET_BEGIN(set) \
(__CONCAT(_bsd__start_set_,set))
diff --git a/rtemsbsd/rtems/rtems-bsd-init.c b/rtemsbsd/rtems/rtems-bsd-init.c
index 613cab3..ed46265 100644
--- a/rtemsbsd/rtems/rtems-bsd-init.c
+++ b/rtemsbsd/rtems/rtems-bsd-init.c
@@ -7,10 +7,10 @@
*/
/*
- * Copyright (c) 2009, 2010 embedded brains GmbH. All rights reserved.
+ * Copyright (c) 2009-2013 embedded brains GmbH. All rights reserved.
*
* embedded brains GmbH
- * Obere Lagerstr. 30
+ * Dornierstr. 4
* 82178 Puchheim
* Germany
* <rtems at embedded-brains.de>
@@ -57,6 +57,11 @@ SYSINIT_REFERENCE(linker_kernel);
SYSINIT_MODULE_REFERENCE(rootbus);
SYSINIT_DRIVER_REFERENCE(nexus, root);
+RTEMS_BSD_DEFINE_SET(modmetadata_set, struct mod_metadata);
+RTEMS_BSD_DEFINE_SET(sysctl_set, struct sysctl_oid);
+
+RTEMS_BSD_DEFINE_RWSET(sysinit_set, struct sysinit);
+
/* In FreeBSD this is a local function */
void mi_startup(void);
More information about the vc
mailing list