]> git.ipfire.org Git - thirdparty/kmod.git/commitdiff
libkmod: Move finit_module() definition to missing.h
authorLucas De Marchi <lucas.de.marchi@gmail.com>
Tue, 9 Apr 2013 07:16:57 +0000 (04:16 -0300)
committerLucas De Marchi <lucas.de.marchi@gmail.com>
Tue, 9 Apr 2013 07:38:27 +0000 (04:38 -0300)
Check for finit_module() and don't use our own static inline function if
there's such function in libc (or another lib).

In testsuite we need to unconditionally define HAVE_FINIT_MODULE because
we want to override this function, and never use the static inline one
in missing.h

configure.ac
libkmod/libkmod-module.c
libkmod/missing.h
testsuite/init_module.c

index 1c6c79327b7c5910d50b272849c6d3b1b941c74f..066515c400856bbc4f46f7a9f17fe515809de852 100644 (file)
@@ -40,6 +40,7 @@ PKG_PROG_PKG_CONFIG
 
 AC_CHECK_FUNCS_ONCE(__xstat)
 AC_CHECK_FUNCS_ONCE([__secure_getenv secure_getenv])
+AC_CHECK_FUNCS_ONCE([finit_module])
 
 # dietlibc doesn't have st.st_mtim struct member
 AC_CHECK_MEMBERS([struct stat.st_mtim], [], [], [#include <sys/stat.h>])
index f701d47bce47806b70cb1b7c446fd6ded1f6f45e..47d12adfd7a8a9fbaea214af3d3043b49ca59032 100644 (file)
@@ -768,14 +768,6 @@ KMOD_EXPORT int kmod_module_remove_module(struct kmod_module *mod,
 
 extern long init_module(const void *mem, unsigned long len, const char *args);
 
-#ifndef __NR_finit_module
-# define __NR_finit_module -1
-#endif
-static inline int finit_module(int fd, const char *uargs, int flags)
-{
-   return syscall(__NR_finit_module, fd, uargs, flags);
-}
-
 /**
  * kmod_module_insert_module:
  * @mod: kmod module
index 6ff754f9e7dd165b19232cb150ad8b6c20163b13..edb88b9fb3b62ee8b393d4b6deded107dcc3fa14 100644 (file)
@@ -1,5 +1,8 @@
 #pragma once
 
+#include <unistd.h>
+#include <sys/syscall.h>
+
 #ifdef HAVE_LINUX_MODULE_H
 #include <linux/module.h>
 #endif
 #ifndef MODULE_INIT_IGNORE_VERMAGIC
 # define MODULE_INIT_IGNORE_VERMAGIC 2
 #endif
+
+#ifndef __NR_finit_module
+# define __NR_finit_module -1
+#endif
+
+#ifndef HAVE_FINIT_MODULE
+static inline int finit_module(int fd, const char *uargs, int flags)
+{
+       return syscall(__NR_finit_module, fd, uargs, flags);
+}
+#endif
index ca9f84c7a32ef9113aae9638315787f30ff01f68..d60ca96b68db048012907c0e2dc744c3822a0414 100644 (file)
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
+#ifndef HAVE_FINIT_MODULE
+#define HAVE_FINIT_MODULE 1
+#endif
+
 #include <assert.h>
 #include <elf.h>
 #include <errno.h>