xref: /illumos-gate/usr/src/head/iso/string_iso.h (revision 50971960)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
57c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
67c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
77c478bd9Sstevel@tonic-gate  * with the License.
87c478bd9Sstevel@tonic-gate  *
97c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
107c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
117c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
127c478bd9Sstevel@tonic-gate  * and limitations under the License.
137c478bd9Sstevel@tonic-gate  *
147c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
157c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
167c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
177c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
187c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
197c478bd9Sstevel@tonic-gate  *
207c478bd9Sstevel@tonic-gate  * CDDL HEADER END
217c478bd9Sstevel@tonic-gate  */
227c478bd9Sstevel@tonic-gate /*	Copyright (c) 1988 AT&T	*/
23b4203d75SMarcel Telka /*	  All Rights Reserved	*/
247c478bd9Sstevel@tonic-gate 
257c478bd9Sstevel@tonic-gate 
267c478bd9Sstevel@tonic-gate /*
27ba3594baSGarrett D'Amore  * Copyright 2014 Garrett D'Amore <garrett@damore.org>
284870e0a7SRichard PALO  * Copyright 2014 PALO, Richard.
29ba3594baSGarrett D'Amore  *
307c478bd9Sstevel@tonic-gate  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
317c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
327c478bd9Sstevel@tonic-gate  */
337c478bd9Sstevel@tonic-gate 
347c478bd9Sstevel@tonic-gate /*
357c478bd9Sstevel@tonic-gate  * An application should not include this header directly.  Instead it
367c478bd9Sstevel@tonic-gate  * should be included only through the inclusion of other Sun headers.
377c478bd9Sstevel@tonic-gate  *
387c478bd9Sstevel@tonic-gate  * The contents of this header is limited to identifiers specified in the
397c478bd9Sstevel@tonic-gate  * C Standard.  Any new identifiers specified in future amendments to the
407c478bd9Sstevel@tonic-gate  * C Standard must be placed in this header.  If these new identifiers
417c478bd9Sstevel@tonic-gate  * are required to also be in the C++ Standard "std" namespace, then for
427c478bd9Sstevel@tonic-gate  * anything other than macro definitions, corresponding "using" directives
437c478bd9Sstevel@tonic-gate  * must also be added to <string.h>.
447c478bd9Sstevel@tonic-gate  */
457c478bd9Sstevel@tonic-gate 
467c478bd9Sstevel@tonic-gate #ifndef _ISO_STRING_ISO_H
477c478bd9Sstevel@tonic-gate #define	_ISO_STRING_ISO_H
487c478bd9Sstevel@tonic-gate 
497c478bd9Sstevel@tonic-gate #include <sys/feature_tests.h>
504870e0a7SRichard PALO #include <sys/null.h>
517c478bd9Sstevel@tonic-gate 
527c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
537c478bd9Sstevel@tonic-gate extern "C" {
547c478bd9Sstevel@tonic-gate #endif
557c478bd9Sstevel@tonic-gate 
567c478bd9Sstevel@tonic-gate #if __cplusplus >= 199711L
577c478bd9Sstevel@tonic-gate namespace std {
587c478bd9Sstevel@tonic-gate #endif
597c478bd9Sstevel@tonic-gate 
607c478bd9Sstevel@tonic-gate #if !defined(_SIZE_T) || __cplusplus >= 199711L
617c478bd9Sstevel@tonic-gate #define	_SIZE_T
627c478bd9Sstevel@tonic-gate #if defined(_LP64) || defined(_I32LPx)
637c478bd9Sstevel@tonic-gate typedef unsigned long	size_t;		/* size of something in bytes */
647c478bd9Sstevel@tonic-gate #else
657c478bd9Sstevel@tonic-gate typedef unsigned int	size_t;		/* (historical version) */
667c478bd9Sstevel@tonic-gate #endif
677c478bd9Sstevel@tonic-gate #endif	/* !_SIZE_T */
687c478bd9Sstevel@tonic-gate 
697c478bd9Sstevel@tonic-gate extern int memcmp(const void *, const void *, size_t);
707c478bd9Sstevel@tonic-gate extern void *memcpy(void *_RESTRICT_KYWD, const void *_RESTRICT_KYWD, size_t);
717c478bd9Sstevel@tonic-gate extern void *memmove(void *, const void *, size_t);
727c478bd9Sstevel@tonic-gate extern void *memset(void *, int, size_t);
737c478bd9Sstevel@tonic-gate extern char *strcat(char *_RESTRICT_KYWD, const char *_RESTRICT_KYWD);
747c478bd9Sstevel@tonic-gate extern int strcmp(const char *, const char *);
757c478bd9Sstevel@tonic-gate extern char *strcpy(char *_RESTRICT_KYWD, const char *_RESTRICT_KYWD);
767c478bd9Sstevel@tonic-gate extern int strcoll(const char *, const char *);
777c478bd9Sstevel@tonic-gate extern size_t strcspn(const char *, const char *);
787c478bd9Sstevel@tonic-gate extern char *strerror(int);
797c478bd9Sstevel@tonic-gate extern size_t strlen(const char *);
807c478bd9Sstevel@tonic-gate extern char *strncat(char *_RESTRICT_KYWD, const char *_RESTRICT_KYWD, size_t);
817c478bd9Sstevel@tonic-gate extern int strncmp(const char *, const char *, size_t);
827c478bd9Sstevel@tonic-gate extern char *strncpy(char *_RESTRICT_KYWD, const char *_RESTRICT_KYWD, size_t);
837c478bd9Sstevel@tonic-gate extern size_t strspn(const char *, const char *);
847c478bd9Sstevel@tonic-gate extern char *strtok(char *_RESTRICT_KYWD, const char *_RESTRICT_KYWD);
857c478bd9Sstevel@tonic-gate extern size_t strxfrm(char *_RESTRICT_KYWD, const char *_RESTRICT_KYWD, size_t);
867c478bd9Sstevel@tonic-gate 
877c478bd9Sstevel@tonic-gate /*
887c478bd9Sstevel@tonic-gate  * The C++ Standard (ISO/IEC 14882:1998) specifies that each of the
897c478bd9Sstevel@tonic-gate  * function signatures for the following functions be replaced by
907c478bd9Sstevel@tonic-gate  * two declarations, both of which have the same behavior.
917c478bd9Sstevel@tonic-gate  */
927c478bd9Sstevel@tonic-gate #if __cplusplus >= 199711L
937c478bd9Sstevel@tonic-gate extern const void *memchr(const void *, int, size_t);
947c478bd9Sstevel@tonic-gate #ifndef	_MEMCHR_INLINE
957c478bd9Sstevel@tonic-gate #define	_MEMCHR_INLINE
967c478bd9Sstevel@tonic-gate extern "C++" {
memchr(void * __s,int __c,size_t __n)977c478bd9Sstevel@tonic-gate 	inline void *memchr(void * __s, int __c, size_t __n) {
987c478bd9Sstevel@tonic-gate 		return (void *)memchr((const void *)__s, __c, __n);
997c478bd9Sstevel@tonic-gate 	}
1007c478bd9Sstevel@tonic-gate }
1017c478bd9Sstevel@tonic-gate #endif  /* _MEMCHR_INLINE */
1027c478bd9Sstevel@tonic-gate extern const char *strchr(const char *, int);
1037c478bd9Sstevel@tonic-gate #ifndef _STRCHR_INLINE
1047c478bd9Sstevel@tonic-gate #define	_STRCHR_INLINE
1057c478bd9Sstevel@tonic-gate extern "C++" {
strchr(char * __s,int __c)1067c478bd9Sstevel@tonic-gate 	inline char *strchr(char *__s, int __c) {
1077c478bd9Sstevel@tonic-gate 		return (char *)strchr((const char *)__s, __c);
1087c478bd9Sstevel@tonic-gate 	}
1097c478bd9Sstevel@tonic-gate }
1107c478bd9Sstevel@tonic-gate #endif	/* _STRCHR_INLINE */
1117c478bd9Sstevel@tonic-gate extern const char *strpbrk(const char *, const char *);
1127c478bd9Sstevel@tonic-gate #ifndef _STRPBRK_INLINE
1137c478bd9Sstevel@tonic-gate #define	_STRPBRK_INLINE
1147c478bd9Sstevel@tonic-gate extern "C++" {
strpbrk(char * __s1,const char * __s2)1157c478bd9Sstevel@tonic-gate 	inline char *strpbrk(char *__s1, const char *__s2) {
1167c478bd9Sstevel@tonic-gate 		return (char *)strpbrk((const char *)__s1, __s2);
1177c478bd9Sstevel@tonic-gate 	}
1187c478bd9Sstevel@tonic-gate }
1197c478bd9Sstevel@tonic-gate #endif	/* _STRPBRK_INLINE */
1207c478bd9Sstevel@tonic-gate extern const char *strrchr(const char *, int);
1217c478bd9Sstevel@tonic-gate #ifndef _STRRCHR_INLINE
1227c478bd9Sstevel@tonic-gate #define	_STRRCHR_INLINE
1237c478bd9Sstevel@tonic-gate extern "C++" {
strrchr(char * __s,int __c)1247c478bd9Sstevel@tonic-gate 	inline char *strrchr(char *__s, int __c) {
1257c478bd9Sstevel@tonic-gate 		return (char *)strrchr((const char *)__s, __c);
1267c478bd9Sstevel@tonic-gate 	}
1277c478bd9Sstevel@tonic-gate }
1287c478bd9Sstevel@tonic-gate #endif	/* _STRRCHR_INLINE */
1297c478bd9Sstevel@tonic-gate extern const char *strstr(const char *, const char *);
1307c478bd9Sstevel@tonic-gate #ifndef _STRSTR_INLINE
1317c478bd9Sstevel@tonic-gate #define	_STRSTR_INLINE
1327c478bd9Sstevel@tonic-gate extern "C++" {
strstr(char * __s1,const char * __s2)1337c478bd9Sstevel@tonic-gate 	inline char *strstr(char *__s1, const char *__s2) {
1347c478bd9Sstevel@tonic-gate 		return (char *)strstr((const char *)__s1, __s2);
1357c478bd9Sstevel@tonic-gate 	}
1367c478bd9Sstevel@tonic-gate }
1377c478bd9Sstevel@tonic-gate #endif	/* _STRSTR_INLINE */
1387c478bd9Sstevel@tonic-gate #else /* __cplusplus >= 199711L */
1397c478bd9Sstevel@tonic-gate extern void *memchr(const void *, int, size_t);
1407c478bd9Sstevel@tonic-gate extern char *strchr(const char *, int);
1417c478bd9Sstevel@tonic-gate extern char *strpbrk(const char *, const char *);
1427c478bd9Sstevel@tonic-gate extern char *strrchr(const char *, int);
1437c478bd9Sstevel@tonic-gate extern char *strstr(const char *, const char *);
1447c478bd9Sstevel@tonic-gate #endif /* __cplusplus >= 199711L */
1457c478bd9Sstevel@tonic-gate 
146*50971960SAlexander Pyhalov #if __cplusplus >= 199711L
147*50971960SAlexander Pyhalov }
148*50971960SAlexander Pyhalov #endif /* end of namespace std */
149*50971960SAlexander Pyhalov 
150*50971960SAlexander Pyhalov /*
151*50971960SAlexander Pyhalov  * ISO C11 Annex K functions are not allowed to be in the standard
152*50971960SAlexander Pyhalov  * namespace; however, it is implementation-defined as to whether or
153*50971960SAlexander Pyhalov  * not they are in the global namespace and we opt to make them
154*50971960SAlexander Pyhalov  * available to software.
155*50971960SAlexander Pyhalov  */
15600efb5e1SYuri Pankov #if __EXT1_VISIBLE
15700efb5e1SYuri Pankov 
15800efb5e1SYuri Pankov #ifndef	_RSIZE_T_DEFINED
15900efb5e1SYuri Pankov #define	_RSIZE_T_DEFINED
160*50971960SAlexander Pyhalov #if __cplusplus >= 199711L
161*50971960SAlexander Pyhalov typedef std::size_t rsize_t;
162*50971960SAlexander Pyhalov #else
16300efb5e1SYuri Pankov typedef size_t rsize_t;
16400efb5e1SYuri Pankov #endif
165*50971960SAlexander Pyhalov #endif
16600efb5e1SYuri Pankov 
16700efb5e1SYuri Pankov #ifndef	_ERRNO_T_DEFINED
16800efb5e1SYuri Pankov #define	_ERRNO_T_DEFINED
16900efb5e1SYuri Pankov typedef int errno_t;
17000efb5e1SYuri Pankov #endif
17100efb5e1SYuri Pankov 
17200efb5e1SYuri Pankov /* ISO/IEC 9899:2011 K.3.7.4.1.1 */
17300efb5e1SYuri Pankov extern errno_t memset_s(void *, rsize_t, int, rsize_t);
17400efb5e1SYuri Pankov #endif	/* __EXT1_VISIBLE */
17500efb5e1SYuri Pankov 
1767c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
1777c478bd9Sstevel@tonic-gate }
1787c478bd9Sstevel@tonic-gate #endif
1797c478bd9Sstevel@tonic-gate 
1807c478bd9Sstevel@tonic-gate #endif	/* _ISO_STRING_ISO_H */
181