From: Rick L Bird Date: Sun, 17 Apr 2011 18:28:09 +0000 (-0400) Subject: This gets us through some of the ISO C compliance for our POSIX C X-Git-Url: https://git.theari.com/?a=commitdiff_plain;h=09ef3f4180ccf93654b485deb709b4d2db838760;p=cobramush.git This gets us through some of the ISO C compliance for our POSIX C compliance use with the module code. This refs issues #238 and #3 --- diff --git a/hdrs/modules.h b/hdrs/modules.h index 86687f4..dec1450 100644 --- a/hdrs/modules.h +++ b/hdrs/modules.h @@ -19,6 +19,7 @@ int module_open(char *path, char *name); int module_close(struct module_entry_t *m); int modules_shutdown(void); +extern void *utility_memcpy_ptr; /* This gets us through the ISO C warnings about our POSIX compliance macros */ /* Iterate through Module List */ #define MODULE_ITER(m) for(m = module_list ; m != NULL ; m = m->next) @@ -28,15 +29,19 @@ int modules_shutdown(void); /* Retrieve Module Function */ /* This Macro can only be used for non-returning calls */ #define MODULE_FUNC(h, m, func, ...) \ - if((h = (void (*)()) lt_dlsym(m, func))) { \ + utility_memcpy_ptr = lt_dlsym(m, func); \ + memcpy(&h, &utility_memcpy_ptr, sizeof(utility_memcpy_ptr)); \ + if(h) { \ h(__VA_ARGS__); \ } + #define MODULE_FUNC_NOARGS(h, m, func) \ - if((h = (void (*)()) lt_dlsym(m, func))) { \ + utility_memcpy_ptr = lt_dlsym(m, func); \ + memcpy(&h, &utility_memcpy_ptr, sizeof(utility_memcpy_ptr)); \ + if(h) { \ h(); \ } #define MODULE_FUNCRET(m, func) lt_dlsym(m, func); - #endif /* _MODULES_H_ */ diff --git a/src/modules.c b/src/modules.c index 070ace5..688dea4 100644 --- a/src/modules.c +++ b/src/modules.c @@ -20,6 +20,9 @@ struct module_entry_t *module_list = NULL; +/* Utility power for my macros... This gets us through the ISO C warnings about our posix compliance issues.. */ +void *utility_memcpy_ptr; + /* Ads a module entry and returns */ struct module_entry_t *module_entry_add(char *name) { struct module_entry_t *entry;