From 866631c5258708c0806b00901ccecc204e1bdb70 Mon Sep 17 00:00:00 2001 From: Tobias Wooldridge Date: Mon, 8 Sep 2014 12:56:42 +0930 Subject: [PATCH] Fixes compile fatal error with section(command) on OS X, ifdef'd so fix doesn't break Ubuntu. Licensed under the BSD license. All rights/copyright granted to Serval Project Inc. --- commandline.h | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/commandline.h b/commandline.h index 7abab7b7..23024725 100644 --- a/commandline.h +++ b/commandline.h @@ -30,18 +30,28 @@ struct cli_schema; struct cli_context; +#ifdef __APPLE__ +#define SECTION(X) section("__DATA,__" X ) +#define SECTION_START(X) __asm("section$start$__DATA$__" X) +#define SECTION_END(X) __asm("section$end$__DATA$__" X) +#else +#define SECTION(X) section(X) +#define SECTION_START(X) +#define SECTION_END(X) +#endif + #define DEFINE_CMD(FUNC, FLAGS, HELP, WORD1, ...) \ static int FUNC(const struct cli_parsed *parsed, struct cli_context *context); \ struct cli_schema _APPEND2(FUNC, __LINE__) \ - __attribute__((used,aligned(sizeof(void *)),section("commands"))) = {\ + __attribute__((used,aligned(sizeof(void *)),SECTION("commands"))) = {\ .function = FUNC, \ .words = {WORD1, ##__VA_ARGS__, NULL}, \ .flags = FLAGS, \ .description = HELP\ } -extern struct cli_schema __start_commands[]; -extern struct cli_schema __stop_commands[]; +extern struct cli_schema __start_commands[] SECTION_START("commands"); +extern struct cli_schema __stop_commands[] SECTION_END("commands"); #define CMD_COUNT (__stop_commands - __start_commands)