]> code.delx.au - gnu-emacs/commitdiff
Port better to FreeBSD’s dlfunc vs dlsym
authorPaul Eggert <eggert@cs.ucla.edu>
Tue, 24 Nov 2015 02:48:42 +0000 (18:48 -0800)
committerPaul Eggert <eggert@cs.ucla.edu>
Tue, 24 Nov 2015 03:01:51 +0000 (19:01 -0800)
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.

configure.ac
src/dynlib.c
src/dynlib.h
src/emacs-module.c

index d5638bf20028ca46ef14b7666dc5fc86d3f4e332..b2fa1eddaffb9babda6b31ee99fcecde22766aba 100644 (file)
@@ -3316,6 +3316,11 @@ if test "${with_modules}" != "no"; then
 
   if test "${HAVE_MODULES}" = no; then
     AC_MSG_ERROR([Dynamic modules are not supported on your system])
+  else
+    SAVE_LIBS=$LIBS
+    LIBS="$LIBS $LIBMODULES"
+    AC_CHECK_FUNCS([dlfunc])
+    LIBS=$SAVE_LIBS
   fi
 fi
 
index 47ffb4181403c08d3159dcfe4553a8cc3b391911..a41bed847bb822221b068385169b416397857edb 100644 (file)
@@ -206,3 +206,13 @@ dynlib_close (dynlib_handle_ptr h)
 #error "No dynamic loading for this system"
 
 #endif
+
+#if !HAVE_DLFUNC
+# define dlfunc dynlib_sym
+#endif
+
+dynlib_function_ptr
+dynlib_func (dynlib_handle_ptr h, const char *sym)
+{
+  return (dynlib_function_ptr) dlfunc (h, sym);
+}
index 1282c4fd719147a1fa8b272c43374bc3a2184c8b..1c19b5db8acf7ed5dbd8a25dfdfb450a8592f406 100644 (file)
@@ -25,6 +25,8 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 typedef void *dynlib_handle_ptr;
 dynlib_handle_ptr dynlib_open (const char *path);
 void *dynlib_sym (dynlib_handle_ptr h, const char *sym);
+typedef struct dynlib_function_ptr_nonce *(*dynlib_function_ptr) (void);
+dynlib_function_ptr dynlib_func (dynlib_handle_ptr h, const char *sym);
 bool dynlib_addr (void *ptr, const char **path, const char **sym);
 const char *dynlib_error (void);
 int dynlib_close (dynlib_handle_ptr h);
index 1a5e253c969c0ba6a41b124e17c55b945bc0b304..209f99baf0ff3b36764783886c442c98b334fcad 100644 (file)
@@ -710,7 +710,7 @@ DEFUN ("module-load", Fmodule_load, Smodule_load, 1, 1, 0,
   if (!gpl_sym)
     error ("Module %s is not GPL compatible", SDATA (file));
 
-  module_init = (emacs_init_function) dynlib_sym (handle, "emacs_module_init");
+  module_init = (emacs_init_function) dynlib_func (handle, "emacs_module_init");
   if (!module_init)
     error ("Module %s does not have an init function.", SDATA (file));
 
@@ -937,7 +937,8 @@ allocate_emacs_value (emacs_env *env, struct emacs_value_storage *storage,
 
 /* Mark all objects allocated from local environments so that they
    don't get garbage-collected.  */
-void mark_modules (void)
+void
+mark_modules (void)
 {
   for (Lisp_Object tem = Vmodule_environments; CONSP (tem); tem = XCDR (tem))
     {