OSDN Git Service

2000-05-17 Nathan C. Myers <ncm@cantrip.org>
[pf3gnuchains/gcc-fork.git] / libstdc++-v3 / shadow / bits / std_cstring.h
1 // -*- C++ -*- header wrapper.
2
3 // Copyright (C) 1997-1999 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.
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
34 #ifndef _CPP_CSTRING
35 #define _CPP_CSTRING 1
36 # if defined __GLIBC__ && __GLIBC__ >= 2
37 // We must not see the optimized string functions GNU libc defines.
38 #  define __NO_STRING_INLINES
39 # endif
40
41 # include <bits/std_cstddef.h>  /* pick up size_t, NULL */
42
43   namespace _C_Swamp {
44     extern "C" {
45 #     define _IN_C_SWAMP_
46 #     pragma system_header
47 #     include_next <string.h>
48     }
49
50     // size_t
51     // NULL
52
53     // We do inline captures of most of these in case they
54     // have been optimized with macros.  
55
56     inline void* _CPP_memcpy_capture(void* __s1, void const* __s2, size_t __n)
57       { return memcpy(__s1,__s2,__n); }
58     inline void* _CPP_memmove_capture(void* __s1, void const* __s2, size_t __n)
59       { return memmove(__s1,__s2,__n); }
60     inline void* _CPP_strcpy_capture(char* __s1, char const* __s2)
61       { return strcpy(__s1,__s2); }
62     inline char* _CPP_strncpy_capture(char* __s1, char const* __s2, size_t __n)
63       { return strncpy(__s1,__s2,__n); }
64     inline char* _CPP_strcat_capture(char* __s1, char const* __s2)
65       { return strcat(__s1,__s2); }
66     inline char* _CPP_strncat_capture(char* __s1, char const* __s2, size_t __n)
67       { return strncat(__s1,__s2,__n); }
68     inline int _CPP_memcmp_capture(void const* __s1, 
69                                    void const* __s2, size_t __n)
70       { return memcmp(__s1,__s2,__n); }
71     inline int _CPP_strcmp_capture(char const* __s1, char const* __s2)
72       { return strcmp(__s1,__s2); }
73     inline int _CPP_strcoll_capture(char const* __s1, char const* __s2)
74       { return strcoll(__s1,__s2); }
75     inline int _CPP_strncmp_capture(char const* __s1, 
76                                     char const* __s2, size_t __n)
77       { return strncmp(__s1,__s2,__n); }
78     inline size_t _CPP_strxfrm_capture(char* __b, char const* __s, size_t __n)
79       { return strxfrm(__b,__s,__n); }
80     inline void* _CPP_memchr_capture(void const* __s1, int __c, size_t __n)
81       { return memchr(__s1,__c,__n); }
82     inline char* _CPP_strchr_capture(char const* __s1, int __c)
83       { return strchr(__s1,__c); }
84     inline size_t _CPP_strcspn_capture(char const* __s1, char const* __s2)
85       { return strcspn(__s1,__s2); }
86     inline char* _CPP_strpbrk_capture(char const* __s1, char const* __s2)
87       { return strpbrk(__s1,__s2); }
88     inline char* _CPP_strrchr_capture(char const* __s1, int __c)
89       { return strrchr(__s1,__c); }
90     inline size_t _CPP_strspn_capture(char const* __s1, char const* __s2)
91       { return strspn(__s1,__s2); }
92     inline char* _CPP_strstr_capture(char const* __s1, char const* __s2)
93       { return strstr(__s1,__s2); }
94     inline char* _CPP_strtok_capture(char* __s1, char const* __s2)
95       { return strtok(__s1,__s2); }
96     inline void* _CPP_memset_capture(void* __s, int __c, size_t __n)
97       { return memset(__s,__c,__n); }
98     // inline char* _CPP_strerror_capture(int __num)
99     //  { return strerror(__num); }
100     inline size_t _CPP_strlen_capture(char const* __s)
101       { return strlen(__s); }
102
103     namespace _C_Shadow { }
104   } // close namespace ::_C_Swamp::
105
106 // size_t, NULL
107 # undef memcpy
108 # undef memmove
109 # undef strcpy
110 # undef strncpy
111 # undef strcat
112 # undef strncat
113 # undef memcmp
114 # undef strcmp
115 # undef strcoll
116 # undef strncmp
117 # undef strxfrm
118 # undef memchr
119 # undef strchr
120 # undef strcspn
121 # undef strpbrk
122 # undef strrchr
123 # undef strspn
124 # undef strstr
125 # undef strtok
126 # undef memset
127 # undef strerror
128 # undef strlen
129
130   namespace _C_Swamp {
131     namespace _C_Shadow {
132     }
133   }
134   namespace std {
135
136     // Redefine most of these inline.  Note that the 
137     // C++ definition differs from C in some cases.
138
139     inline void* memcpy(void* __s1, void const* __s2, size_t __n)
140       { return ::_C_Swamp::_CPP_memcpy_capture(__s1,__s2,__n); }
141     inline void* memmove(void* __s1, void const* __s2, size_t __n)
142       { return ::_C_Swamp::_CPP_memmove_capture(__s1,__s2,__n); }
143     inline void* strcpy(char* __s1, char const* __s2)
144       { return ::_C_Swamp::_CPP_strcpy_capture(__s1,__s2); }
145     inline char* strncpy(char* __s1, char const* __s2, size_t __n)
146       { return ::_C_Swamp::_CPP_strncpy_capture(__s1,__s2,__n); }
147     inline char* strcat(char* __s1, char const* __s2)
148       { return ::_C_Swamp::_CPP_strcat_capture(__s1,__s2); }
149     inline char* strncat(char* __s1, char const* __s2, size_t __n)
150       { return ::_C_Swamp::_CPP_strncat_capture(__s1,__s2,__n); }
151     inline int memcmp(void const* __s1, 
152                       void const* __s2, size_t __n)
153       { return ::_C_Swamp::_CPP_memcmp_capture(__s1,__s2,__n); }
154     inline int strcmp(char const* __s1, char const* __s2)
155       { return ::_C_Swamp::_CPP_strcmp_capture(__s1,__s2); }
156     inline int strcoll(char const* __s1, char const* __s2)
157       { return ::_C_Swamp::_CPP_strcoll_capture(__s1,__s2); }
158     inline int strncmp(char const* __s1, 
159                                     char const* __s2, size_t __n)
160       { return ::_C_Swamp::_CPP_strncmp_capture(__s1,__s2,__n); }
161     inline size_t strxfrm(char* __b, char const* __s, size_t __n)
162       { return ::_C_Swamp::_CPP_strxfrm_capture(__b,__s,__n); }
163
164     inline void const* memchr(void const* __s1, int __c, size_t __n)
165       { return ::_C_Swamp::_CPP_memchr_capture(__s1,__c,__n); }
166     inline       void* memchr(      void* __s1, int __c, size_t __n)
167       { return ::_C_Swamp::_CPP_memchr_capture(__s1,__c,__n); }
168
169     inline char const* strchr(char const* __s1, int __c)
170       { return ::_C_Swamp::_CPP_strchr_capture(__s1,__c); }
171     inline       char* strchr(      char* __s1, int __c)
172       { return ::_C_Swamp::_CPP_strchr_capture(__s1,__c); }
173
174     inline size_t strcspn(char const* __s1, char const* __s2)
175       { return ::_C_Swamp::_CPP_strcspn_capture(__s1,__s2); }
176
177     inline char const* strpbrk(char const* __s1, char const* __s2)
178       { return ::_C_Swamp::_CPP_strpbrk_capture(__s1,__s2); }
179     inline       char* strpbrk(      char* __s1, char const* __s2)
180       { return ::_C_Swamp::_CPP_strpbrk_capture(__s1,__s2); }
181
182     inline char const* strrchr(char const* __s1, int __c)
183       { return ::_C_Swamp::_CPP_strrchr_capture(__s1,__c); }
184     inline       char* strrchr(      char* __s1, int __c)
185       { return ::_C_Swamp::_CPP_strrchr_capture(__s1,__c); }
186
187     inline size_t strspn(char const* __s1, char const* __s2)
188       { return ::_C_Swamp::_CPP_strspn_capture(__s1,__s2); }
189
190     inline char const* strstr(char const* __s1, char const* __s2)
191       { return ::_C_Swamp::_CPP_strstr_capture(__s1,__s2); }
192     inline       char* strstr(      char* __s1, char const* __s2)
193       { return ::_C_Swamp::_CPP_strstr_capture(__s1,__s2); }
194
195     inline char* strtok(char* __s1, char const* __s2)
196       { return ::_C_Swamp::_CPP_strtok_capture(__s1,__s2); }
197     inline void* memset(void* __s, int __c, size_t __n)
198       { return ::_C_Swamp::_CPP_memset_capture(__s,__c,__n); }
199
200     using ::_C_Swamp::strerror;
201
202     inline size_t strlen(char const* __s)
203       { return ::_C_Swamp::_CPP_strlen_capture(__s); }
204
205   } // close namespace std::
206   
207   namespace _C_Swamp {
208     namespace _C_Shadow {
209       // adopt names back into C
210       using ::std::memcpy;
211       using ::std::memmove;
212       using ::std::strcpy;
213       using ::std::strncpy;
214       using ::std::strcat;
215       using ::std::strncat;
216       using ::std::memcmp;
217       using ::std::strcmp;
218       using ::std::strcoll;
219       using ::std::strncmp;
220       using ::std::strxfrm;
221       using ::std::memchr;
222       using ::std::strchr;
223       using ::std::strcspn;
224       using ::std::strpbrk;
225       using ::std::strrchr;
226       using ::std::strspn;
227       using ::std::strstr;
228       using ::std::strtok;
229       using ::std::memset;
230       // using ::std::strerror;
231       using ::std::strlen;
232     }
233   }
234
235 # undef _IN_C_SWAMP_
236
237 #endif
238