From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14439 invoked by alias); 6 Jul 2015 19:59:51 -0000 Mailing-List: contact newlib-cvs-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: newlib-cvs-owner@sourceware.org Received: (qmail 14379 invoked by uid 9642); 6 Jul 2015 19:59:51 -0000 Date: Mon, 06 Jul 2015 19:59:00 -0000 Message-ID: <20150706195951.14377.qmail@sourceware.org> Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Yaakov Selkowitz To: newlib-cvs@sourceware.org Subject: [newlib-cygwin] Rework handling of basename variants X-Act-Checkin: newlib-cygwin X-Git-Author: Yaakov Selkowitz X-Git-Refname: refs/heads/master X-Git-Oldrev: f9b87aaf109366342777521fe93fe9f795e8f1fa X-Git-Newrev: 79e419de6261c4e04785908828096cb4d56b8680 X-SW-Source: 2015-q3/txt/msg00002.txt.bz2 https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=79e419de6261c4e04785908828096cb4d56b8680 commit 79e419de6261c4e04785908828096cb4d56b8680 Author: Yaakov Selkowitz Date: Mon Jul 6 14:58:51 2015 -0500 Rework handling of basename variants As a commonly-included header, the #define basename in 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 and some not, then errors result. OTOH, is rarely used, and that's where the renaming occurs in glibc, so code using 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. Diff: --- newlib/ChangeLog | 9 +++++++++ newlib/libc/include/libgen.h | 5 +++-- newlib/libc/include/string.h | 4 ++-- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/newlib/ChangeLog b/newlib/ChangeLog index 994f1ca..24a6c9c 100644 --- a/newlib/ChangeLog +++ b/newlib/ChangeLog @@ -1,3 +1,12 @@ +2015-07-06 Yaakov Selkowitz + + * 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. + 2015-07-06 Corinna Vinschen * libc/include/sys/time.h: Explicitely include sys/cdefs.h. diff --git a/newlib/libc/include/libgen.h b/newlib/libc/include/libgen.h index de70b5b..3c717c5 100644 --- a/newlib/libc/include/libgen.h +++ b/newlib/libc/include/libgen.h @@ -6,6 +6,7 @@ #define _LIBGEN_H_ #include "_ansi.h" +#include #include #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 92e08ae..84dd6b0 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