blob: d3659b36179290ae90ec32468a879530b7a9acd1 [file] [log] [blame]
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001// -*- C++ -*-
2//===--------------------------- cstring ----------------------------------===//
3//
Howard Hinnantf5256e12010-05-11 21:36:01 +00004// The LLVM Compiler Infrastructure
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00005//
6// This file is distributed under the University of Illinois Open Source
7// License. See LICENSE.TXT for details.
8//
9//===----------------------------------------------------------------------===//
10
11#ifndef _LIBCPP_CSTRING
12#define _LIBCPP_CSTRING
13
14/*
15 cstring synopsis
16
17Macros:
18
19 NULL
Howard Hinnant324bb032010-08-22 00:02:43 +000020
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000021namespace std
22{
23
24Types:
25
26 size_t
27
28void* memcpy(void* restrict s1, const void* restrict s2, size_t n);
29void* memmove(void* s1, const void* s2, size_t n);
30char* strcpy (char* restrict s1, const char* restrict s2);
31char* strncpy(char* restrict s1, const char* restrict s2, size_t n);
32char* strcat (char* restrict s1, const char* restrict s2);
33char* strncat(char* restrict s1, const char* restrict s2, size_t n);
34int memcmp(const void* s1, const void* s2, size_t n);
35int strcmp (const char* s1, const char* s2);
36int strncmp(const char* s1, const char* s2, size_t n);
37int strcoll(const char* s1, const char* s2);
38size_t strxfrm(char* restrict s1, const char* restrict s2, size_t n);
39const void* memchr(const void* s, int c, size_t n);
40 void* memchr( void* s, int c, size_t n);
41const char* strchr(const char* s, int c);
42 char* strchr( char* s, int c);
43size_t strcspn(const char* s1, const char* s2);
44const char* strpbrk(const char* s1, const char* s2);
45 char* strpbrk( char* s1, const char* s2);
46const char* strrchr(const char* s, int c);
47 char* strrchr( char* s, int c);
48size_t strspn(const char* s1, const char* s2);
49const char* strstr(const char* s1, const char* s2);
50 char* strstr( char* s1, const char* s2);
51char* strtok(char* restrict s1, const char* restrict s2);
52void* memset(void* s, int c, size_t n);
53char* strerror(int errnum);
54size_t strlen(const char* s);
55
56} // std
57
58*/
59
60#include <__config>
61#include <string.h>
62
Howard Hinnant08e17472011-10-17 20:05:10 +000063#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000064#pragma GCC system_header
Howard Hinnant08e17472011-10-17 20:05:10 +000065#endif
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000066
67_LIBCPP_BEGIN_NAMESPACE_STD
68
69using ::size_t;
Marshall Clow22f6c052015-06-02 22:25:23 +000070
71// using ::memcpy;
72inline _LIBCPP_INLINE_VISIBILITY
73void* memcpy(void* __s1, const void* __s2, size_t __n) __attribute__((nonnull(1, 2)))
74{ return ::memcpy(__s1, __s2, __n); }
75
76// using ::memmove;
77inline _LIBCPP_INLINE_VISIBILITY
78void* memmove(void* __s1, const void* __s2, size_t __n) __attribute__((nonnull(1, 2)))
79{ return ::memmove(__s1, __s2, __n); }
80
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000081using ::strcpy;
82using ::strncpy;
83using ::strcat;
84using ::strncat;
Marshall Clow22f6c052015-06-02 22:25:23 +000085
86// using ::memcmp;
87inline _LIBCPP_INLINE_VISIBILITY
88int memcmp(const void* __s1, const void* __s2, size_t __n) __attribute__((nonnull(1, 2)))
89{ return ::memcmp(__s1, __s2, __n); }
90
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000091using ::strcmp;
Marshall Clow22f6c052015-06-02 22:25:23 +000092
93// using ::strncmp;
94inline _LIBCPP_INLINE_VISIBILITY
95int strncmp(const char* __s1, const char* __s2, size_t __n) __attribute__((nonnull(1, 2)))
96{ return ::memcmp(__s1, __s2, __n); }
97
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000098using ::strcoll;
99using ::strxfrm;
100
Howard Hinnant0a68a4d2010-08-10 21:57:23 +0000101using ::memchr;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000102
Howard Hinnant0a68a4d2010-08-10 21:57:23 +0000103using ::strchr;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000104
105using ::strcspn;
106
Howard Hinnant0a68a4d2010-08-10 21:57:23 +0000107using ::strpbrk;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000108
Howard Hinnant0a68a4d2010-08-10 21:57:23 +0000109using ::strrchr;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000110
111using ::strspn;
112
Howard Hinnant0a68a4d2010-08-10 21:57:23 +0000113using ::strstr;
Howard Hinnant81772072010-10-14 17:11:39 +0000114
Howard Hinnante9df0a52013-08-01 18:17:34 +0000115// MSVCRT, GNU libc and its derivates already have the correct prototype in <string.h> #ifdef __cplusplus
116#if !defined(__GLIBC__) && !defined(_LIBCPP_MSVCRT) && !defined(__sun__) && !defined(_STRING_H_CPLUSPLUS_98_CONFORMANCE_)
Howard Hinnant81772072010-10-14 17:11:39 +0000117inline _LIBCPP_INLINE_VISIBILITY char* strchr( char* __s, int __c) {return ::strchr(__s, __c);}
118inline _LIBCPP_INLINE_VISIBILITY char* strpbrk( char* __s1, const char* __s2) {return ::strpbrk(__s1, __s2);}
119inline _LIBCPP_INLINE_VISIBILITY char* strrchr( char* __s, int __c) {return ::strrchr(__s, __c);}
120inline _LIBCPP_INLINE_VISIBILITY void* memchr( void* __s, int __c, size_t __n) {return ::memchr(__s, __c, __n);}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000121inline _LIBCPP_INLINE_VISIBILITY char* strstr( char* __s1, const char* __s2) {return ::strstr(__s1, __s2);}
Howard Hinnant81772072010-10-14 17:11:39 +0000122#endif
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000123
124using ::strtok;
125using ::memset;
126using ::strerror;
127using ::strlen;
128
129_LIBCPP_END_NAMESPACE_STD
130
131#endif // _LIBCPP_CSTRING