From dab244d92ffd34c0afe1dee7fe749437f9465c96 Mon Sep 17 00:00:00 2001 From: gardners Date: Fri, 14 Aug 2015 13:53:37 +0930 Subject: [PATCH] shorten section names (and precursors) to keep in the 16 char limit of the O-MACH assembler on OSX. --- commandline.c | 2 +- commandline.h | 5 ++--- httpd.c | 2 +- rhizome.h | 2 +- rhizome_database.c | 4 ++-- section.h | 17 ++++++++++++----- trigger.h | 7 +++---- 7 files changed, 22 insertions(+), 17 deletions(-) diff --git a/commandline.c b/commandline.c index 6ff824f9..7a3c106b 100644 --- a/commandline.c +++ b/commandline.c @@ -237,7 +237,7 @@ int parseCommandLine(struct cli_context *context, const char *argv0, int argc, c IN(); struct cli_parsed parsed; - int result = cli_parse(argc, args, __start_commands, __stop_commands, &parsed); + int result = cli_parse(argc, args, SECTION_START(commands), SECTION_END(commands), &parsed); switch (result) { case 0: // Do not run the command if the configuration does not load ok. diff --git a/commandline.h b/commandline.h index 3c63dc0b..e6979987 100644 --- a/commandline.h +++ b/commandline.h @@ -41,10 +41,9 @@ struct cli_context; .description = HELP \ } -extern struct cli_schema __start_commands[] SECTION_START(commands); -extern struct cli_schema __stop_commands[] SECTION_STOP(commands); +DECLARE_SECTION(struct cli_schema, commands); -#define CMD_COUNT (__stop_commands - __start_commands) +#define CMD_COUNT (SECTION_START(commands) - SECTION_END(commands)) void cli_flush(struct cli_context *context); int cli_delim(struct cli_context *context, const char *opt); diff --git a/httpd.c b/httpd.c index f17ef157..2a0bccc1 100644 --- a/httpd.c +++ b/httpd.c @@ -341,7 +341,7 @@ static void trigger_rhizome_bundle_added(rhizome_manifest *m) } } -DEFINE_TRIGGER(rhizome_bundle_added, trigger_rhizome_bundle_added) +DEFINE_TRIGGER(bundle_add, trigger_rhizome_bundle_added) int is_http_header_complete(const char *buf, size_t len, size_t read_since_last_call) { diff --git a/rhizome.h b/rhizome.h index 4433a452..b7f927bb 100644 --- a/rhizome.h +++ b/rhizome.h @@ -925,6 +925,6 @@ DECLARE_ALARM(rhizome_fetch_status); /* Rhizome triggers */ -DECLARE_TRIGGER(rhizome_bundle_added, rhizome_manifest*) +DECLARE_TRIGGER(bundle_add, rhizome_manifest*) #endif //__SERVAL_DNA__RHIZOME_H diff --git a/rhizome_database.c b/rhizome_database.c index c53ec89d..3be42902 100644 --- a/rhizome_database.c +++ b/rhizome_database.c @@ -1351,7 +1351,7 @@ int rhizome_store_manifest(rhizome_manifest *m) alloca_tohex_rhizome_bid_t(m->cryptoSignPublic), m->version ); - CALL_TRIGGER(rhizome_bundle_added, m); + CALL_TRIGGER(bundle_add, m); monitor_announce_bundle(m); if (serverMode){ time_ms_t now = gettime_ms(); @@ -1376,7 +1376,7 @@ static void trigger_rhizome_bundle_added_debug(rhizome_manifest *m) ); } -DEFINE_TRIGGER(rhizome_bundle_added, trigger_rhizome_bundle_added_debug) +DEFINE_TRIGGER(bundle_add, trigger_rhizome_bundle_added_debug) /* The cursor struct must be zerofilled and the query parameters optionally filled in prior to * calling this function. diff --git a/section.h b/section.h index 723eb78b..eede5447 100644 --- a/section.h +++ b/section.h @@ -22,16 +22,23 @@ /* Macros for creating named linkage sections. */ +#define SECTION_START(X) __start_##X +#define SECTION_END(X) __stop_##X + #ifdef __APPLE__ -#define _SECTION_ATTRIBUTE(X) section("__DATA,__" #X ) -#define SECTION_START(X) __asm("section$start$__DATA$__" #X) -#define SECTION_STOP(X) __asm("section$end$__DATA$__" #X) + +#define _SECTION_ATTRIBUTE(X) section("__DATA,__"#X) +#define DECLARE_SECTION(TYPE, X) \ + extern TYPE SECTION_START(X)[] __asm("section$start$__DATA$__" #X);\ + extern TYPE SECTION_END(X)[] __asm("section$end$__DATA$__" #X) #else #define _SECTION_ATTRIBUTE(X) section(#X) -#define SECTION_START(X) -#define SECTION_STOP(X) +#define DECLARE_SECTION(TYPE, X) \ + extern TYPE SECTION_START(X)[];\ + extern TYPE SECTION_END(X)[] #endif + #define IN_SECTION(name) __attribute__((used,aligned(sizeof(void *)),_SECTION_ATTRIBUTE(name))) #endif // __SERVAL_DNA__SECTION_H diff --git a/trigger.h b/trigger.h index 8f70ef67..51247b0d 100644 --- a/trigger.h +++ b/trigger.h @@ -26,16 +26,15 @@ #define DECLARE_TRIGGER(TRIG, ...) \ typedef void TRIGGER_FUNC_##TRIG (__VA_ARGS__); \ - extern TRIGGER_FUNC_##TRIG *__start___trigger_section_##TRIG[] SECTION_START(trigger_##TRIG); \ - extern TRIGGER_FUNC_##TRIG *__stop___trigger_section_##TRIG[] SECTION_STOP(trigger_##TRIG); + DECLARE_SECTION(TRIGGER_FUNC_##TRIG *, tr_##TRIG); #define DEFINE_TRIGGER(TRIG, FUNC) \ - TRIGGER_FUNC_##TRIG * __trigger_##FUNC IN_SECTION(__trigger_section_##TRIG) = FUNC; + TRIGGER_FUNC_##TRIG * __trigger_##FUNC IN_SECTION(tr_##TRIG) = FUNC; #define CALL_TRIGGER(TRIG, ...) \ do { \ TRIGGER_FUNC_##TRIG **__trig; \ - for (__trig = __start___trigger_section_##TRIG; __trig < __stop___trigger_section_##TRIG; ++__trig) \ + for (__trig = SECTION_START(tr_##TRIG); __trig < SECTION_END(tr_##TRIG); ++__trig) \ (**__trig)(__VA_ARGS__); \ } while (0);