diff options
-rw-r--r-- | configure.ac | 3 | ||||
-rw-r--r-- | libkmod/missing.h | 8 |
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 |