xref: /illumos-gate/usr/src/head/iso/string_iso.h (revision a6bde1a23b60f140c7ed78df979c2e22b1ed9b2c)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*	Copyright (c) 1988 AT&T	*/
23 /*	  All Rights Reserved  	*/
24 
25 
26 /*
27  * Copyright 2014 Garrett D'Amore <garrett@damore.org>
28  *
29  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
30  * Use is subject to license terms.
31  */
32 
33 /*
34  * An application should not include this header directly.  Instead it
35  * should be included only through the inclusion of other Sun headers.
36  *
37  * The contents of this header is limited to identifiers specified in the
38  * C Standard.  Any new identifiers specified in future amendments to the
39  * C Standard must be placed in this header.  If these new identifiers
40  * are required to also be in the C++ Standard "std" namespace, then for
41  * anything other than macro definitions, corresponding "using" directives
42  * must also be added to <string.h>.
43  */
44 
45 #ifndef _ISO_STRING_ISO_H
46 #define	_ISO_STRING_ISO_H
47 
48 #include <sys/feature_tests.h>
49 
50 #ifdef	__cplusplus
51 extern "C" {
52 #endif
53 
54 #if __cplusplus >= 199711L
55 namespace std {
56 #endif
57 
58 #if !defined(_SIZE_T) || __cplusplus >= 199711L
59 #define	_SIZE_T
60 #if defined(_LP64) || defined(_I32LPx)
61 typedef unsigned long	size_t;		/* size of something in bytes */
62 #else
63 typedef unsigned int	size_t;		/* (historical version) */
64 #endif
65 #endif	/* !_SIZE_T */
66 
67 #ifndef	NULL
68 #if defined(_LP64)
69 #define	NULL	0L
70 #else
71 #define	NULL	0
72 #endif
73 #endif
74 
75 extern int memcmp(const void *, const void *, size_t);
76 extern void *memcpy(void *_RESTRICT_KYWD, const void *_RESTRICT_KYWD, size_t);
77 extern void *memmove(void *, const void *, size_t);
78 extern void *memset(void *, int, size_t);
79 extern char *strcat(char *_RESTRICT_KYWD, const char *_RESTRICT_KYWD);
80 extern int strcmp(const char *, const char *);
81 extern char *strcpy(char *_RESTRICT_KYWD, const char *_RESTRICT_KYWD);
82 extern int strcoll(const char *, const char *);
83 extern size_t strcspn(const char *, const char *);
84 extern char *strerror(int);
85 extern size_t strlen(const char *);
86 extern char *strncat(char *_RESTRICT_KYWD, const char *_RESTRICT_KYWD, size_t);
87 extern int strncmp(const char *, const char *, size_t);
88 extern char *strncpy(char *_RESTRICT_KYWD, const char *_RESTRICT_KYWD, size_t);
89 extern size_t strspn(const char *, const char *);
90 extern char *strtok(char *_RESTRICT_KYWD, const char *_RESTRICT_KYWD);
91 extern size_t strxfrm(char *_RESTRICT_KYWD, const char *_RESTRICT_KYWD, size_t);
92 
93 /*
94  * The C++ Standard (ISO/IEC 14882:1998) specifies that each of the
95  * function signatures for the following functions be replaced by
96  * two declarations, both of which have the same behavior.
97  */
98 #if __cplusplus >= 199711L
99 extern const void *memchr(const void *, int, size_t);
100 #ifndef	_MEMCHR_INLINE
101 #define	_MEMCHR_INLINE
102 extern "C++" {
103 	inline void *memchr(void * __s, int __c, size_t __n) {
104 		return (void *)memchr((const void *)__s, __c, __n);
105 	}
106 }
107 #endif  /* _MEMCHR_INLINE */
108 extern const char *strchr(const char *, int);
109 #ifndef _STRCHR_INLINE
110 #define	_STRCHR_INLINE
111 extern "C++" {
112 	inline char *strchr(char *__s, int __c) {
113 		return (char *)strchr((const char *)__s, __c);
114 	}
115 }
116 #endif	/* _STRCHR_INLINE */
117 extern const char *strpbrk(const char *, const char *);
118 #ifndef _STRPBRK_INLINE
119 #define	_STRPBRK_INLINE
120 extern "C++" {
121 	inline char *strpbrk(char *__s1, const char *__s2) {
122 		return (char *)strpbrk((const char *)__s1, __s2);
123 	}
124 }
125 #endif	/* _STRPBRK_INLINE */
126 extern const char *strrchr(const char *, int);
127 #ifndef _STRRCHR_INLINE
128 #define	_STRRCHR_INLINE
129 extern "C++" {
130 	inline char *strrchr(char *__s, int __c) {
131 		return (char *)strrchr((const char *)__s, __c);
132 	}
133 }
134 #endif	/* _STRRCHR_INLINE */
135 extern const char *strstr(const char *, const char *);
136 #ifndef _STRSTR_INLINE
137 #define	_STRSTR_INLINE
138 extern "C++" {
139 	inline char *strstr(char *__s1, const char *__s2) {
140 		return (char *)strstr((const char *)__s1, __s2);
141 	}
142 }
143 #endif	/* _STRSTR_INLINE */
144 #else /* __cplusplus >= 199711L */
145 extern void *memchr(const void *, int, size_t);
146 extern char *strchr(const char *, int);
147 extern char *strpbrk(const char *, const char *);
148 extern char *strrchr(const char *, int);
149 extern char *strstr(const char *, const char *);
150 #endif /* __cplusplus >= 199711L */
151 
152 #if __cplusplus >= 199711L
153 }
154 #endif /* end of namespace std */
155 
156 #ifdef	__cplusplus
157 }
158 #endif
159 
160 #endif	/* _ISO_STRING_ISO_H */
161