10b57cec5SDimitry Andric // -*- C++ -*- 2349cc55cSDimitry Andric //===----------------------------------------------------------------------===// 30b57cec5SDimitry Andric // 40b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 50b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information. 60b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 70b57cec5SDimitry Andric // 80b57cec5SDimitry Andric //===----------------------------------------------------------------------===// 90b57cec5SDimitry Andric 100b57cec5SDimitry Andric #ifndef _LIBCPP_STRING_H 110b57cec5SDimitry Andric #define _LIBCPP_STRING_H 120b57cec5SDimitry Andric 130b57cec5SDimitry Andric /* 140b57cec5SDimitry Andric string.h synopsis 150b57cec5SDimitry Andric 160b57cec5SDimitry Andric Macros: 170b57cec5SDimitry Andric 180b57cec5SDimitry Andric NULL 190b57cec5SDimitry Andric 200b57cec5SDimitry Andric Types: 210b57cec5SDimitry Andric 220b57cec5SDimitry Andric size_t 230b57cec5SDimitry Andric 240b57cec5SDimitry Andric void* memcpy(void* restrict s1, const void* restrict s2, size_t n); 250b57cec5SDimitry Andric void* memmove(void* s1, const void* s2, size_t n); 260b57cec5SDimitry Andric char* strcpy (char* restrict s1, const char* restrict s2); 270b57cec5SDimitry Andric char* strncpy(char* restrict s1, const char* restrict s2, size_t n); 280b57cec5SDimitry Andric char* strcat (char* restrict s1, const char* restrict s2); 290b57cec5SDimitry Andric char* strncat(char* restrict s1, const char* restrict s2, size_t n); 300b57cec5SDimitry Andric int memcmp(const void* s1, const void* s2, size_t n); 310b57cec5SDimitry Andric int strcmp (const char* s1, const char* s2); 320b57cec5SDimitry Andric int strncmp(const char* s1, const char* s2, size_t n); 330b57cec5SDimitry Andric int strcoll(const char* s1, const char* s2); 340b57cec5SDimitry Andric size_t strxfrm(char* restrict s1, const char* restrict s2, size_t n); 350b57cec5SDimitry Andric const void* memchr(const void* s, int c, size_t n); 360b57cec5SDimitry Andric void* memchr( void* s, int c, size_t n); 370b57cec5SDimitry Andric const char* strchr(const char* s, int c); 380b57cec5SDimitry Andric char* strchr( char* s, int c); 390b57cec5SDimitry Andric size_t strcspn(const char* s1, const char* s2); 400b57cec5SDimitry Andric const char* strpbrk(const char* s1, const char* s2); 410b57cec5SDimitry Andric char* strpbrk( char* s1, const char* s2); 420b57cec5SDimitry Andric const char* strrchr(const char* s, int c); 430b57cec5SDimitry Andric char* strrchr( char* s, int c); 440b57cec5SDimitry Andric size_t strspn(const char* s1, const char* s2); 450b57cec5SDimitry Andric const char* strstr(const char* s1, const char* s2); 460b57cec5SDimitry Andric char* strstr( char* s1, const char* s2); 470b57cec5SDimitry Andric char* strtok(char* restrict s1, const char* restrict s2); 480b57cec5SDimitry Andric void* memset(void* s, int c, size_t n); 490b57cec5SDimitry Andric char* strerror(int errnum); 500b57cec5SDimitry Andric size_t strlen(const char* s); 510b57cec5SDimitry Andric 520b57cec5SDimitry Andric */ 530b57cec5SDimitry Andric 540b57cec5SDimitry Andric #include <__config> 550b57cec5SDimitry Andric 560b57cec5SDimitry Andric #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 570b57cec5SDimitry Andric # pragma GCC system_header 580b57cec5SDimitry Andric #endif 590b57cec5SDimitry Andric 60bdd1243dSDimitry Andric #if __has_include_next(<string.h>) 610b57cec5SDimitry Andric # include_next <string.h> 62bdd1243dSDimitry Andric #endif 630b57cec5SDimitry Andric 640b57cec5SDimitry Andric // MSVCRT, GNU libc and its derivates may already have the correct prototype in 650b57cec5SDimitry Andric // <string.h>. This macro can be defined by users if their C library provides 660b57cec5SDimitry Andric // the right signature. 67*06c3fb27SDimitry Andric #if defined(__CORRECT_ISO_CPP_STRING_H_PROTO) || defined(_LIBCPP_MSVCRT) || defined(_STRING_H_CPLUSPLUS_98_CONFORMANCE_) 680b57cec5SDimitry Andric #define _LIBCPP_STRING_H_HAS_CONST_OVERLOADS 690b57cec5SDimitry Andric #endif 700b57cec5SDimitry Andric 710b57cec5SDimitry Andric #if defined(__cplusplus) && !defined(_LIBCPP_STRING_H_HAS_CONST_OVERLOADS) && defined(_LIBCPP_PREFERRED_OVERLOAD) 720b57cec5SDimitry Andric extern "C++" { 73bdd1243dSDimitry Andric inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_PREFERRED_OVERLOAD const char* strchr(const char* __s, int __c) { 74bdd1243dSDimitry Andric return __builtin_strchr(__s, __c); 750b57cec5SDimitry Andric } 76bdd1243dSDimitry Andric inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_PREFERRED_OVERLOAD char* strchr(char* __s, int __c) { 77bdd1243dSDimitry Andric return __builtin_strchr(__s, __c); 78bdd1243dSDimitry Andric } 79bdd1243dSDimitry Andric 80bdd1243dSDimitry Andric inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_PREFERRED_OVERLOAD const char* strpbrk(const char* __s1, const char* __s2) { 81bdd1243dSDimitry Andric return __builtin_strpbrk(__s1, __s2); 82bdd1243dSDimitry Andric } 83bdd1243dSDimitry Andric inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_PREFERRED_OVERLOAD char* strpbrk(char* __s1, const char* __s2) { 84bdd1243dSDimitry Andric return __builtin_strpbrk(__s1, __s2); 85bdd1243dSDimitry Andric } 86bdd1243dSDimitry Andric 87bdd1243dSDimitry Andric inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_PREFERRED_OVERLOAD const char* strrchr(const char* __s, int __c) { 88bdd1243dSDimitry Andric return __builtin_strrchr(__s, __c); 89bdd1243dSDimitry Andric } 90bdd1243dSDimitry Andric inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_PREFERRED_OVERLOAD char* strrchr(char* __s, int __c) { 91bdd1243dSDimitry Andric return __builtin_strrchr(__s, __c); 92bdd1243dSDimitry Andric } 93bdd1243dSDimitry Andric 94bdd1243dSDimitry Andric inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_PREFERRED_OVERLOAD const void* memchr(const void* __s, int __c, size_t __n) { 95bdd1243dSDimitry Andric return __builtin_memchr(__s, __c, __n); 96bdd1243dSDimitry Andric } 97bdd1243dSDimitry Andric inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_PREFERRED_OVERLOAD void* memchr(void* __s, int __c, size_t __n) { 98bdd1243dSDimitry Andric return __builtin_memchr(__s, __c, __n); 99bdd1243dSDimitry Andric } 100bdd1243dSDimitry Andric 101bdd1243dSDimitry Andric inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_PREFERRED_OVERLOAD const char* strstr(const char* __s1, const char* __s2) { 102bdd1243dSDimitry Andric return __builtin_strstr(__s1, __s2); 103bdd1243dSDimitry Andric } 104bdd1243dSDimitry Andric inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_PREFERRED_OVERLOAD char* strstr(char* __s1, const char* __s2) { 105bdd1243dSDimitry Andric return __builtin_strstr(__s1, __s2); 106bdd1243dSDimitry Andric } 107bdd1243dSDimitry Andric } // extern "C++" 1080b57cec5SDimitry Andric #endif 1090b57cec5SDimitry Andric 1100b57cec5SDimitry Andric #endif // _LIBCPP_STRING_H 111