summaryrefslogtreecommitdiff
path: root/include/string.h
diff options
context:
space:
mode:
authorbjh21 <bjh21@NetBSD.org>2003-04-28 23:16:11 +0000
committerbjh21 <bjh21@NetBSD.org>2003-04-28 23:16:11 +0000
commit4be7a2dcf395bcf0739f131315b64970d74b265e (patch)
tree50a146602abe550af45c34b744ac26b42213b959 /include/string.h
parent4fc5083af1f3cbcb7a421c77dcf29b1264f0599f (diff)
Add a new feature-test macro, _NETBSD_SOURCE. If this is defined
by the application, all NetBSD interfaces are made visible, even if some other feature-test macro (like _POSIX_C_SOURCE) is defined. <sys/featuretest.h> defined _NETBSD_SOURCE if none of _ANSI_SOURCE, _POSIX_C_SOURCE and _XOPEN_SOURCE is defined, so as to preserve existing behaviour. This has two major advantages: + Programs that require non-POSIX facilities but define _POSIX_C_SOURCE can trivially be overruled by putting -D_NETBSD_SOURCE in their CFLAGS. + It makes most of the #ifs simpler, in that they're all now ORs of the various macros, rather than having checks for (!defined(_ANSI_SOURCE) || !defined(_POSIX_C_SOURCE) || !defined(_XOPEN_SOURCE)) all over the place. I've tried not to change the semantics of the headers in any case where _NETBSD_SOURCE wasn't defined, but there were some places where the current semantics were clearly mad, and retaining them was harder than correcting them. In particular, I've mostly normalised things so that _ANSI_SOURCE gets you the smallest set of stuff, then _POSIX_C_SOURCE, _XOPEN_SOURCE and _NETBSD_SOURCE in that order. Tested by building for vax, encouraged by thorpej, and uncontested in tech-userlevel for a week.
Diffstat (limited to 'include/string.h')
-rw-r--r--include/string.h19
1 files changed, 8 insertions, 11 deletions
diff --git a/include/string.h b/include/string.h
index cf0210cbe87..021b38ed761 100644
--- a/include/string.h
+++ b/include/string.h
@@ -1,4 +1,4 @@
-/* $NetBSD: string.h,v 1.23 2001/03/22 07:37:04 kleink Exp $ */
+/* $NetBSD: string.h,v 1.24 2003/04/28 23:16:15 bjh21 Exp $ */
/*-
* Copyright (c) 1990, 1993
@@ -71,26 +71,23 @@ char *strrchr __P((const char *, int));
size_t strspn __P((const char *, const char *));
char *strstr __P((const char *, const char *));
char *strtok __P((char * __restrict, const char * __restrict));
-#if (!defined(_ANSI_SOURCE) && !defined(_POSIX_C_SOURCE) && \
- !defined(_XOPEN_SOURCE)) || defined(_REENTRANT) || \
- (_POSIX_C_SOURCE - 0 >= 199506L) || (_XOPEN_SOURCE - 0 >= 500)
+#if (_POSIX_C_SOURCE - 0 >= 199506L) || (_XOPEN_SOURCE - 0 >= 500) || \
+ defined(_REENTRANT) || defined(_NETBSD_SOURCE)
char *strtok_r __P((char *, const char *, char **));
-#endif /* !defined(_ANSI_SOURCE) || defined(_REENTRANT) || ... */
+#endif /* _POSIX_C_SOURCE >= 199506 || XOPEN_SOURCE >= 500 || ... */
size_t strxfrm __P((char * __restrict, const char * __restrict, size_t));
-#if !defined(_ANSI_SOURCE) && !defined(_POSIX_C_SOURCE) || \
- defined(_XOPEN_SOURCE)
+#if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE)
void *memccpy __P((void *, const void *, int, size_t));
char *strdup __P((const char *));
-#endif /* !defined(_ANSI_SOURCE) && !defined(_POSIX_C_SOURCE) */
+#endif
-#if !defined(_ANSI_SOURCE) && !defined(_POSIX_C_SOURCE) && \
- !defined(_XOPEN_SOURCE)
+#if defined(_NETBSD_SOURCE)
#include <strings.h> /* for backwards-compatibilty */
size_t strlcat __P((char *, const char *, size_t));
size_t strlcpy __P((char *, const char *, size_t));
char *strsep __P((char **, const char *));
-#endif /* !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE) && ... */
+#endif
__END_DECLS
#endif /* !defined(_STRING_H_) */