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