summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorDavid Lamparter <equinox@opensourcerouting.org>2024-05-01 16:55:54 +0200
committerGitHub <noreply@github.com>2024-05-01 16:55:54 +0200
commit2130575b8cd19827d42ca7e9b3706d00e1452e6e (patch)
tree360f6525934434a029de44932eec30c4f9c0529b /lib
parentMerge pull request #15892 from donaldsharp/parse_attr_problems (diff)
parentlib: fix error on MacOS (diff)
downloadfrr-2130575b8cd19827d42ca7e9b3706d00e1452e6e.tar.xz
frr-2130575b8cd19827d42ca7e9b3706d00e1452e6e.zip
Merge pull request #15890 from httpstorm/frr-macOS-section.2024-04-30
Diffstat (limited to 'lib')
-rw-r--r--lib/compiler.h6
-rw-r--r--lib/memory.h27
2 files changed, 18 insertions, 15 deletions
diff --git a/lib/compiler.h b/lib/compiler.h
index 03261052a..9d39026c6 100644
--- a/lib/compiler.h
+++ b/lib/compiler.h
@@ -455,6 +455,12 @@ _Static_assert(sizeof(_uint64_t) == 8 && sizeof(_int64_t) == 8,
#define unlikely(_x) !!(_x)
#endif
+#ifdef __MACH__
+#define _DATA_SECTION(name) __attribute__((section("__DATA," name)))
+#else
+#define _DATA_SECTION(name) __attribute__((section(".data." name)))
+#endif
+
#ifdef __cplusplus
}
#endif
diff --git a/lib/memory.h b/lib/memory.h
index ba437ebd0..65b99a5fc 100644
--- a/lib/memory.h
+++ b/lib/memory.h
@@ -69,14 +69,12 @@ struct memgroup {
#define DECLARE_MGROUP(name) extern struct memgroup _mg_##name
#define _DEFINE_MGROUP(mname, desc, ...) \
- struct memgroup _mg_##mname \
- __attribute__((section(".data.mgroups"))) = { \
- .name = desc, \
- .types = NULL, \
- .next = NULL, \
- .insert = NULL, \
- .ref = NULL, \
- __VA_ARGS__ \
+ struct memgroup _mg_##mname _DATA_SECTION("mgroups") = { \
+ .name = desc, \
+ .types = NULL, \
+ .next = NULL, \
+ .insert = NULL, \
+ .ref = NULL, \
}; \
static void _mginit_##mname(void) __attribute__((_CONSTRUCTOR(1000))); \
static void _mginit_##mname(void) \
@@ -105,13 +103,12 @@ struct memgroup {
/* end */
#define DEFINE_MTYPE_ATTR(group, mname, attr, desc) \
- attr struct memtype MTYPE_##mname[1] \
- __attribute__((section(".data.mtypes"))) = { { \
- .name = desc, \
- .next = NULL, \
- .n_alloc = 0, \
- .size = 0, \
- .ref = NULL, \
+ attr struct memtype MTYPE_##mname[1] _DATA_SECTION("mtypes") = { { \
+ .name = desc, \
+ .next = NULL, \
+ .n_alloc = 0, \
+ .size = 0, \
+ .ref = NULL, \
} }; \
static void _mtinit_##mname(void) __attribute__((_CONSTRUCTOR(1001))); \
static void _mtinit_##mname(void) \