Add strndupa to missing.h
diff --git a/configure.ac b/configure.ac
index 579d981..4040908 100644
--- a/configure.ac
+++ b/configure.ac
@@ -50,6 +50,9 @@
# 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 @@
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