cstring 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. // -*- C++ -*-
  2. //===--------------------------- cstring ----------------------------------===//
  3. //
  4. // The LLVM Compiler Infrastructure
  5. //
  6. // This file is distributed under the University of Illinois Open Source
  7. // License. See LICENSE.TXT for details.
  8. //
  9. //===----------------------------------------------------------------------===//
  10. #ifndef _LIBCPP_CSTRING
  11. #define _LIBCPP_CSTRING
  12. /*
  13. cstring synopsis
  14. Macros:
  15. NULL
  16. namespace std
  17. {
  18. Types:
  19. size_t
  20. void* memcpy(void* restrict s1, const void* restrict s2, size_t n);
  21. void* memmove(void* s1, const void* s2, size_t n);
  22. char* strcpy (char* restrict s1, const char* restrict s2);
  23. char* strncpy(char* restrict s1, const char* restrict s2, size_t n);
  24. char* strcat (char* restrict s1, const char* restrict s2);
  25. char* strncat(char* restrict s1, const char* restrict s2, size_t n);
  26. int memcmp(const void* s1, const void* s2, size_t n);
  27. int strcmp (const char* s1, const char* s2);
  28. int strncmp(const char* s1, const char* s2, size_t n);
  29. int strcoll(const char* s1, const char* s2);
  30. size_t strxfrm(char* restrict s1, const char* restrict s2, size_t n);
  31. const void* memchr(const void* s, int c, size_t n);
  32. void* memchr( void* s, int c, size_t n);
  33. const char* strchr(const char* s, int c);
  34. char* strchr( char* s, int c);
  35. size_t strcspn(const char* s1, const char* s2);
  36. const char* strpbrk(const char* s1, const char* s2);
  37. char* strpbrk( char* s1, const char* s2);
  38. const char* strrchr(const char* s, int c);
  39. char* strrchr( char* s, int c);
  40. size_t strspn(const char* s1, const char* s2);
  41. const char* strstr(const char* s1, const char* s2);
  42. char* strstr( char* s1, const char* s2);
  43. char* strtok(char* restrict s1, const char* restrict s2);
  44. void* memset(void* s, int c, size_t n);
  45. char* strerror(int errnum);
  46. size_t strlen(const char* s);
  47. } // std
  48. */
  49. #include <__config>
  50. #include <string.h>
  51. #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
  52. #pragma GCC system_header
  53. #endif
  54. _LIBCPP_BEGIN_NAMESPACE_STD
  55. using ::size_t;
  56. using ::memcpy;
  57. using ::memmove;
  58. #if !defined(_LIBCPP_SGX_CONFIG)
  59. using ::strcpy;
  60. #endif
  61. using ::strncpy;
  62. #if !defined(_LIBCPP_SGX_CONFIG)
  63. using ::strcat;
  64. #endif
  65. using ::strncat;
  66. using ::memcmp;
  67. using ::strcmp;
  68. using ::strncmp;
  69. using ::strcoll;
  70. using ::strxfrm;
  71. using ::memchr;
  72. using ::strchr;
  73. using ::strcspn;
  74. using ::strpbrk;
  75. using ::strrchr;
  76. using ::strspn;
  77. using ::strstr;
  78. // MSVCRT, GNU libc and its derivates already have the correct prototype in <string.h> #ifdef __cplusplus
  79. #if !defined(__GLIBC__) && !defined(_LIBCPP_MSVCRT) && !defined(__sun__) && !defined(_STRING_H_CPLUSPLUS_98_CONFORMANCE_)
  80. inline _LIBCPP_INLINE_VISIBILITY char* strchr( char* __s, int __c) {return ::strchr(__s, __c);}
  81. inline _LIBCPP_INLINE_VISIBILITY char* strpbrk( char* __s1, const char* __s2) {return ::strpbrk(__s1, __s2);}
  82. inline _LIBCPP_INLINE_VISIBILITY char* strrchr( char* __s, int __c) {return ::strrchr(__s, __c);}
  83. inline _LIBCPP_INLINE_VISIBILITY void* memchr( void* __s, int __c, size_t __n) {return ::memchr(__s, __c, __n);}
  84. inline _LIBCPP_INLINE_VISIBILITY char* strstr( char* __s1, const char* __s2) {return ::strstr(__s1, __s2);}
  85. #endif
  86. #ifndef _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS
  87. using ::strtok;
  88. #endif
  89. using ::memset;
  90. using ::strerror;
  91. using ::strlen;
  92. _LIBCPP_END_NAMESPACE_STD
  93. #endif // _LIBCPP_CSTRING