1 /* DO NOT EDIT! GENERATED AUTOMATICALLY! */
2 /* -*- buffer-read-only: t -*- vi: set ro: */
3 /* DO NOT EDIT! GENERATED AUTOMATICALLY! */
4 /* A substitute <strings.h>.
6 Copyright (C) 2007-2011 Free Software Foundation, Inc.
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3, or (at your option)
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software Foundation,
20 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
25 #pragma GCC system_header
29 /* Minix 3.1.8 has a bug: <sys/types.h> must be included before <strings.h>.
30 But avoid namespace pollution on glibc systems. */
31 #if defined __minix && !defined __GLIBC__
32 # include <sys/types.h>
35 /* The include_next requires a split double-inclusion guard. */
36 #include_next <strings.h>
42 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
46 /* The three most frequent use cases of these macros are:
48 * For providing a substitute for a function that is missing on some
49 platforms, but is declared and works fine on the platforms on which
54 _GL_FUNCDECL_SYS (foo, ...);
56 _GL_CXXALIAS_SYS (foo, ...);
57 _GL_CXXALIASWARN (foo);
58 #elif defined GNULIB_POSIXCHECK
62 * For providing a replacement for a function that exists on all platforms,
63 but is broken/insufficient and needs to be replaced on some platforms:
67 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
71 _GL_FUNCDECL_RPL (foo, ...);
72 _GL_CXXALIAS_RPL (foo, ...);
74 _GL_CXXALIAS_SYS (foo, ...);
76 _GL_CXXALIASWARN (foo);
77 #elif defined GNULIB_POSIXCHECK
81 * For providing a replacement for a function that exists on some platforms
82 but is broken/insufficient and needs to be replaced on some of them and
83 is additionally either missing or undeclared on some other platforms:
87 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
91 _GL_FUNCDECL_RPL (foo, ...);
92 _GL_CXXALIAS_RPL (foo, ...);
94 # if !@HAVE_FOO@ or if !@HAVE_DECL_FOO@
95 _GL_FUNCDECL_SYS (foo, ...);
97 _GL_CXXALIAS_SYS (foo, ...);
99 _GL_CXXALIASWARN (foo);
100 #elif defined GNULIB_POSIXCHECK
105 /* _GL_EXTERN_C declaration;
106 performs the declaration with C linkage. */
107 #if defined __cplusplus
108 # define _GL_EXTERN_C extern "C"
110 # define _GL_EXTERN_C extern
113 /* _GL_FUNCDECL_RPL (func, rettype, parameters_and_attributes);
114 declares a replacement function, named rpl_func, with the given prototype,
115 consisting of return type, parameters, and attributes.
117 _GL_FUNCDECL_RPL (open, int, (const char *filename, int flags, ...)
118 _GL_ARG_NONNULL ((1)));
120 #define _GL_FUNCDECL_RPL(func,rettype,parameters_and_attributes) \
121 _GL_FUNCDECL_RPL_1 (rpl_##func, rettype, parameters_and_attributes)
122 #define _GL_FUNCDECL_RPL_1(rpl_func,rettype,parameters_and_attributes) \
123 _GL_EXTERN_C rettype rpl_func parameters_and_attributes
125 /* _GL_FUNCDECL_SYS (func, rettype, parameters_and_attributes);
126 declares the system function, named func, with the given prototype,
127 consisting of return type, parameters, and attributes.
129 _GL_FUNCDECL_SYS (open, int, (const char *filename, int flags, ...)
130 _GL_ARG_NONNULL ((1)));
132 #define _GL_FUNCDECL_SYS(func,rettype,parameters_and_attributes) \
133 _GL_EXTERN_C rettype func parameters_and_attributes
135 /* _GL_CXXALIAS_RPL (func, rettype, parameters);
136 declares a C++ alias called GNULIB_NAMESPACE::func
137 that redirects to rpl_func, if GNULIB_NAMESPACE is defined.
139 _GL_CXXALIAS_RPL (open, int, (const char *filename, int flags, ...));
141 #define _GL_CXXALIAS_RPL(func,rettype,parameters) \
142 _GL_CXXALIAS_RPL_1 (func, rpl_##func, rettype, parameters)
143 #if defined __cplusplus && defined GNULIB_NAMESPACE
144 # define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \
145 namespace GNULIB_NAMESPACE \
147 rettype (*const func) parameters = ::rpl_func; \
149 _GL_EXTERN_C int _gl_cxxalias_dummy
151 # define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \
152 _GL_EXTERN_C int _gl_cxxalias_dummy
155 /* _GL_CXXALIAS_RPL_CAST_1 (func, rpl_func, rettype, parameters);
156 is like _GL_CXXALIAS_RPL_1 (func, rpl_func, rettype, parameters);
157 except that the C function rpl_func may have a slightly different
158 declaration. A cast is used to silence the "invalid conversion" error
159 that would otherwise occur. */
160 #if defined __cplusplus && defined GNULIB_NAMESPACE
161 # define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \
162 namespace GNULIB_NAMESPACE \
164 rettype (*const func) parameters = \
165 reinterpret_cast<rettype(*)parameters>(::rpl_func); \
167 _GL_EXTERN_C int _gl_cxxalias_dummy
169 # define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \
170 _GL_EXTERN_C int _gl_cxxalias_dummy
173 /* _GL_CXXALIAS_SYS (func, rettype, parameters);
174 declares a C++ alias called GNULIB_NAMESPACE::func
175 that redirects to the system provided function func, if GNULIB_NAMESPACE
178 _GL_CXXALIAS_SYS (open, int, (const char *filename, int flags, ...));
180 #if defined __cplusplus && defined GNULIB_NAMESPACE
181 /* If we were to write
182 rettype (*const func) parameters = ::func;
183 like above in _GL_CXXALIAS_RPL_1, the compiler could optimize calls
184 better (remove an indirection through a 'static' pointer variable),
185 but then the _GL_CXXALIASWARN macro below would cause a warning not only
186 for uses of ::func but also for uses of GNULIB_NAMESPACE::func. */
187 # define _GL_CXXALIAS_SYS(func,rettype,parameters) \
188 namespace GNULIB_NAMESPACE \
190 static rettype (*func) parameters = ::func; \
192 _GL_EXTERN_C int _gl_cxxalias_dummy
194 # define _GL_CXXALIAS_SYS(func,rettype,parameters) \
195 _GL_EXTERN_C int _gl_cxxalias_dummy
198 /* _GL_CXXALIAS_SYS_CAST (func, rettype, parameters);
199 is like _GL_CXXALIAS_SYS (func, rettype, parameters);
200 except that the C function func may have a slightly different declaration.
201 A cast is used to silence the "invalid conversion" error that would
203 #if defined __cplusplus && defined GNULIB_NAMESPACE
204 # define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \
205 namespace GNULIB_NAMESPACE \
207 static rettype (*func) parameters = \
208 reinterpret_cast<rettype(*)parameters>(::func); \
210 _GL_EXTERN_C int _gl_cxxalias_dummy
212 # define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \
213 _GL_EXTERN_C int _gl_cxxalias_dummy
216 /* _GL_CXXALIAS_SYS_CAST2 (func, rettype, parameters, rettype2, parameters2);
217 is like _GL_CXXALIAS_SYS (func, rettype, parameters);
218 except that the C function is picked among a set of overloaded functions,
219 namely the one with rettype2 and parameters2. Two consecutive casts
220 are used to silence the "cannot find a match" and "invalid conversion"
221 errors that would otherwise occur. */
222 #if defined __cplusplus && defined GNULIB_NAMESPACE
223 /* The outer cast must be a reinterpret_cast.
224 The inner cast: When the function is defined as a set of overloaded
225 functions, it works as a static_cast<>, choosing the designated variant.
226 When the function is defined as a single variant, it works as a
227 reinterpret_cast<>. The parenthesized cast syntax works both ways. */
228 # define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \
229 namespace GNULIB_NAMESPACE \
231 static rettype (*func) parameters = \
232 reinterpret_cast<rettype(*)parameters>( \
233 (rettype2(*)parameters2)(::func)); \
235 _GL_EXTERN_C int _gl_cxxalias_dummy
237 # define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \
238 _GL_EXTERN_C int _gl_cxxalias_dummy
241 /* _GL_CXXALIASWARN (func);
242 causes a warning to be emitted when ::func is used but not when
243 GNULIB_NAMESPACE::func is used. func must be defined without overloaded
245 #if defined __cplusplus && defined GNULIB_NAMESPACE
246 # define _GL_CXXALIASWARN(func) \
247 _GL_CXXALIASWARN_1 (func, GNULIB_NAMESPACE)
248 # define _GL_CXXALIASWARN_1(func,namespace) \
249 _GL_CXXALIASWARN_2 (func, namespace)
250 /* To work around GCC bug <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>,
251 we enable the warning only when not optimizing. */
253 # define _GL_CXXALIASWARN_2(func,namespace) \
254 _GL_WARN_ON_USE (func, \
255 "The symbol ::" #func " refers to the system function. " \
256 "Use " #namespace "::" #func " instead.")
257 # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
258 # define _GL_CXXALIASWARN_2(func,namespace) \
259 extern __typeof__ (func) func
261 # define _GL_CXXALIASWARN_2(func,namespace) \
262 _GL_EXTERN_C int _gl_cxxalias_dummy
265 # define _GL_CXXALIASWARN(func) \
266 _GL_EXTERN_C int _gl_cxxalias_dummy
269 /* _GL_CXXALIASWARN1 (func, rettype, parameters_and_attributes);
270 causes a warning to be emitted when the given overloaded variant of ::func
271 is used but not when GNULIB_NAMESPACE::func is used. */
272 #if defined __cplusplus && defined GNULIB_NAMESPACE
273 # define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \
274 _GL_CXXALIASWARN1_1 (func, rettype, parameters_and_attributes, \
276 # define _GL_CXXALIASWARN1_1(func,rettype,parameters_and_attributes,namespace) \
277 _GL_CXXALIASWARN1_2 (func, rettype, parameters_and_attributes, namespace)
278 /* To work around GCC bug <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>,
279 we enable the warning only when not optimizing. */
281 # define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
282 _GL_WARN_ON_USE_CXX (func, rettype, parameters_and_attributes, \
283 "The symbol ::" #func " refers to the system function. " \
284 "Use " #namespace "::" #func " instead.")
285 # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
286 # define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
287 extern __typeof__ (func) func
289 # define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
290 _GL_EXTERN_C int _gl_cxxalias_dummy
293 # define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \
294 _GL_EXTERN_C int _gl_cxxalias_dummy
297 #endif /* _GL_CXXDEFS_H */
299 /* The definition of _GL_ARG_NONNULL is copied here. */
300 /* _GL_ARG_NONNULL((n,...,m)) tells the compiler and static analyzer tools
301 that the values passed as arguments n, ..., m must be non-NULL pointers.
302 n = 1 stands for the first argument, n = 2 for the second argument etc. */
303 #ifndef _GL_ARG_NONNULL
304 # if (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) || __GNUC__ > 3
305 # define _GL_ARG_NONNULL(params) __attribute__ ((__nonnull__ params))
307 # define _GL_ARG_NONNULL(params)
311 /* The definition of _GL_WARN_ON_USE is copied here. */
312 #ifndef _GL_WARN_ON_USE
314 # if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__)
315 /* A compiler attribute is available in gcc versions 4.3.0 and later. */
316 # define _GL_WARN_ON_USE(function, message) \
317 extern __typeof__ (function) function __attribute__ ((__warning__ (message)))
318 # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
319 /* Verify the existence of the function. */
320 # define _GL_WARN_ON_USE(function, message) \
321 extern __typeof__ (function) function
322 # else /* Unsupported. */
323 # define _GL_WARN_ON_USE(function, message) \
324 _GL_WARN_EXTERN_C int _gl_warn_on_use
328 /* _GL_WARN_ON_USE_CXX (function, rettype, parameters_and_attributes, "string")
329 is like _GL_WARN_ON_USE (function, "string"), except that the function is
330 declared with the given prototype, consisting of return type, parameters,
332 This variant is useful for overloaded functions in C++. _GL_WARN_ON_USE does
333 not work in this case. */
334 #ifndef _GL_WARN_ON_USE_CXX
335 # if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__)
336 # define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
337 extern rettype function parameters_and_attributes \
338 __attribute__ ((__warning__ (msg)))
339 # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
340 /* Verify the existence of the function. */
341 # define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
342 extern rettype function parameters_and_attributes
343 # else /* Unsupported. */
344 # define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
345 _GL_WARN_EXTERN_C int _gl_warn_on_use
349 /* _GL_WARN_EXTERN_C declaration;
350 performs the declaration with C linkage. */
351 #ifndef _GL_WARN_EXTERN_C
352 # if defined __cplusplus
353 # define _GL_WARN_EXTERN_C extern "C"
355 # define _GL_WARN_EXTERN_C extern
364 /* Find the index of the least-significant set bit. */
367 _GL_FUNCDECL_SYS (ffs, int, (int i));
369 _GL_CXXALIAS_SYS (ffs, int, (int i));
370 _GL_CXXALIASWARN (ffs);
371 #elif defined GNULIB_POSIXCHECK
373 # if HAVE_RAW_DECL_FFS
374 _GL_WARN_ON_USE (ffs, "ffs is not portable - use the ffs module");
378 /* Compare strings S1 and S2, ignoring case, returning less than, equal to or
379 greater than zero if S1 is lexicographically less than, equal to or greater
381 Note: This function does not work in multibyte locales. */
383 extern int strcasecmp (char const *s1, char const *s2)
384 _GL_ARG_NONNULL ((1, 2));
386 #if defined GNULIB_POSIXCHECK
387 /* strcasecmp() does not work with multibyte strings:
388 POSIX says that it operates on "strings", and "string" in POSIX is defined
389 as a sequence of bytes, not of characters. */
391 # if HAVE_RAW_DECL_STRCASECMP
392 _GL_WARN_ON_USE (strcasecmp, "strcasecmp cannot work correctly on character "
393 "strings in multibyte locales - "
394 "use mbscasecmp if you care about "
395 "internationalization, or use c_strcasecmp , "
396 "gnulib module c-strcase) if you want a locale "
397 "independent function");
401 /* Compare no more than N bytes of strings S1 and S2, ignoring case,
402 returning less than, equal to or greater than zero if S1 is
403 lexicographically less than, equal to or greater than S2.
404 Note: This function cannot work correctly in multibyte locales. */
406 extern int strncasecmp (char const *s1, char const *s2, size_t n)
407 _GL_ARG_NONNULL ((1, 2));
409 #if defined GNULIB_POSIXCHECK
410 /* strncasecmp() does not work with multibyte strings:
411 POSIX says that it operates on "strings", and "string" in POSIX is defined
412 as a sequence of bytes, not of characters. */
414 # if HAVE_RAW_DECL_STRNCASECMP
415 _GL_WARN_ON_USE (strncasecmp, "strncasecmp cannot work correctly on character "
416 "strings in multibyte locales - "
417 "use mbsncasecmp or mbspcasecmp if you care about "
418 "internationalization, or use c_strncasecmp , "
419 "gnulib module c-strcase) if you want a locale "
420 "independent function");
429 #endif /* _GL_STRING_H */
430 #endif /* _GL_STRING_H */