diff options
| author | Paul Eggert | 2015-11-23 18:48:42 -0800 |
|---|---|---|
| committer | Paul Eggert | 2015-11-23 19:01:51 -0800 |
| commit | da8c7ca2647d2e111a415f59c6b59053a19bdb61 (patch) | |
| tree | 04dd13e37031bbee8b6ff6c0365db28b846c5a5c /src | |
| parent | ceaca7bec6adf5735d51c1ca7efea5a2e05f470e (diff) | |
| download | emacs-da8c7ca2647d2e111a415f59c6b59053a19bdb61.tar.gz emacs-da8c7ca2647d2e111a415f59c6b59053a19bdb61.zip | |
Port better to FreeBSD’s dlfunc vs dlsym
This avoids warnings when converting between void * and
function pointers, which strict C11 does not allow.
* configure.ac (dlfunc): Check for existence.
* src/dynlib.c (dlfunc) [!HAVE_DLFUNC]: New macro.
(dynlib_func): New function.
* src/dynlib.h (dynlib_function_ptr, dynlib_func): New decls.
* src/emacs-module.c (Fmodule_load): Use dynlib_func, not
dynlib_sym, for function pointers.
Diffstat (limited to 'src')
| -rw-r--r-- | src/dynlib.c | 10 | ||||
| -rw-r--r-- | src/dynlib.h | 2 | ||||
| -rw-r--r-- | src/emacs-module.c | 5 |
3 files changed, 15 insertions, 2 deletions
diff --git a/src/dynlib.c b/src/dynlib.c index 47ffb418140..a41bed847bb 100644 --- a/src/dynlib.c +++ b/src/dynlib.c | |||
| @@ -206,3 +206,13 @@ dynlib_close (dynlib_handle_ptr h) | |||
| 206 | #error "No dynamic loading for this system" | 206 | #error "No dynamic loading for this system" |
| 207 | 207 | ||
| 208 | #endif | 208 | #endif |
| 209 | |||
| 210 | #if !HAVE_DLFUNC | ||
| 211 | # define dlfunc dynlib_sym | ||
| 212 | #endif | ||
| 213 | |||
| 214 | dynlib_function_ptr | ||
| 215 | dynlib_func (dynlib_handle_ptr h, const char *sym) | ||
| 216 | { | ||
| 217 | return (dynlib_function_ptr) dlfunc (h, sym); | ||
| 218 | } | ||
diff --git a/src/dynlib.h b/src/dynlib.h index 1282c4fd719..1c19b5db8ac 100644 --- a/src/dynlib.h +++ b/src/dynlib.h | |||
| @@ -25,6 +25,8 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 25 | typedef void *dynlib_handle_ptr; | 25 | typedef void *dynlib_handle_ptr; |
| 26 | dynlib_handle_ptr dynlib_open (const char *path); | 26 | dynlib_handle_ptr dynlib_open (const char *path); |
| 27 | void *dynlib_sym (dynlib_handle_ptr h, const char *sym); | 27 | void *dynlib_sym (dynlib_handle_ptr h, const char *sym); |
| 28 | typedef struct dynlib_function_ptr_nonce *(*dynlib_function_ptr) (void); | ||
| 29 | dynlib_function_ptr dynlib_func (dynlib_handle_ptr h, const char *sym); | ||
| 28 | bool dynlib_addr (void *ptr, const char **path, const char **sym); | 30 | bool dynlib_addr (void *ptr, const char **path, const char **sym); |
| 29 | const char *dynlib_error (void); | 31 | const char *dynlib_error (void); |
| 30 | int dynlib_close (dynlib_handle_ptr h); | 32 | int dynlib_close (dynlib_handle_ptr h); |
diff --git a/src/emacs-module.c b/src/emacs-module.c index 1a5e253c969..209f99baf0f 100644 --- a/src/emacs-module.c +++ b/src/emacs-module.c | |||
| @@ -710,7 +710,7 @@ DEFUN ("module-load", Fmodule_load, Smodule_load, 1, 1, 0, | |||
| 710 | if (!gpl_sym) | 710 | if (!gpl_sym) |
| 711 | error ("Module %s is not GPL compatible", SDATA (file)); | 711 | error ("Module %s is not GPL compatible", SDATA (file)); |
| 712 | 712 | ||
| 713 | module_init = (emacs_init_function) dynlib_sym (handle, "emacs_module_init"); | 713 | module_init = (emacs_init_function) dynlib_func (handle, "emacs_module_init"); |
| 714 | if (!module_init) | 714 | if (!module_init) |
| 715 | error ("Module %s does not have an init function.", SDATA (file)); | 715 | error ("Module %s does not have an init function.", SDATA (file)); |
| 716 | 716 | ||
| @@ -937,7 +937,8 @@ allocate_emacs_value (emacs_env *env, struct emacs_value_storage *storage, | |||
| 937 | 937 | ||
| 938 | /* Mark all objects allocated from local environments so that they | 938 | /* Mark all objects allocated from local environments so that they |
| 939 | don't get garbage-collected. */ | 939 | don't get garbage-collected. */ |
| 940 | void mark_modules (void) | 940 | void |
| 941 | mark_modules (void) | ||
| 941 | { | 942 | { |
| 942 | for (Lisp_Object tem = Vmodule_environments; CONSP (tem); tem = XCDR (tem)) | 943 | for (Lisp_Object tem = Vmodule_environments; CONSP (tem); tem = XCDR (tem)) |
| 943 | { | 944 | { |