summaryrefslogtreecommitdiffstats
path: root/newlib/libc/include
diff options
context:
space:
mode:
Diffstat (limited to 'newlib/libc/include')
-rw-r--r--newlib/libc/include/libgen.h1
-rw-r--r--newlib/libc/include/string.h14
2 files changed, 15 insertions, 0 deletions
diff --git a/newlib/libc/include/libgen.h b/newlib/libc/include/libgen.h
index abfab0e5c..8360a22f9 100644
--- a/newlib/libc/include/libgen.h
+++ b/newlib/libc/include/libgen.h
@@ -13,6 +13,7 @@ extern "C" {
#endif
char *_EXFUN(basename, (char *));
+#define _BASENAME_DEFINED
char *_EXFUN(dirname, (char *));
#ifdef __cplusplus
diff --git a/newlib/libc/include/string.h b/newlib/libc/include/string.h
index 43b36267d..9e11e5c51 100644
--- a/newlib/libc/include/string.h
+++ b/newlib/libc/include/string.h
@@ -163,6 +163,20 @@ int _EXFUN(strtosigno, (const char *__name));
(char *) memcpy (__out, __in, __len-1);}))
#endif /* _GNU_SOURCE && __GNUC__ */
+/* There are two common basename variants. If you #include <libgen.h>
+ first, you get the POSIX version; otherwise you get the GNU version.
+ POSIX requires that #undef basename will still let you
+ invoke the underlying function, but that requires gcc support. */
+#if __GNU_VISIBLE && !defined(_BASENAME_DEFINED)
+# ifdef __GNUC__
+char *_EXFUN(basename,(const char *))
+ __asm__ (__ASMNAME ("__gnu_basename")) __nonnull(1);
+# else
+char *_EXFUN(__gnu_basename,(const char *));
+# define basename __gnu_basename
+# endif
+#endif
+
#include <sys/string.h>
_END_STD_C