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 * Copyright 2014 PALO, Richard.
29 *
30 * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
31 * Use is subject to license terms.
32 */
33
34/*
35 * An application should not include this header directly.  Instead it
36 * should be included only through the inclusion of other Sun headers.
37 *
38 * The contents of this header is limited to identifiers specified in the
39 * C Standard.  Any new identifiers specified in future amendments to the
40 * C Standard must be placed in this header.  If these new identifiers
41 * are required to also be in the C++ Standard "std" namespace, then for
42 * anything other than macro definitions, corresponding "using" directives
43 * must also be added to <string.h>.
44 */
45
46#ifndef _ISO_STRING_ISO_H
47#define	_ISO_STRING_ISO_H
48
49#include <sys/feature_tests.h>
50#include <sys/null.h>
51
52#ifdef	__cplusplus
53extern "C" {
54#endif
55
56#if __cplusplus >= 199711L
57namespace std {
58#endif
59
60#if !defined(_SIZE_T) || __cplusplus >= 199711L
61#define	_SIZE_T
62#if defined(_LP64) || defined(_I32LPx)
63typedef unsigned long	size_t;		/* size of something in bytes */
64#else
65typedef unsigned int	size_t;		/* (historical version) */
66#endif
67#endif	/* !_SIZE_T */
68
69extern int memcmp(const void *, const void *, size_t);
70extern void *memcpy(void *_RESTRICT_KYWD, const void *_RESTRICT_KYWD, size_t);
71extern void *memmove(void *, const void *, size_t);
72extern void *memset(void *, int, size_t);
73extern char *strcat(char *_RESTRICT_KYWD, const char *_RESTRICT_KYWD);
74extern int strcmp(const char *, const char *);
75extern char *strcpy(char *_RESTRICT_KYWD, const char *_RESTRICT_KYWD);
76extern int strcoll(const char *, const char *);
77extern size_t strcspn(const char *, const char *);
78extern char *strerror(int);
79extern size_t strlen(const char *);
80extern char *strncat(char *_RESTRICT_KYWD, const char *_RESTRICT_KYWD, size_t);
81extern int strncmp(const char *, const char *, size_t);
82extern char *strncpy(char *_RESTRICT_KYWD, const char *_RESTRICT_KYWD, size_t);
83extern size_t strspn(const char *, const char *);
84extern char *strtok(char *_RESTRICT_KYWD, const char *_RESTRICT_KYWD);
85extern size_t strxfrm(char *_RESTRICT_KYWD, const char *_RESTRICT_KYWD, size_t);
86
87/*
88 * The C++ Standard (ISO/IEC 14882:1998) specifies that each of the
89 * function signatures for the following functions be replaced by
90 * two declarations, both of which have the same behavior.
91 */
92#if __cplusplus >= 199711L
93extern const void *memchr(const void *, int, size_t);
94#ifndef	_MEMCHR_INLINE
95#define	_MEMCHR_INLINE
96extern "C++" {
97	inline void *memchr(void * __s, int __c, size_t __n) {
98		return (void *)memchr((const void *)__s, __c, __n);
99	}
100}
101#endif  /* _MEMCHR_INLINE */
102extern const char *strchr(const char *, int);
103#ifndef _STRCHR_INLINE
104#define	_STRCHR_INLINE
105extern "C++" {
106	inline char *strchr(char *__s, int __c) {
107		return (char *)strchr((const char *)__s, __c);
108	}
109}
110#endif	/* _STRCHR_INLINE */
111extern const char *strpbrk(const char *, const char *);
112#ifndef _STRPBRK_INLINE
113#define	_STRPBRK_INLINE
114extern "C++" {
115	inline char *strpbrk(char *__s1, const char *__s2) {
116		return (char *)strpbrk((const char *)__s1, __s2);
117	}
118}
119#endif	/* _STRPBRK_INLINE */
120extern const char *strrchr(const char *, int);
121#ifndef _STRRCHR_INLINE
122#define	_STRRCHR_INLINE
123extern "C++" {
124	inline char *strrchr(char *__s, int __c) {
125		return (char *)strrchr((const char *)__s, __c);
126	}
127}
128#endif	/* _STRRCHR_INLINE */
129extern const char *strstr(const char *, const char *);
130#ifndef _STRSTR_INLINE
131#define	_STRSTR_INLINE
132extern "C++" {
133	inline char *strstr(char *__s1, const char *__s2) {
134		return (char *)strstr((const char *)__s1, __s2);
135	}
136}
137#endif	/* _STRSTR_INLINE */
138#else /* __cplusplus >= 199711L */
139extern void *memchr(const void *, int, size_t);
140extern char *strchr(const char *, int);
141extern char *strpbrk(const char *, const char *);
142extern char *strrchr(const char *, int);
143extern char *strstr(const char *, const char *);
144#endif /* __cplusplus >= 199711L */
145
146#if __cplusplus >= 199711L
147}
148#endif /* end of namespace std */
149
150/*
151 * ISO C11 Annex K functions are not allowed to be in the standard
152 * namespace; however, it is implementation-defined as to whether or
153 * not they are in the global namespace and we opt to make them
154 * available to software.
155 */
156#if __EXT1_VISIBLE
157
158#ifndef	_RSIZE_T_DEFINED
159#define	_RSIZE_T_DEFINED
160#if __cplusplus >= 199711L
161typedef std::size_t rsize_t;
162#else
163typedef size_t rsize_t;
164#endif
165#endif
166
167#ifndef	_ERRNO_T_DEFINED
168#define	_ERRNO_T_DEFINED
169typedef int errno_t;
170#endif
171
172/* ISO/IEC 9899:2011 K.3.7.4.1.1 */
173extern errno_t memset_s(void *, rsize_t, int, rsize_t);
174#endif	/* __EXT1_VISIBLE */
175
176#ifdef	__cplusplus
177}
178#endif
179
180#endif	/* _ISO_STRING_ISO_H */
181