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.
This commit is contained in:
parent
f9b87aaf10
commit
79e419de62
|
@ -1,3 +1,12 @@
|
|||
2015-07-06 Yaakov Selkowitz <yselkowi@redhat.com>
|
||||
|
||||
* 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 <corinna@vinschen.de>
|
||||
|
||||
* libc/include/sys/time.h: Explicitely include sys/cdefs.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
|
||||
|
|
|
@ -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>
|
||||
|
|
Loading…
Reference in New Issue