* include/c_std/bits/std_cstring.h: #define away all global
[official-gcc.git] / libstdc++-v3 / include / c_std / bits / std_cstring.h
blob08c7b023ee3aceba9d9edc896554b1a9a8f43e6e
1 // -*- C++ -*- forwarding header.
3 // Copyright (C) 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
4 //
5 // This file is part of the GNU ISO C++ Library. This library is free
6 // software; you can redistribute it and/or modify it under the
7 // terms of the GNU General Public License as published by the
8 // Free Software Foundation; either version 2, or (at your option)
9 // 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.
16 // You should have received a copy of the GNU General Public License along
17 // with this library; see the file COPYING. If not, write to the Free
18 // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
19 // USA.
21 // As a special exception, you may use this file as part of a free software
22 // library without restriction. Specifically, if other files instantiate
23 // templates or use macros or inline functions from this file, or you compile
24 // this file and link it with other files to produce an executable, this
25 // file does not by itself cause the resulting executable to be covered by
26 // the GNU General Public License. This exception does not however
27 // invalidate any other reasons why the executable file might be covered by
28 // the GNU General Public License.
31 // ISO C++ 14882: 20.4.6 C library
34 // Note: This is not a conforming implementation.
36 #ifndef _CPP_CSTRING
37 #define _CPP_CSTRING 1
39 #include <bits/c++config.h>
40 #include <bits/std_cstddef.h>
43 // Need to mangle these "C" functions because C++ modifies their signature.
44 #define memcpy __glibcpp_memcpy
45 #define memmove __glibcpp_memmove
46 #define strcpy __glibcpp_strcpy
47 #define strncpy __glibcpp_strncpy
48 #define strcat __glibcpp_strcat
49 #define strncat __glibcpp_strncat
50 #define memcmp __glibcpp_memcmp
51 #define strcmp __glibcpp_strcmp
52 #define strcoll __glibcpp_strcoll
53 #define strncmp __glibcpp_strncmp
54 #define strxfrm __glibcpp_strxfrm
55 #define memchr __glibcpp_memchr
56 #define strchr __glibcpp_strchr
57 #define strcspn __glibcpp_strcspn
58 #define strpbrk __glibcpp_strpbrk
59 #define strrchr __glibcpp_strrchr
60 #define strspn __glibcpp_strspn
61 #define strstr __glibcpp_strstr
62 #define strtok __glibcpp_strtok
63 #define memset __glibcpp_memset
64 #define strerror __glibcpp_strerror
65 #define strlen __glibcpp_strlen
67 #pragma GCC system_header
68 #include <string.h>
70 // Get rid of those macros defined in <string.h> in lieu of real functions.
71 #undef memcpy
72 #undef memmove
73 #undef strcpy
74 #undef strncpy
75 #undef strcat
76 #undef strncat
77 #undef memcmp
78 #undef strcmp
79 #undef strcoll
80 #undef strncmp
81 #undef strxfrm
82 #undef memchr
83 #undef strchr
84 #undef strcspn
85 #undef strpbrk
86 #undef strrchr
87 #undef strspn
88 #undef strstr
89 #undef strtok
90 #undef memset
91 #undef strerror
92 #undef strlen
94 namespace std
96 inline void*
97 memcpy(void* __p1, const void* __p2, size_t __n)
98 { return __builtin_memcpy(__p1, __p2, __n); }
100 extern "C" void* memmove(void*, const void*, size_t);
102 inline char*
103 strcpy(char* __s1, const char* __s2)
104 { return __builtin_strcpy(__s1, __s2); }
106 inline char*
107 strncpy(char* __s1, const char* __s2, size_t __n)
108 { return __builtin_strncpy(__s1, __s2, __n); }
110 inline char*
111 strcat(char* __s1, const char* __s2)
112 { return __builtin_strcat(__s1, __s2); }
114 inline char*
115 strncat(char* __s1, const char* __s2, size_t __n)
116 { return __builtin_strncat(__s1, __s2, __n); }
118 inline int
119 memcmp(const void* __p1, const void* __p2, size_t __n)
120 { return __builtin_memcmp(__p1, __p2, __n); }
122 inline int
123 strcmp(const char* __s1, const char* __s2)
124 { return __builtin_strcmp(__s1, __s2); }
126 extern "C" int strcoll(const char*, const char*);
128 inline int
129 strncmp(const char* __s1, const char* __s2, size_t __n)
130 { return __builtin_strncmp(__s1, __s2, __n); }
132 extern "C" size_t strxfrm(char*, const char*, size_t);
133 extern "C" const void* memchr(const void*, int, size_t);
135 inline void*
136 memchr(void* __p, int __c, size_t __n)
138 return const_cast<void*>(memchr(const_cast<const void*>(__p), __c, __n));
141 inline const char*
142 strchr(const char* __s1, int __n)
143 { return const_cast<const char*>(__builtin_strchr(__s1, __n)); }
145 inline char*
146 strchr(char* __s1, int __n)
148 return
149 const_cast<char*>(__builtin_strchr(const_cast<const char*>(__s1), __n));
152 inline size_t
153 strcspn(const char* __s1, const char* __s2)
154 { return __builtin_strcspn(__s1, __s2); }
156 inline const char*
157 strpbrk(const char* __s1, const char* __s2)
158 { return const_cast<char*>(__builtin_strpbrk(__s1, __s2)); }
160 inline char*
161 strpbrk(char* __s1, const char* __s2)
163 return const_cast<char*>
164 (__builtin_strpbrk(const_cast<const char*>(__s1), __s2));
167 inline const char*
168 strrchr(const char* __s1, int __n)
169 { return const_cast<char*>(__builtin_strrchr(__s1, __n)); }
171 inline char*
172 strrchr(char* __s1, int __n)
173 { return __builtin_strrchr(const_cast<const char*>(__s1), __n); }
175 inline size_t
176 strspn(const char* __s1, const char* __s2)
177 { return __builtin_strspn(__s1, __s2); }
179 inline const char*
180 strstr(const char* __s1, const char* __s2)
181 { return const_cast<char*>(__builtin_strstr (__s1, __s2)); }
183 inline char*
184 strstr(char* __s1, const char* __s2)
186 return (const_cast<char*>
187 (__builtin_strstr(const_cast<const char*>(__s1), __s2)));
190 extern "C" char* strtok(char*, const char*);
192 inline void*
193 memset(void* __p, int __c, size_t __n)
194 { return __builtin_memset(__p, __c, __n); }
196 extern "C" char* strerror(int);
198 inline size_t
199 strlen(const char* __s)
200 { return __builtin_strlen(__s); }
203 #endif