summaryrefslogtreecommitdiffstats
path: root/shared
diff options
context:
space:
mode:
Diffstat (limited to 'shared')
-rw-r--r--shared/missing.h10
-rw-r--r--shared/util.c2
-rw-r--r--shared/util.h1
3 files changed, 12 insertions, 1 deletions
diff --git a/shared/missing.h b/shared/missing.h
index 2629444..7df6235 100644
--- a/shared/missing.h
+++ b/shared/missing.h
@@ -38,6 +38,7 @@ static inline int finit_module(int fd, const char *uargs, int flags)
#endif
#if !HAVE_DECL_STRNDUPA
+#include <string.h>
#define strndupa(s, n) \
({ \
const char *__old = (s); \
@@ -48,6 +49,15 @@ static inline int finit_module(int fd, const char *uargs, int flags)
})
#endif
+#if !HAVE_DECL_BASENAME
+#include <string.h>
+static inline const char *basename(const char *s)
+{
+ const char *p = strrchr(s, '/');
+ return p ? p + 1 : s;
+}
+#endif
+
#if !HAVE_DECL_BE32TOH
#include <endian.h>
#include <byteswap.h>
diff --git a/shared/util.c b/shared/util.c
index e2bab83..437bc69 100644
--- a/shared/util.c
+++ b/shared/util.c
@@ -172,7 +172,7 @@ char *modname_normalize(const char *modname, char buf[static PATH_MAX], size_t *
char *path_to_modname(const char *path, char buf[static PATH_MAX], size_t *len)
{
- char *modname;
+ const char *modname;
modname = basename(path);
if (modname == NULL || modname[0] == '\0')
diff --git a/shared/util.h b/shared/util.h
index c4a3916..2a377dd 100644
--- a/shared/util.h
+++ b/shared/util.h
@@ -5,6 +5,7 @@
#include <stdbool.h>
#include <stdlib.h>
#include <stdio.h>
+#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <time.h>