Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1 | // -*- C++ -*- |
| 2 | //===--------------------------- cstring ----------------------------------===// |
| 3 | // |
Howard Hinnant | f5256e1 | 2010-05-11 21:36:01 +0000 | [diff] [blame] | 4 | // The LLVM Compiler Infrastructure |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 5 | // |
| 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 | |
| 17 | Macros: |
| 18 | |
| 19 | NULL |
Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 20 | |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 21 | namespace std |
| 22 | { |
| 23 | |
| 24 | Types: |
| 25 | |
| 26 | size_t |
| 27 | |
| 28 | void* memcpy(void* restrict s1, const void* restrict s2, size_t n); |
| 29 | void* memmove(void* s1, const void* s2, size_t n); |
| 30 | char* strcpy (char* restrict s1, const char* restrict s2); |
| 31 | char* strncpy(char* restrict s1, const char* restrict s2, size_t n); |
| 32 | char* strcat (char* restrict s1, const char* restrict s2); |
| 33 | char* strncat(char* restrict s1, const char* restrict s2, size_t n); |
| 34 | int memcmp(const void* s1, const void* s2, size_t n); |
| 35 | int strcmp (const char* s1, const char* s2); |
| 36 | int strncmp(const char* s1, const char* s2, size_t n); |
| 37 | int strcoll(const char* s1, const char* s2); |
| 38 | size_t strxfrm(char* restrict s1, const char* restrict s2, size_t n); |
| 39 | const void* memchr(const void* s, int c, size_t n); |
| 40 | void* memchr( void* s, int c, size_t n); |
| 41 | const char* strchr(const char* s, int c); |
| 42 | char* strchr( char* s, int c); |
| 43 | size_t strcspn(const char* s1, const char* s2); |
| 44 | const char* strpbrk(const char* s1, const char* s2); |
| 45 | char* strpbrk( char* s1, const char* s2); |
| 46 | const char* strrchr(const char* s, int c); |
| 47 | char* strrchr( char* s, int c); |
| 48 | size_t strspn(const char* s1, const char* s2); |
| 49 | const char* strstr(const char* s1, const char* s2); |
| 50 | char* strstr( char* s1, const char* s2); |
| 51 | char* strtok(char* restrict s1, const char* restrict s2); |
| 52 | void* memset(void* s, int c, size_t n); |
| 53 | char* strerror(int errnum); |
| 54 | size_t strlen(const char* s); |
| 55 | |
| 56 | } // std |
| 57 | |
| 58 | */ |
| 59 | |
| 60 | #include <__config> |
| 61 | #include <string.h> |
| 62 | |
Howard Hinnant | 08e1747 | 2011-10-17 20:05:10 +0000 | [diff] [blame] | 63 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 64 | #pragma GCC system_header |
Howard Hinnant | 08e1747 | 2011-10-17 20:05:10 +0000 | [diff] [blame] | 65 | #endif |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 66 | |
| 67 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 68 | |
| 69 | using ::size_t; |
Marshall Clow | 22f6c05 | 2015-06-02 22:25:23 +0000 | [diff] [blame^] | 70 | |
| 71 | // using ::memcpy; |
| 72 | inline _LIBCPP_INLINE_VISIBILITY |
| 73 | void* memcpy(void* __s1, const void* __s2, size_t __n) __attribute__((nonnull(1, 2))) |
| 74 | { return ::memcpy(__s1, __s2, __n); } |
| 75 | |
| 76 | // using ::memmove; |
| 77 | inline _LIBCPP_INLINE_VISIBILITY |
| 78 | void* memmove(void* __s1, const void* __s2, size_t __n) __attribute__((nonnull(1, 2))) |
| 79 | { return ::memmove(__s1, __s2, __n); } |
| 80 | |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 81 | using ::strcpy; |
| 82 | using ::strncpy; |
| 83 | using ::strcat; |
| 84 | using ::strncat; |
Marshall Clow | 22f6c05 | 2015-06-02 22:25:23 +0000 | [diff] [blame^] | 85 | |
| 86 | // using ::memcmp; |
| 87 | inline _LIBCPP_INLINE_VISIBILITY |
| 88 | int memcmp(const void* __s1, const void* __s2, size_t __n) __attribute__((nonnull(1, 2))) |
| 89 | { return ::memcmp(__s1, __s2, __n); } |
| 90 | |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 91 | using ::strcmp; |
Marshall Clow | 22f6c05 | 2015-06-02 22:25:23 +0000 | [diff] [blame^] | 92 | |
| 93 | // using ::strncmp; |
| 94 | inline _LIBCPP_INLINE_VISIBILITY |
| 95 | int strncmp(const char* __s1, const char* __s2, size_t __n) __attribute__((nonnull(1, 2))) |
| 96 | { return ::memcmp(__s1, __s2, __n); } |
| 97 | |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 98 | using ::strcoll; |
| 99 | using ::strxfrm; |
| 100 | |
Howard Hinnant | 0a68a4d | 2010-08-10 21:57:23 +0000 | [diff] [blame] | 101 | using ::memchr; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 102 | |
Howard Hinnant | 0a68a4d | 2010-08-10 21:57:23 +0000 | [diff] [blame] | 103 | using ::strchr; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 104 | |
| 105 | using ::strcspn; |
| 106 | |
Howard Hinnant | 0a68a4d | 2010-08-10 21:57:23 +0000 | [diff] [blame] | 107 | using ::strpbrk; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 108 | |
Howard Hinnant | 0a68a4d | 2010-08-10 21:57:23 +0000 | [diff] [blame] | 109 | using ::strrchr; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 110 | |
| 111 | using ::strspn; |
| 112 | |
Howard Hinnant | 0a68a4d | 2010-08-10 21:57:23 +0000 | [diff] [blame] | 113 | using ::strstr; |
Howard Hinnant | 8177207 | 2010-10-14 17:11:39 +0000 | [diff] [blame] | 114 | |
Howard Hinnant | e9df0a5 | 2013-08-01 18:17:34 +0000 | [diff] [blame] | 115 | // 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 Hinnant | 8177207 | 2010-10-14 17:11:39 +0000 | [diff] [blame] | 117 | inline _LIBCPP_INLINE_VISIBILITY char* strchr( char* __s, int __c) {return ::strchr(__s, __c);} |
| 118 | inline _LIBCPP_INLINE_VISIBILITY char* strpbrk( char* __s1, const char* __s2) {return ::strpbrk(__s1, __s2);} |
| 119 | inline _LIBCPP_INLINE_VISIBILITY char* strrchr( char* __s, int __c) {return ::strrchr(__s, __c);} |
| 120 | inline _LIBCPP_INLINE_VISIBILITY void* memchr( void* __s, int __c, size_t __n) {return ::memchr(__s, __c, __n);} |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 121 | inline _LIBCPP_INLINE_VISIBILITY char* strstr( char* __s1, const char* __s2) {return ::strstr(__s1, __s2);} |
Howard Hinnant | 8177207 | 2010-10-14 17:11:39 +0000 | [diff] [blame] | 122 | #endif |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 123 | |
| 124 | using ::strtok; |
| 125 | using ::memset; |
| 126 | using ::strerror; |
| 127 | using ::strlen; |
| 128 | |
| 129 | _LIBCPP_END_NAMESPACE_STD |
| 130 | |
| 131 | #endif // _LIBCPP_CSTRING |