blob: 627cbae781c1310aec0def3a63bec0fac96dd789 [file] [log] [blame]
Richard Smith5827a772016-02-10 00:59:02 +00001// -*- C++ -*-
Louis Dionne9bd93882021-11-17 16:25:01 -05002//===----------------------------------------------------------------------===//
Richard Smith5827a772016-02-10 00:59:02 +00003//
Chandler Carruth7642bb12019-01-19 08:50:56 +00004// 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-exception
Richard Smith5827a772016-02-10 00:59:02 +00007//
8//===----------------------------------------------------------------------===//
9
10#ifndef _LIBCPP_STRING_H
11#define _LIBCPP_STRING_H
12
13/*
14 string.h synopsis
15
16Macros:
17
18 NULL
19
20Types:
21
22 size_t
23
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#include <__config>
55
56#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
Arthur O'Dwyer6eeaa002022-02-01 20:16:40 -050057# pragma GCC system_header
Richard Smith5827a772016-02-10 00:59:02 +000058#endif
59
Louis Dionnebe1aa9e2022-11-15 17:08:01 -050060#if __has_include_next(<string.h>)
61# include_next <string.h>
62#endif
Richard Smith5827a772016-02-10 00:59:02 +000063
Richard Smith763496e2016-02-11 23:51:02 +000064// MSVCRT, GNU libc and its derivates may already have the correct prototype in
65// <string.h>. This macro can be defined by users if their C library provides
66// the right signature.
67#if defined(__CORRECT_ISO_CPP_STRING_H_PROTO) || defined(_LIBCPP_MSVCRT) || \
68 defined(__sun__) || defined(_STRING_H_CPLUSPLUS_98_CONFORMANCE_)
Richard Smith5827a772016-02-10 00:59:02 +000069#define _LIBCPP_STRING_H_HAS_CONST_OVERLOADS
70#endif
71
72#if defined(__cplusplus) && !defined(_LIBCPP_STRING_H_HAS_CONST_OVERLOADS) && defined(_LIBCPP_PREFERRED_OVERLOAD)
73extern "C++" {
74inline _LIBCPP_INLINE_VISIBILITY
75char* __libcpp_strchr(const char* __s, int __c) {return (char*)strchr(__s, __c);}
76inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD
77const char* strchr(const char* __s, int __c) {return __libcpp_strchr(__s, __c);}
78inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD
79 char* strchr( char* __s, int __c) {return __libcpp_strchr(__s, __c);}
80
81inline _LIBCPP_INLINE_VISIBILITY
82char* __libcpp_strpbrk(const char* __s1, const char* __s2) {return (char*)strpbrk(__s1, __s2);}
83inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD
84const char* strpbrk(const char* __s1, const char* __s2) {return __libcpp_strpbrk(__s1, __s2);}
85inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD
86 char* strpbrk( char* __s1, const char* __s2) {return __libcpp_strpbrk(__s1, __s2);}
87
88inline _LIBCPP_INLINE_VISIBILITY
89char* __libcpp_strrchr(const char* __s, int __c) {return (char*)strrchr(__s, __c);}
90inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD
91const char* strrchr(const char* __s, int __c) {return __libcpp_strrchr(__s, __c);}
92inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD
93 char* strrchr( char* __s, int __c) {return __libcpp_strrchr(__s, __c);}
94
95inline _LIBCPP_INLINE_VISIBILITY
96void* __libcpp_memchr(const void* __s, int __c, size_t __n) {return (void*)memchr(__s, __c, __n);}
97inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD
98const void* memchr(const void* __s, int __c, size_t __n) {return __libcpp_memchr(__s, __c, __n);}
99inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD
100 void* memchr( void* __s, int __c, size_t __n) {return __libcpp_memchr(__s, __c, __n);}
101
102inline _LIBCPP_INLINE_VISIBILITY
103char* __libcpp_strstr(const char* __s1, const char* __s2) {return (char*)strstr(__s1, __s2);}
104inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD
105const char* strstr(const char* __s1, const char* __s2) {return __libcpp_strstr(__s1, __s2);}
106inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD
107 char* strstr( char* __s1, const char* __s2) {return __libcpp_strstr(__s1, __s2);}
108}
109#endif
110
Louis Dionne2b1ceaa2021-04-20 12:03:32 -0400111#endif // _LIBCPP_STRING_H