string.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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-exception
  7. //
  8. //===----------------------------------------------------------------------===//
  9. #ifndef _LIBCPP_STRING_H
  10. #define _LIBCPP_STRING_H
  11. /*
  12. string.h synopsis
  13. Macros:
  14. NULL
  15. Types:
  16. size_t
  17. void* memcpy(void* restrict s1, const void* restrict s2, size_t n);
  18. void* memmove(void* s1, const void* s2, size_t n);
  19. char* strcpy (char* restrict s1, const char* restrict s2);
  20. char* strncpy(char* restrict s1, const char* restrict s2, size_t n);
  21. char* strcat (char* restrict s1, const char* restrict s2);
  22. char* strncat(char* restrict s1, const char* restrict s2, size_t n);
  23. int memcmp(const void* s1, const void* s2, size_t n);
  24. int strcmp (const char* s1, const char* s2);
  25. int strncmp(const char* s1, const char* s2, size_t n);
  26. int strcoll(const char* s1, const char* s2);
  27. size_t strxfrm(char* restrict s1, const char* restrict s2, size_t n);
  28. const void* memchr(const void* s, int c, size_t n);
  29. void* memchr( void* s, int c, size_t n);
  30. const char* strchr(const char* s, int c);
  31. char* strchr( char* s, int c);
  32. size_t strcspn(const char* s1, const char* s2);
  33. const char* strpbrk(const char* s1, const char* s2);
  34. char* strpbrk( char* s1, const char* s2);
  35. const char* strrchr(const char* s, int c);
  36. char* strrchr( char* s, int c);
  37. size_t strspn(const char* s1, const char* s2);
  38. const char* strstr(const char* s1, const char* s2);
  39. char* strstr( char* s1, const char* s2);
  40. char* strtok(char* restrict s1, const char* restrict s2);
  41. void* memset(void* s, int c, size_t n);
  42. char* strerror(int errnum);
  43. size_t strlen(const char* s);
  44. */
  45. #include <__config>
  46. #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
  47. # pragma GCC system_header
  48. #endif
  49. #ifdef _LIBCPP_COMPILER_MSVC
  50. #include Y_UCRT_INCLUDE_NEXT(string.h)
  51. #else
  52. #include_next <string.h>
  53. #endif
  54. // MSVCRT, GNU libc and its derivates may already have the correct prototype in
  55. // <string.h>. This macro can be defined by users if their C library provides
  56. // the right signature.
  57. #if defined(__CORRECT_ISO_CPP_STRING_H_PROTO) || defined(_LIBCPP_MSVCRT) || \
  58. defined(__sun__) || defined(_STRING_H_CPLUSPLUS_98_CONFORMANCE_)
  59. #define _LIBCPP_STRING_H_HAS_CONST_OVERLOADS
  60. #endif
  61. #if defined(__cplusplus) && !defined(_LIBCPP_STRING_H_HAS_CONST_OVERLOADS) && defined(_LIBCPP_PREFERRED_OVERLOAD)
  62. extern "C++" {
  63. inline _LIBCPP_INLINE_VISIBILITY
  64. char* __libcpp_strchr(const char* __s, int __c) {return (char*)strchr(__s, __c);}
  65. inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD
  66. const char* strchr(const char* __s, int __c) {return __libcpp_strchr(__s, __c);}
  67. inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD
  68. char* strchr( char* __s, int __c) {return __libcpp_strchr(__s, __c);}
  69. inline _LIBCPP_INLINE_VISIBILITY
  70. char* __libcpp_strpbrk(const char* __s1, const char* __s2) {return (char*)strpbrk(__s1, __s2);}
  71. inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD
  72. const char* strpbrk(const char* __s1, const char* __s2) {return __libcpp_strpbrk(__s1, __s2);}
  73. inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD
  74. char* strpbrk( char* __s1, const char* __s2) {return __libcpp_strpbrk(__s1, __s2);}
  75. inline _LIBCPP_INLINE_VISIBILITY
  76. char* __libcpp_strrchr(const char* __s, int __c) {return (char*)strrchr(__s, __c);}
  77. inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD
  78. const char* strrchr(const char* __s, int __c) {return __libcpp_strrchr(__s, __c);}
  79. inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD
  80. char* strrchr( char* __s, int __c) {return __libcpp_strrchr(__s, __c);}
  81. inline _LIBCPP_INLINE_VISIBILITY
  82. void* __libcpp_memchr(const void* __s, int __c, size_t __n) {return (void*)memchr(__s, __c, __n);}
  83. inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD
  84. const void* memchr(const void* __s, int __c, size_t __n) {return __libcpp_memchr(__s, __c, __n);}
  85. inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD
  86. void* memchr( void* __s, int __c, size_t __n) {return __libcpp_memchr(__s, __c, __n);}
  87. inline _LIBCPP_INLINE_VISIBILITY
  88. char* __libcpp_strstr(const char* __s1, const char* __s2) {return (char*)strstr(__s1, __s2);}
  89. inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD
  90. const char* strstr(const char* __s1, const char* __s2) {return __libcpp_strstr(__s1, __s2);}
  91. inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD
  92. char* strstr( char* __s1, const char* __s2) {return __libcpp_strstr(__s1, __s2);}
  93. }
  94. #endif
  95. #endif // _LIBCPP_STRING_H