This is the mail archive of the newlib@sourceware.org mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH v3 14/24] Feature test macros overhaul: string.h


Throughout, remove __STRICT_ANSI__ and use the proper internal macros.

bcmp, bcopy, bzero, index, and rindex were in POSIX prior to 2008.

memrchr is GNU.

strdup and strndup are POSIX.1-2008.

The int-returning form of strerror_r is POSIX.1-2001.

Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
---
 newlib/libc/include/string.h | 38 +++++++++++++++-----------------------
 1 file changed, 15 insertions(+), 23 deletions(-)

diff --git a/newlib/libc/include/string.h b/newlib/libc/include/string.h
index 84dd6b0..8580d16 100644
--- a/newlib/libc/include/string.h
+++ b/newlib/libc/include/string.h
@@ -43,28 +43,30 @@ char 	*_EXFUN(strtok,(char *__restrict, const char *__restrict));
 #endif
 size_t	 _EXFUN(strxfrm,(char *__restrict, const char *__restrict, size_t));
 
-#if __POSIX_VISIBLE
+#if __MISC_VISIBLE || __POSIX_VISIBLE
 char 	*_EXFUN(strtok_r,(char *__restrict, const char *__restrict, char **__restrict));
 #endif
-#if __BSD_VISIBLE
+#if __BSD_VISIBLE || (__POSIX_VISIBLE && __POSIX_VISIBLE < 200809)
 int	 _EXFUN(bcmp,(const void *, const void *, size_t));
 void	 _EXFUN(bcopy,(const void *, void *, size_t));
 void	 _EXFUN(bzero,(void *, size_t));
+#endif
+#if __MISC_VISIBLE || __POSIX_VISIBLE >= 200809
 int	 _EXFUN(ffs,(int));
+#endif
+#if __BSD_VISIBLE || (__POSIX_VISIBLE && __POSIX_VISIBLE < 200809)
 char 	*_EXFUN(index,(const char *, int));
 #endif
-#if __BSD_VISIBLE || __XSI_VISIBLE
+#if __MISC_VISIBLE || __POSIX_VISIBLE
 _PTR	 _EXFUN(memccpy,(_PTR __restrict, const _PTR __restrict, int, size_t));
 #endif
 #if __GNU_VISIBLE
 _PTR	 _EXFUN(mempcpy,(_PTR, const _PTR, size_t));
 _PTR	 _EXFUN(memmem, (const _PTR, size_t, const _PTR, size_t));
-#endif
 _PTR 	 _EXFUN(memrchr,(const _PTR, int, size_t));
-#if __GNU_VISIBLE
 _PTR 	 _EXFUN(rawmemchr,(const _PTR, int));
 #endif
-#if __BSD_VISIBLE
+#if __BSD_VISIBLE || (__POSIX_VISIBLE && __POSIX_VISIBLE < 200809)
 char 	*_EXFUN(rindex,(const char *, int));
 #endif
 char 	*_EXFUN(stpcpy,(char *__restrict, const char *__restrict));
@@ -76,19 +78,14 @@ int	 _EXFUN(strcasecmp,(const char *, const char *));
 char	*_EXFUN(strcasestr,(const char *, const char *));
 char 	*_EXFUN(strchrnul,(const char *, int));
 #endif
-#if __XSI_VISIBLE >= 500
+#if __MISC_VISIBLE || __POSIX_VISIBLE >= 200809 || __XSI_VISIBLE >= 4
 char 	*_EXFUN(strdup,(const char *));
 #endif
-#ifndef __STRICT_ANSI__
 char 	*_EXFUN(_strdup_r,(struct _reent *, const char *));
-#endif
-#if __XSI_VISIBLE >= 700
+#if __POSIX_VISIBLE >= 200809
 char 	*_EXFUN(strndup,(const char *, size_t));
 #endif
-
-#ifndef __STRICT_ANSI__
 char 	*_EXFUN(_strndup_r,(struct _reent *, const char *, size_t));
-#endif
 
 #if __GNU_VISIBLE
 int	 _EXFUN(ffsl,(long));
@@ -101,7 +98,7 @@ int	 _EXFUN(ffsll, (long long));
    invoke the underlying function, but that requires gcc support.  */
 #if __GNU_VISIBLE
 char	*_EXFUN(strerror_r,(int, char *, size_t));
-#else
+#elif __POSIX_VISIBLE >= 200112
 # ifdef __GNUC__
 int	_EXFUN(strerror_r,(int, char *, size_t))
 #ifdef __ASMNAME
@@ -124,19 +121,14 @@ size_t	_EXFUN(strlcpy,(char *, const char *, size_t));
 #if __BSD_VISIBLE || __POSIX_VISIBLE
 int	_EXFUN(strncasecmp,(const char *, const char *, size_t));
 #endif
-#if !defined(__STRICT_ANSI__) || __POSIX_VISIBLE >= 200809 || \
-    __XSI_VISIBLE >= 700
+#if __POSIX_VISIBLE >= 200809
 size_t	 _EXFUN(strnlen,(const char *, size_t));
 #endif
 #if __BSD_VISIBLE
 char 	*_EXFUN(strsep,(char **, const char *));
 #endif
 
-/*
- * The origin of these is unknown to me so I am conditionalizing them
- * on __STRICT_ANSI__. Finetuning this is definitely needed. --joel
- */
-#if !defined(__STRICT_ANSI__)
+#if __MISC_VISIBLE
 char	*_EXFUN(strlwr,(char *));
 char	*_EXFUN(strupr,(char *));
 #endif
@@ -149,7 +141,7 @@ char	*_EXFUN(strsignal, (int __signo));
 int	_EXFUN(strtosigno, (const char *__name));
 #endif
 
-#if defined _GNU_SOURCE && defined __GNUC__
+#if __GNU_VISIBLE && defined(__GNUC__)
 #define strdupa(__s) \
 	(__extension__ ({const char *__in = (__s); \
 			 size_t __len = strlen (__in) + 1; \
@@ -161,7 +153,7 @@ int	_EXFUN(strtosigno, (const char *__name));
 			 char *__out = (char *) __builtin_alloca (__len); \
 			 __out[__len-1] = '\0'; \
 			 (char *) memcpy (__out, __in, __len-1);}))
-#endif /* _GNU_SOURCE && __GNUC__ */
+#endif /* __GNU_VISIBLE && __GNUC__ */
 
 /* There are two common basename variants.  If you do NOT #include <libgen.h>
    and you do
-- 
2.7.0


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]