cstring 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. // -*- C++ -*- forwarding header.
  2. // Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
  3. // 2006, 2007, 2008, 2009
  4. // Free Software Foundation, Inc.
  5. //
  6. // This file is part of the GNU ISO C++ Library. This library is free
  7. // software; you can redistribute it and/or modify it under the
  8. // terms of the GNU General Public License as published by the
  9. // Free Software Foundation; either version 3, or (at your option)
  10. // any later version.
  11. // This library is distributed in the hope that it will be useful,
  12. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. // GNU General Public License for more details.
  15. // Under Section 7 of GPL version 3, you are granted additional
  16. // permissions described in the GCC Runtime Library Exception, version
  17. // 3.1, as published by the Free Software Foundation.
  18. // You should have received a copy of the GNU General Public License and
  19. // a copy of the GCC Runtime Library Exception along with this program;
  20. // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
  21. // <http://www.gnu.org/licenses/>.
  22. /** @file cstring
  23. * This is a Standard C++ Library file. You should @c #include this file
  24. * in your programs, rather than any of the "*.h" implementation files.
  25. *
  26. * This is the C++ version of the Standard C Library header @c string.h,
  27. * and its contents are (mostly) the same as that header, but are all
  28. * contained in the namespace @c std (except for names which are defined
  29. * as macros in C).
  30. */
  31. //
  32. // ISO C++ 14882: 20.4.6 C library
  33. //
  34. #pragma GCC system_header
  35. #include <bits/c++config.h>
  36. #include <cstddef>
  37. #include <string.h>
  38. #ifndef _GLIBCXX_CSTRING
  39. #define _GLIBCXX_CSTRING 1
  40. // Get rid of those macros defined in <string.h> in lieu of real functions.
  41. #undef memchr
  42. #undef memcmp
  43. #undef memcpy
  44. #undef memmove
  45. #undef memset
  46. #undef strcat
  47. #undef strchr
  48. #undef strcmp
  49. #undef strcoll
  50. #undef strcpy
  51. #undef strcspn
  52. #undef strerror
  53. #undef strlen
  54. #undef strncat
  55. #undef strncmp
  56. #undef strncpy
  57. #undef strpbrk
  58. #undef strrchr
  59. #undef strspn
  60. #undef strstr
  61. #undef strtok
  62. #undef strxfrm
  63. _GLIBCXX_BEGIN_NAMESPACE(std)
  64. using ::memchr;
  65. using ::memcmp;
  66. using ::memcpy;
  67. using ::memmove;
  68. using ::memset;
  69. using ::strcat;
  70. using ::strcmp;
  71. using ::strcoll;
  72. using ::strcpy;
  73. using ::strcspn;
  74. using ::strerror;
  75. using ::strlen;
  76. using ::strncat;
  77. using ::strncmp;
  78. using ::strncpy;
  79. using ::strspn;
  80. using ::strtok;
  81. using ::strxfrm;
  82. using ::strchr;
  83. using ::strpbrk;
  84. using ::strrchr;
  85. using ::strstr;
  86. #ifndef __CORRECT_ISO_CPP_STRING_H_PROTO
  87. inline void*
  88. memchr(void* __p, int __c, size_t __n)
  89. { return memchr(const_cast<const void*>(__p), __c, __n); }
  90. inline char*
  91. strchr(char* __s1, int __n)
  92. { return __builtin_strchr(const_cast<const char*>(__s1), __n); }
  93. inline char*
  94. strpbrk(char* __s1, const char* __s2)
  95. { return __builtin_strpbrk(const_cast<const char*>(__s1), __s2); }
  96. inline char*
  97. strrchr(char* __s1, int __n)
  98. { return __builtin_strrchr(const_cast<const char*>(__s1), __n); }
  99. inline char*
  100. strstr(char* __s1, const char* __s2)
  101. { return __builtin_strstr(const_cast<const char*>(__s1), __s2); }
  102. #endif
  103. _GLIBCXX_END_NAMESPACE
  104. #endif