1*700637cbSDimitry Andric // -*- C++ -*-
2*700637cbSDimitry Andric //===----------------------------------------------------------------------===//
3*700637cbSDimitry Andric //
4*700637cbSDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5*700637cbSDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
6*700637cbSDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7*700637cbSDimitry Andric //
8*700637cbSDimitry Andric //===----------------------------------------------------------------------===//
9*700637cbSDimitry Andric
10*700637cbSDimitry Andric #ifndef _LIBCPP___CXX03_STRING_H
11*700637cbSDimitry Andric #define _LIBCPP___CXX03_STRING_H
12*700637cbSDimitry Andric
13*700637cbSDimitry Andric /*
14*700637cbSDimitry Andric string.h synopsis
15*700637cbSDimitry Andric
16*700637cbSDimitry Andric Macros:
17*700637cbSDimitry Andric
18*700637cbSDimitry Andric NULL
19*700637cbSDimitry Andric
20*700637cbSDimitry Andric Types:
21*700637cbSDimitry Andric
22*700637cbSDimitry Andric size_t
23*700637cbSDimitry Andric
24*700637cbSDimitry Andric void* memcpy(void* restrict s1, const void* restrict s2, size_t n);
25*700637cbSDimitry Andric void* memmove(void* s1, const void* s2, size_t n);
26*700637cbSDimitry Andric char* strcpy (char* restrict s1, const char* restrict s2);
27*700637cbSDimitry Andric char* strncpy(char* restrict s1, const char* restrict s2, size_t n);
28*700637cbSDimitry Andric char* strcat (char* restrict s1, const char* restrict s2);
29*700637cbSDimitry Andric char* strncat(char* restrict s1, const char* restrict s2, size_t n);
30*700637cbSDimitry Andric int memcmp(const void* s1, const void* s2, size_t n);
31*700637cbSDimitry Andric int strcmp (const char* s1, const char* s2);
32*700637cbSDimitry Andric int strncmp(const char* s1, const char* s2, size_t n);
33*700637cbSDimitry Andric int strcoll(const char* s1, const char* s2);
34*700637cbSDimitry Andric size_t strxfrm(char* restrict s1, const char* restrict s2, size_t n);
35*700637cbSDimitry Andric const void* memchr(const void* s, int c, size_t n);
36*700637cbSDimitry Andric void* memchr( void* s, int c, size_t n);
37*700637cbSDimitry Andric const char* strchr(const char* s, int c);
38*700637cbSDimitry Andric char* strchr( char* s, int c);
39*700637cbSDimitry Andric size_t strcspn(const char* s1, const char* s2);
40*700637cbSDimitry Andric const char* strpbrk(const char* s1, const char* s2);
41*700637cbSDimitry Andric char* strpbrk( char* s1, const char* s2);
42*700637cbSDimitry Andric const char* strrchr(const char* s, int c);
43*700637cbSDimitry Andric char* strrchr( char* s, int c);
44*700637cbSDimitry Andric size_t strspn(const char* s1, const char* s2);
45*700637cbSDimitry Andric const char* strstr(const char* s1, const char* s2);
46*700637cbSDimitry Andric char* strstr( char* s1, const char* s2);
47*700637cbSDimitry Andric char* strtok(char* restrict s1, const char* restrict s2);
48*700637cbSDimitry Andric void* memset(void* s, int c, size_t n);
49*700637cbSDimitry Andric char* strerror(int errnum);
50*700637cbSDimitry Andric size_t strlen(const char* s);
51*700637cbSDimitry Andric
52*700637cbSDimitry Andric */
53*700637cbSDimitry Andric
54*700637cbSDimitry Andric #include <__cxx03/__config>
55*700637cbSDimitry Andric
56*700637cbSDimitry Andric #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
57*700637cbSDimitry Andric # pragma GCC system_header
58*700637cbSDimitry Andric #endif
59*700637cbSDimitry Andric
60*700637cbSDimitry Andric #if __has_include_next(<string.h>)
61*700637cbSDimitry Andric # include_next <string.h>
62*700637cbSDimitry Andric #endif
63*700637cbSDimitry Andric
64*700637cbSDimitry Andric // MSVCRT, GNU libc and its derivates may already have the correct prototype in
65*700637cbSDimitry Andric // <string.h>. This macro can be defined by users if their C library provides
66*700637cbSDimitry Andric // the right signature.
67*700637cbSDimitry Andric #if defined(__CORRECT_ISO_CPP_STRING_H_PROTO) || defined(_LIBCPP_MSVCRT) || defined(_STRING_H_CPLUSPLUS_98_CONFORMANCE_)
68*700637cbSDimitry Andric # define _LIBCPP_STRING_H_HAS_CONST_OVERLOADS
69*700637cbSDimitry Andric #endif
70*700637cbSDimitry Andric
71*700637cbSDimitry Andric #if defined(__cplusplus) && !defined(_LIBCPP_STRING_H_HAS_CONST_OVERLOADS) && defined(_LIBCPP_PREFERRED_OVERLOAD)
72*700637cbSDimitry Andric extern "C++" {
strchr(const char * __s,int __c)73*700637cbSDimitry Andric inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_PREFERRED_OVERLOAD const char* strchr(const char* __s, int __c) {
74*700637cbSDimitry Andric return __builtin_strchr(__s, __c);
75*700637cbSDimitry Andric }
strchr(char * __s,int __c)76*700637cbSDimitry Andric inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_PREFERRED_OVERLOAD char* strchr(char* __s, int __c) {
77*700637cbSDimitry Andric return __builtin_strchr(__s, __c);
78*700637cbSDimitry Andric }
79*700637cbSDimitry Andric
strpbrk(const char * __s1,const char * __s2)80*700637cbSDimitry Andric inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_PREFERRED_OVERLOAD const char* strpbrk(const char* __s1, const char* __s2) {
81*700637cbSDimitry Andric return __builtin_strpbrk(__s1, __s2);
82*700637cbSDimitry Andric }
strpbrk(char * __s1,const char * __s2)83*700637cbSDimitry Andric inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_PREFERRED_OVERLOAD char* strpbrk(char* __s1, const char* __s2) {
84*700637cbSDimitry Andric return __builtin_strpbrk(__s1, __s2);
85*700637cbSDimitry Andric }
86*700637cbSDimitry Andric
strrchr(const char * __s,int __c)87*700637cbSDimitry Andric inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_PREFERRED_OVERLOAD const char* strrchr(const char* __s, int __c) {
88*700637cbSDimitry Andric return __builtin_strrchr(__s, __c);
89*700637cbSDimitry Andric }
strrchr(char * __s,int __c)90*700637cbSDimitry Andric inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_PREFERRED_OVERLOAD char* strrchr(char* __s, int __c) {
91*700637cbSDimitry Andric return __builtin_strrchr(__s, __c);
92*700637cbSDimitry Andric }
93*700637cbSDimitry Andric
memchr(const void * __s,int __c,size_t __n)94*700637cbSDimitry Andric inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_PREFERRED_OVERLOAD const void* memchr(const void* __s, int __c, size_t __n) {
95*700637cbSDimitry Andric return __builtin_memchr(__s, __c, __n);
96*700637cbSDimitry Andric }
memchr(void * __s,int __c,size_t __n)97*700637cbSDimitry Andric inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_PREFERRED_OVERLOAD void* memchr(void* __s, int __c, size_t __n) {
98*700637cbSDimitry Andric return __builtin_memchr(__s, __c, __n);
99*700637cbSDimitry Andric }
100*700637cbSDimitry Andric
strstr(const char * __s1,const char * __s2)101*700637cbSDimitry Andric inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_PREFERRED_OVERLOAD const char* strstr(const char* __s1, const char* __s2) {
102*700637cbSDimitry Andric return __builtin_strstr(__s1, __s2);
103*700637cbSDimitry Andric }
strstr(char * __s1,const char * __s2)104*700637cbSDimitry Andric inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_PREFERRED_OVERLOAD char* strstr(char* __s1, const char* __s2) {
105*700637cbSDimitry Andric return __builtin_strstr(__s1, __s2);
106*700637cbSDimitry Andric }
107*700637cbSDimitry Andric } // extern "C++"
108*700637cbSDimitry Andric #endif
109*700637cbSDimitry Andric
110*700637cbSDimitry Andric #endif // _LIBCPP___CXX03_STRING_H
111