Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYaakov Selkowitz <yselkowi@redhat.com>2015-07-06 22:58:51 +0300
committerYaakov Selkowitz <yselkowi@redhat.com>2015-07-06 22:58:51 +0300
commit79e419de6261c4e04785908828096cb4d56b8680 (patch)
tree72f17165f0acb9ad42eb45c801acfd7624570c5c /newlib/libc
parentf9b87aaf109366342777521fe93fe9f795e8f1fa (diff)
Rework handling of basename variants
As a commonly-included header, the #define basename in <string.h> can affect code which uses "basename" for its own purposes (e.g. struct members or C++ namespaced functions). When such cases occur and some code includes <string.h> and some not, then errors result. OTOH, <libgen.h> is rarely used, and that's where the renaming occurs in glibc, so code using <libgen.h> should already be safe. * libc/include/libgen.h (basename): Define as __xpg_basename for source compatibility with glibc. Declare with __ASMNAME("basename") for ABI compatibility. * libc/include/string.h (basename): Define as basename for source compatibility with glibc. Declare with __ASMNAME("__gnu_basename") for ABI compatibility.
Diffstat (limited to 'newlib/libc')
-rw-r--r--newlib/libc/include/libgen.h5
-rw-r--r--newlib/libc/include/string.h4
2 files changed, 5 insertions, 4 deletions
diff --git a/newlib/libc/include/libgen.h b/newlib/libc/include/libgen.h
index de70b5b2f..3c717c5b0 100644
--- a/newlib/libc/include/libgen.h
+++ b/newlib/libc/include/libgen.h
@@ -6,6 +6,7 @@
#define _LIBGEN_H_
#include "_ansi.h"
+#include <sys/cdefs.h>
#include <sys/reent.h>
#ifdef __cplusplus
@@ -24,8 +25,8 @@ extern "C" {
this also implies that the POSIX version is used in this case. That's made
sure here. */
#undef basename
-#define basename basename
-char *_EXFUN(basename, (char *));
+#define basename __xpg_basename
+char *_EXFUN(basename, (char *)) __asm__(__ASMNAME("basename"));
char *_EXFUN(dirname, (char *));
#ifdef __cplusplus
diff --git a/newlib/libc/include/string.h b/newlib/libc/include/string.h
index 92e08aebc..84dd6b0ce 100644
--- a/newlib/libc/include/string.h
+++ b/newlib/libc/include/string.h
@@ -175,8 +175,8 @@ int _EXFUN(strtosigno, (const char *__name));
this also implies that the POSIX version is used in this case. That's made
sure here. */
#if __GNU_VISIBLE && !defined(basename)
-char *_EXFUN(__nonnull (1) __gnu_basename,(const char *));
-# define basename __gnu_basename
+# define basename basename
+char *_EXFUN(__nonnull (1) basename,(const char *)) __asm__(__ASMNAME("__gnu_basename"));
#endif
#include <sys/string.h>