]>
Commit | Line | Data |
---|---|---|
98e6e789 | 1 | // -*- C++ -*- forwarding header. |
22aef514 | 2 | |
7b331228 | 3 | // Copyright (C) 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc. |
22aef514 BK |
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. | |
10 | ||
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 | ||
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. | |
20 | ||
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. | |
29 | ||
30 | // | |
31 | // ISO C++ 14882: 20.4.6 C library | |
32 | // | |
33 | ||
98e6e789 BK |
34 | // Note: This is not a conforming implementation. |
35 | ||
22aef514 BK |
36 | #ifndef _CPP_CSTRING |
37 | #define _CPP_CSTRING 1 | |
38 | ||
98e6e789 | 39 | #include <bits/c++config.h> |
7b331228 | 40 | #include <bits/std_cstddef.h> |
98e6e789 | 41 | |
9ea659ac BK |
42 | |
43 | // Need to mangle these "C" functions because C++ modifies their signature. | |
eeff8d2c MM |
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 | |
9ea659ac BK |
58 | #define strpbrk __glibcpp_strpbrk |
59 | #define strrchr __glibcpp_strrchr | |
eeff8d2c MM |
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 | |
9ea659ac | 66 | |
98e6e789 BK |
67 | #pragma GCC system_header |
68 | #include <string.h> | |
69 | ||
8089616e BK |
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 | |
93 | ||
98e6e789 BK |
94 | namespace std |
95 | { | |
eeff8d2c MM |
96 | inline void* |
97 | memcpy(void* __p1, const void* __p2, size_t __n) | |
98 | { return __builtin_memcpy(__p1, __p2, __n); } | |
99 | ||
98e6e789 | 100 | extern "C" void* memmove(void*, const void*, size_t); |
eeff8d2c MM |
101 | |
102 | inline char* | |
103 | strcpy(char* __s1, const char* __s2) | |
104 | { return __builtin_strcpy(__s1, __s2); } | |
105 | ||
106 | inline char* | |
107 | strncpy(char* __s1, const char* __s2, size_t __n) | |
108 | { return __builtin_strncpy(__s1, __s2, __n); } | |
109 | ||
110 | inline char* | |
111 | strcat(char* __s1, const char* __s2) | |
112 | { return __builtin_strcat(__s1, __s2); } | |
113 | ||
114 | inline char* | |
115 | strncat(char* __s1, const char* __s2, size_t __n) | |
116 | { return __builtin_strncat(__s1, __s2, __n); } | |
117 | ||
118 | inline int | |
119 | memcmp(const void* __p1, const void* __p2, size_t __n) | |
120 | { return __builtin_memcmp(__p1, __p2, __n); } | |
121 | ||
122 | inline int | |
123 | strcmp(const char* __s1, const char* __s2) | |
124 | { return __builtin_strcmp(__s1, __s2); } | |
125 | ||
98e6e789 | 126 | extern "C" int strcoll(const char*, const char*); |
eeff8d2c MM |
127 | |
128 | inline int | |
129 | strncmp(const char* __s1, const char* __s2, size_t __n) | |
130 | { return __builtin_strncmp(__s1, __s2, __n); } | |
131 | ||
98e6e789 | 132 | extern "C" size_t strxfrm(char*, const char*, size_t); |
9ea659ac | 133 | extern "C" const void* memchr(const void*, int, size_t); |
eeff8d2c | 134 | |
92c3688a SW |
135 | inline void* |
136 | memchr(void* __p, int __c, size_t __n) | |
9ea659ac BK |
137 | { |
138 | return const_cast<void*>(memchr(const_cast<const void*>(__p), __c, __n)); | |
139 | } | |
eeff8d2c MM |
140 | |
141 | inline const char* | |
142 | strchr(const char* __s1, int __n) | |
143 | { return const_cast<const char*>(__builtin_strchr(__s1, __n)); } | |
144 | ||
92c3688a SW |
145 | inline char* |
146 | strchr(char* __s1, int __n) | |
9ea659ac | 147 | { |
eeff8d2c MM |
148 | return |
149 | const_cast<char*>(__builtin_strchr(const_cast<const char*>(__s1), __n)); | |
9ea659ac | 150 | } |
eeff8d2c MM |
151 | |
152 | inline size_t | |
153 | strcspn(const char* __s1, const char* __s2) | |
154 | { return __builtin_strcspn(__s1, __s2); } | |
155 | ||
156 | inline const char* | |
157 | strpbrk(const char* __s1, const char* __s2) | |
158 | { return const_cast<char*>(__builtin_strpbrk(__s1, __s2)); } | |
159 | ||
92c3688a SW |
160 | inline char* |
161 | strpbrk(char* __s1, const char* __s2) | |
9ea659ac | 162 | { |
eeff8d2c MM |
163 | return const_cast<char*> |
164 | (__builtin_strpbrk(const_cast<const char*>(__s1), __s2)); | |
9ea659ac | 165 | } |
eeff8d2c MM |
166 | |
167 | inline const char* | |
168 | strrchr(const char* __s1, int __n) | |
169 | { return const_cast<char*>(__builtin_strrchr(__s1, __n)); } | |
170 | ||
92c3688a SW |
171 | inline char* |
172 | strrchr(char* __s1, int __n) | |
eeff8d2c MM |
173 | { return __builtin_strrchr(const_cast<const char*>(__s1), __n); } |
174 | ||
175 | inline size_t | |
176 | strspn(const char* __s1, const char* __s2) | |
177 | { return __builtin_strspn(__s1, __s2); } | |
178 | ||
179 | inline const char* | |
180 | strstr(const char* __s1, const char* __s2) | |
181 | { return const_cast<char*>(__builtin_strstr (__s1, __s2)); } | |
182 | ||
92c3688a SW |
183 | inline char* |
184 | strstr(char* __s1, const char* __s2) | |
9ea659ac | 185 | { |
eeff8d2c MM |
186 | return (const_cast<char*> |
187 | (__builtin_strstr(const_cast<const char*>(__s1), __s2))); | |
9ea659ac | 188 | } |
eeff8d2c | 189 | |
98e6e789 | 190 | extern "C" char* strtok(char*, const char*); |
eeff8d2c MM |
191 | |
192 | inline void* | |
193 | memset(void* __p, int __c, size_t __n) | |
194 | { return __builtin_memset(__p, __c, __n); } | |
195 | ||
98e6e789 | 196 | extern "C" char* strerror(int); |
eeff8d2c MM |
197 | |
198 | inline size_t | |
199 | strlen(const char* __s) | |
200 | { return __builtin_strlen(__s); } | |
98e6e789 | 201 | } |
22aef514 | 202 | |
98e6e789 | 203 | #endif |
22aef514 | 204 | |
22aef514 | 205 | |
22aef514 | 206 |