aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYaakov Selkowitz <yselkowi@redhat.com>2016-04-13 23:50:11 -0500
committerYaakov Selkowitz <yselkowi@redhat.com>2016-04-13 23:50:11 -0500
commit9f90ae04358fc3f78e1c561209cc7117309ddfd8 (patch)
treed2b17119d1da5a5ad585e47fa2ff1eab5d047887
parent7b391244009ebca831aa8f8dac82112a9daa9023 (diff)
downloadnewlib-9f90ae04358fc3f78e1c561209cc7117309ddfd8.zip
newlib-9f90ae04358fc3f78e1c561209cc7117309ddfd8.tar.gz
newlib-9f90ae04358fc3f78e1c561209cc7117309ddfd8.tar.bz2
Feature test macros overhaul: string.h and strings.h overlaps
strings.h is the header mandated for these functions in POSIX.1 prior to 2008 (when most of these were removed). The declarations in string.h are only for BSD compatibility. But when both headers are included, avoid duplicate declarations. Also, mark stpcpy and stpncpy as POSIX.1-2008. Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
-rw-r--r--newlib/libc/include/string.h14
-rw-r--r--newlib/libc/include/strings.h5
2 files changed, 12 insertions, 7 deletions
diff --git a/newlib/libc/include/string.h b/newlib/libc/include/string.h
index 68ee412..56c7fc2 100644
--- a/newlib/libc/include/string.h
+++ b/newlib/libc/include/string.h
@@ -46,7 +46,7 @@ size_t _EXFUN(strxfrm,(char *__restrict, const char *__restrict, size_t));
#if __MISC_VISIBLE || __POSIX_VISIBLE
char *_EXFUN(strtok_r,(char *__restrict, const char *__restrict, char **__restrict));
#endif
-#if __BSD_VISIBLE || (__POSIX_VISIBLE && __POSIX_VISIBLE < 200809)
+#if __BSD_VISIBLE /* POSIX declaration is in <strings.h> */
int _EXFUN(bcmp,(const void *, const void *, size_t));
void _EXFUN(bcopy,(const void *, void *, size_t));
void _EXFUN(bzero,(void *, size_t));
@@ -56,10 +56,8 @@ void _EXFUN(explicit_bzero,(void *, size_t));
int _EXFUN(timingsafe_bcmp,(const void *, const void *, size_t));
int _EXFUN(timingsafe_memcmp,(const void *, const void *, size_t));
#endif
-#if __MISC_VISIBLE || __POSIX_VISIBLE >= 200809
+#if __BSD_VISIBLE /* POSIX declaration is in <strings.h> */
int _EXFUN(ffs,(int));
-#endif
-#if __BSD_VISIBLE || (__POSIX_VISIBLE && __POSIX_VISIBLE < 200809)
char *_EXFUN(index,(const char *, int));
#endif
#if __MISC_VISIBLE || __POSIX_VISIBLE
@@ -71,12 +69,14 @@ _PTR _EXFUN(memmem, (const _PTR, size_t, const _PTR, size_t));
_PTR _EXFUN(memrchr,(const _PTR, int, size_t));
_PTR _EXFUN(rawmemchr,(const _PTR, int));
#endif
-#if __BSD_VISIBLE || (__POSIX_VISIBLE && __POSIX_VISIBLE < 200809)
+#if __BSD_VISIBLE /* POSIX declaration is in <strings.h> */
char *_EXFUN(rindex,(const char *, int));
#endif
+#if __POSIX_VISIBLE >= 200809
char *_EXFUN(stpcpy,(char *__restrict, const char *__restrict));
char *_EXFUN(stpncpy,(char *__restrict, const char *__restrict, size_t));
-#if __BSD_VISIBLE || __POSIX_VISIBLE
+#endif
+#if __BSD_VISIBLE /* POSIX declaration is in <strings.h> */
int _EXFUN(strcasecmp,(const char *, const char *));
#endif
#if __GNU_VISIBLE
@@ -123,7 +123,7 @@ char * _EXFUN(_strerror_r, (struct _reent *, int, int, int *));
size_t _EXFUN(strlcat,(char *, const char *, size_t));
size_t _EXFUN(strlcpy,(char *, const char *, size_t));
#endif
-#if __BSD_VISIBLE || __POSIX_VISIBLE
+#if __BSD_VISIBLE /* POSIX declaration is in <strings.h> */
int _EXFUN(strncasecmp,(const char *, const char *, size_t));
#endif
#if __POSIX_VISIBLE >= 200809
diff --git a/newlib/libc/include/strings.h b/newlib/libc/include/strings.h
index fdccfca..e467467 100644
--- a/newlib/libc/include/strings.h
+++ b/newlib/libc/include/strings.h
@@ -7,6 +7,9 @@
#ifndef _STRINGS_H_
#define _STRINGS_H_
+/* These functions are already declared in <string.h> with __BSD_VISIBLE */
+#if !(defined(_STRING_H_) && __BSD_VISIBLE)
+
#include "_ansi.h"
#include <sys/reent.h>
#include <sys/cdefs.h>
@@ -32,4 +35,6 @@ int _EXFUN(strncasecmp,(const char *, const char *, size_t));
_END_STD_C
+#endif /* !(_STRING_H_ && __BSD_VISIBLE) */
+
#endif /* _STRINGS_H_ */