summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLucas De Marchi <lucas.demarchi@intel.com>2014-04-04 08:19:00 -0300
committerLucas De Marchi <lucas.demarchi@intel.com>2014-04-07 11:00:24 -0300
commit04c0956e207e3b27a700494f8dc77f902cd53731 (patch)
treefc817394054a5fe65797f4654bd53f725a10c51d
parent29bc329f550644aa034b1581fd1ccbb6ab787d4b (diff)
downloadkmod-04c0956e207e3b27a700494f8dc77f902cd53731.tar.gz
kmod-04c0956e207e3b27a700494f8dc77f902cd53731.tar.bz2
kmod-04c0956e207e3b27a700494f8dc77f902cd53731.zip
Add strndupa to missing.h
-rw-r--r--configure.ac3
-rw-r--r--libkmod/missing.h8
2 files changed, 11 insertions, 0 deletions
diff --git a/configure.ac b/configure.ac
index 579d981..4040908 100644
--- a/configure.ac
+++ b/configure.ac
@@ -50,6 +50,9 @@ 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>])
+# musl 1.0 and bionic 4.4 don't have strndupa
+AC_CHECK_DECLS_ONCE([strndupa])
+
# Check kernel headers
AC_CHECK_HEADERS_ONCE([linux/module.h])
diff --git a/libkmod/missing.h b/libkmod/missing.h
index b45bbe2..a286446 100644
--- a/libkmod/missing.h
+++ b/libkmod/missing.h
@@ -32,3 +32,11 @@ static inline int finit_module(int fd, const char *uargs, int flags)
return syscall(__NR_finit_module, fd, uargs, flags);
}
#endif
+
+#if !HAVE_DECL_STRNDUPA
+#define strndupa(s, length) \
+ ({ \
+ size_t __len = strnlen((s), (length)); \
+ strncpy(alloca(__len + 1), (s), __len); \
+ })
+#endif