summaryrefslogtreecommitdiffstats
path: root/lib/system.h
diff options
context:
space:
mode:
Diffstat (limited to 'lib/system.h')
-rw-r--r--lib/system.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/system.h b/lib/system.h
index 1c914efc..0db12d99 100644
--- a/lib/system.h
+++ b/lib/system.h
@@ -1,6 +1,7 @@
/* Declarations for common convenience functions.
Copyright (C) 2006-2011 Red Hat, Inc.
Copyright (C) 2022 Mark J. Wielaard <mark@klomp.org>
+ Copyright (C) 2023 Khem Raj.
This file is part of elfutils.
This file is free software; you can redistribute it and/or modify
@@ -211,4 +212,17 @@ extern char *__cxa_demangle (const char *mangled_name, char *output_buffer,
extern int never_defined_just_used_for_checking[(expr) ? 1 : -1] \
__attribute__ ((unused))
+/* We really want a basename implementation that doesn't modify the
+ input argument. Normally you get that from string.h with _GNU_SOURCE
+ define. But some libc implementations don't define it and other
+ define it, but provide an implementation that still modifies the
+ argument. So define our own and poison a bare basename symbol. */
+static inline const char *
+xbasename(const char *s)
+{
+ const char *p = strrchr(s, '/');
+ return p ? p+1 : s;
+}
+#pragma GCC poison basename
+
#endif /* system.h */