diff options
author | Lucas De Marchi <lucas.de.marchi@gmail.com> | 2013-04-09 04:16:57 -0300 |
---|---|---|
committer | Lucas De Marchi <lucas.de.marchi@gmail.com> | 2013-04-09 04:38:27 -0300 |
commit | 55112d19f7067dff89b1481d5bd8cc49139c4ecb (patch) | |
tree | 3e9ba480cbc0c22d4773d9e71a365ac403b1180d | |
parent | 1407064e730732dd20952671077007dd4133f7db (diff) | |
download | kmod-55112d19f7067dff89b1481d5bd8cc49139c4ecb.tar.gz |
libkmod: Move finit_module() definition to missing.h
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
-rw-r--r-- | configure.ac | 1 | ||||
-rw-r--r-- | libkmod/libkmod-module.c | 8 | ||||
-rw-r--r-- | libkmod/missing.h | 14 | ||||
-rw-r--r-- | testsuite/init_module.c | 4 |
4 files changed, 19 insertions, 8 deletions
diff --git a/configure.ac b/configure.ac index 1c6c793..066515c 100644 --- a/configure.ac +++ b/configure.ac @@ -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>]) diff --git a/libkmod/libkmod-module.c b/libkmod/libkmod-module.c index f701d47..47d12ad 100644 --- a/libkmod/libkmod-module.c +++ b/libkmod/libkmod-module.c @@ -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 diff --git a/libkmod/missing.h b/libkmod/missing.h index 6ff754f..edb88b9 100644 --- a/libkmod/missing.h +++ b/libkmod/missing.h @@ -1,5 +1,8 @@ #pragma once +#include <unistd.h> +#include <sys/syscall.h> + #ifdef HAVE_LINUX_MODULE_H #include <linux/module.h> #endif @@ -11,3 +14,14 @@ #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 diff --git a/testsuite/init_module.c b/testsuite/init_module.c index ca9f84c..d60ca96 100644 --- a/testsuite/init_module.c +++ b/testsuite/init_module.c @@ -16,6 +16,10 @@ * 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> |