1 /* DO NOT EDIT! GENERATED AUTOMATICALLY! */
2 /* A substitute <strings.h>.
4 Copyright (C) 2007-2013 Free Software Foundation, Inc.
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3, or (at your option)
11 This program 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
17 along with this program; if not, see <http://www.gnu.org/licenses/>. */
22 #pragma GCC system_header
26 /* Minix 3.1.8 has a bug: <sys/types.h> must be included before <strings.h>.
27 But avoid namespace pollution on glibc systems. */
28 #if defined __minix && !defined __GLIBC__
29 # include <sys/types.h>
32 /* The include_next requires a split double-inclusion guard. */
34 # include_next <strings.h>
46 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
50 /* The three most frequent use cases of these macros are:
52 * For providing a substitute for a function that is missing on some
53 platforms, but is declared and works fine on the platforms on which
58 _GL_FUNCDECL_SYS (foo, ...);
60 _GL_CXXALIAS_SYS (foo, ...);
61 _GL_CXXALIASWARN (foo);
62 #elif defined GNULIB_POSIXCHECK
66 * For providing a replacement for a function that exists on all platforms,
67 but is broken/insufficient and needs to be replaced on some platforms:
71 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
75 _GL_FUNCDECL_RPL (foo, ...);
76 _GL_CXXALIAS_RPL (foo, ...);
78 _GL_CXXALIAS_SYS (foo, ...);
80 _GL_CXXALIASWARN (foo);
81 #elif defined GNULIB_POSIXCHECK
85 * For providing a replacement for a function that exists on some platforms
86 but is broken/insufficient and needs to be replaced on some of them and
87 is additionally either missing or undeclared on some other platforms:
91 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
95 _GL_FUNCDECL_RPL (foo, ...);
96 _GL_CXXALIAS_RPL (foo, ...);
98 # if !@HAVE_FOO@ or if !@HAVE_DECL_FOO@
99 _GL_FUNCDECL_SYS (foo, ...);
101 _GL_CXXALIAS_SYS (foo, ...);
103 _GL_CXXALIASWARN (foo);
104 #elif defined GNULIB_POSIXCHECK
109 /* _GL_EXTERN_C declaration;
110 performs the declaration with C linkage. */
111 #if defined __cplusplus
112 # define _GL_EXTERN_C extern "C"
114 # define _GL_EXTERN_C extern
117 /* _GL_FUNCDECL_RPL (func, rettype, parameters_and_attributes);
118 declares a replacement function, named rpl_func, with the given prototype,
119 consisting of return type, parameters, and attributes.
121 _GL_FUNCDECL_RPL (open, int, (const char *filename, int flags, ...)
122 _GL_ARG_NONNULL ((1)));
124 #define _GL_FUNCDECL_RPL(func,rettype,parameters_and_attributes) \
125 _GL_FUNCDECL_RPL_1 (rpl_##func, rettype, parameters_and_attributes)
126 #define _GL_FUNCDECL_RPL_1(rpl_func,rettype,parameters_and_attributes) \
127 _GL_EXTERN_C rettype rpl_func parameters_and_attributes
129 /* _GL_FUNCDECL_SYS (func, rettype, parameters_and_attributes);
130 declares the system function, named func, with the given prototype,
131 consisting of return type, parameters, and attributes.
133 _GL_FUNCDECL_SYS (open, int, (const char *filename, int flags, ...)
134 _GL_ARG_NONNULL ((1)));
136 #define _GL_FUNCDECL_SYS(func,rettype,parameters_and_attributes) \
137 _GL_EXTERN_C rettype func parameters_and_attributes
139 /* _GL_CXXALIAS_RPL (func, rettype, parameters);
140 declares a C++ alias called GNULIB_NAMESPACE::func
141 that redirects to rpl_func, if GNULIB_NAMESPACE is defined.
143 _GL_CXXALIAS_RPL (open, int, (const char *filename, int flags, ...));
145 #define _GL_CXXALIAS_RPL(func,rettype,parameters) \
146 _GL_CXXALIAS_RPL_1 (func, rpl_##func, rettype, parameters)
147 #if defined __cplusplus && defined GNULIB_NAMESPACE
148 # define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \
149 namespace GNULIB_NAMESPACE \
151 rettype (*const func) parameters = ::rpl_func; \
153 _GL_EXTERN_C int _gl_cxxalias_dummy
155 # define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \
156 _GL_EXTERN_C int _gl_cxxalias_dummy
159 /* _GL_CXXALIAS_RPL_CAST_1 (func, rpl_func, rettype, parameters);
160 is like _GL_CXXALIAS_RPL_1 (func, rpl_func, rettype, parameters);
161 except that the C function rpl_func may have a slightly different
162 declaration. A cast is used to silence the "invalid conversion" error
163 that would otherwise occur. */
164 #if defined __cplusplus && defined GNULIB_NAMESPACE
165 # define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \
166 namespace GNULIB_NAMESPACE \
168 rettype (*const func) parameters = \
169 reinterpret_cast<rettype(*)parameters>(::rpl_func); \
171 _GL_EXTERN_C int _gl_cxxalias_dummy
173 # define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \
174 _GL_EXTERN_C int _gl_cxxalias_dummy
177 /* _GL_CXXALIAS_SYS (func, rettype, parameters);
178 declares a C++ alias called GNULIB_NAMESPACE::func
179 that redirects to the system provided function func, if GNULIB_NAMESPACE
182 _GL_CXXALIAS_SYS (open, int, (const char *filename, int flags, ...));
184 #if defined __cplusplus && defined GNULIB_NAMESPACE
185 /* If we were to write
186 rettype (*const func) parameters = ::func;
187 like above in _GL_CXXALIAS_RPL_1, the compiler could optimize calls
188 better (remove an indirection through a 'static' pointer variable),
189 but then the _GL_CXXALIASWARN macro below would cause a warning not only
190 for uses of ::func but also for uses of GNULIB_NAMESPACE::func. */
191 # define _GL_CXXALIAS_SYS(func,rettype,parameters) \
192 namespace GNULIB_NAMESPACE \
194 static rettype (*func) parameters = ::func; \
196 _GL_EXTERN_C int _gl_cxxalias_dummy
198 # define _GL_CXXALIAS_SYS(func,rettype,parameters) \
199 _GL_EXTERN_C int _gl_cxxalias_dummy
202 /* _GL_CXXALIAS_SYS_CAST (func, rettype, parameters);
203 is like _GL_CXXALIAS_SYS (func, rettype, parameters);
204 except that the C function func may have a slightly different declaration.
205 A cast is used to silence the "invalid conversion" error that would
207 #if defined __cplusplus && defined GNULIB_NAMESPACE
208 # define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \
209 namespace GNULIB_NAMESPACE \
211 static rettype (*func) parameters = \
212 reinterpret_cast<rettype(*)parameters>(::func); \
214 _GL_EXTERN_C int _gl_cxxalias_dummy
216 # define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \
217 _GL_EXTERN_C int _gl_cxxalias_dummy
220 /* _GL_CXXALIAS_SYS_CAST2 (func, rettype, parameters, rettype2, parameters2);
221 is like _GL_CXXALIAS_SYS (func, rettype, parameters);
222 except that the C function is picked among a set of overloaded functions,
223 namely the one with rettype2 and parameters2. Two consecutive casts
224 are used to silence the "cannot find a match" and "invalid conversion"
225 errors that would otherwise occur. */
226 #if defined __cplusplus && defined GNULIB_NAMESPACE
227 /* The outer cast must be a reinterpret_cast.
228 The inner cast: When the function is defined as a set of overloaded
229 functions, it works as a static_cast<>, choosing the designated variant.
230 When the function is defined as a single variant, it works as a
231 reinterpret_cast<>. The parenthesized cast syntax works both ways. */
232 # define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \
233 namespace GNULIB_NAMESPACE \
235 static rettype (*func) parameters = \
236 reinterpret_cast<rettype(*)parameters>( \
237 (rettype2(*)parameters2)(::func)); \
239 _GL_EXTERN_C int _gl_cxxalias_dummy
241 # define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \
242 _GL_EXTERN_C int _gl_cxxalias_dummy
245 /* _GL_CXXALIASWARN (func);
246 causes a warning to be emitted when ::func is used but not when
247 GNULIB_NAMESPACE::func is used. func must be defined without overloaded
249 #if defined __cplusplus && defined GNULIB_NAMESPACE
250 # define _GL_CXXALIASWARN(func) \
251 _GL_CXXALIASWARN_1 (func, GNULIB_NAMESPACE)
252 # define _GL_CXXALIASWARN_1(func,namespace) \
253 _GL_CXXALIASWARN_2 (func, namespace)
254 /* To work around GCC bug <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>,
255 we enable the warning only when not optimizing. */
257 # define _GL_CXXALIASWARN_2(func,namespace) \
258 _GL_WARN_ON_USE (func, \
259 "The symbol ::" #func " refers to the system function. " \
260 "Use " #namespace "::" #func " instead.")
261 # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
262 # define _GL_CXXALIASWARN_2(func,namespace) \
263 extern __typeof__ (func) func
265 # define _GL_CXXALIASWARN_2(func,namespace) \
266 _GL_EXTERN_C int _gl_cxxalias_dummy
269 # define _GL_CXXALIASWARN(func) \
270 _GL_EXTERN_C int _gl_cxxalias_dummy
273 /* _GL_CXXALIASWARN1 (func, rettype, parameters_and_attributes);
274 causes a warning to be emitted when the given overloaded variant of ::func
275 is used but not when GNULIB_NAMESPACE::func is used. */
276 #if defined __cplusplus && defined GNULIB_NAMESPACE
277 # define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \
278 _GL_CXXALIASWARN1_1 (func, rettype, parameters_and_attributes, \
280 # define _GL_CXXALIASWARN1_1(func,rettype,parameters_and_attributes,namespace) \
281 _GL_CXXALIASWARN1_2 (func, rettype, parameters_and_attributes, namespace)
282 /* To work around GCC bug <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>,
283 we enable the warning only when not optimizing. */
285 # define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
286 _GL_WARN_ON_USE_CXX (func, rettype, parameters_and_attributes, \
287 "The symbol ::" #func " refers to the system function. " \
288 "Use " #namespace "::" #func " instead.")
289 # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
290 # define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
291 extern __typeof__ (func) func
293 # define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
294 _GL_EXTERN_C int _gl_cxxalias_dummy
297 # define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \
298 _GL_EXTERN_C int _gl_cxxalias_dummy
301 #endif /* _GL_CXXDEFS_H */
303 /* The definition of _GL_ARG_NONNULL is copied here. */
304 /* _GL_ARG_NONNULL((n,...,m)) tells the compiler and static analyzer tools
305 that the values passed as arguments n, ..., m must be non-NULL pointers.
306 n = 1 stands for the first argument, n = 2 for the second argument etc. */
307 #ifndef _GL_ARG_NONNULL
308 # if (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) || __GNUC__ > 3
309 # define _GL_ARG_NONNULL(params) __attribute__ ((__nonnull__ params))
311 # define _GL_ARG_NONNULL(params)
315 /* The definition of _GL_WARN_ON_USE is copied here. */
316 #ifndef _GL_WARN_ON_USE
318 # if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__)
319 /* A compiler attribute is available in gcc versions 4.3.0 and later. */
320 # define _GL_WARN_ON_USE(function, message) \
321 extern __typeof__ (function) function __attribute__ ((__warning__ (message)))
322 # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
323 /* Verify the existence of the function. */
324 # define _GL_WARN_ON_USE(function, message) \
325 extern __typeof__ (function) function
326 # else /* Unsupported. */
327 # define _GL_WARN_ON_USE(function, message) \
328 _GL_WARN_EXTERN_C int _gl_warn_on_use
332 /* _GL_WARN_ON_USE_CXX (function, rettype, parameters_and_attributes, "string")
333 is like _GL_WARN_ON_USE (function, "string"), except that the function is
334 declared with the given prototype, consisting of return type, parameters,
336 This variant is useful for overloaded functions in C++. _GL_WARN_ON_USE does
337 not work in this case. */
338 #ifndef _GL_WARN_ON_USE_CXX
339 # if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__)
340 # define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
341 extern rettype function parameters_and_attributes \
342 __attribute__ ((__warning__ (msg)))
343 # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
344 /* Verify the existence of the function. */
345 # define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
346 extern rettype function parameters_and_attributes
347 # else /* Unsupported. */
348 # define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
349 _GL_WARN_EXTERN_C int _gl_warn_on_use
353 /* _GL_WARN_EXTERN_C declaration;
354 performs the declaration with C linkage. */
355 #ifndef _GL_WARN_EXTERN_C
356 # if defined __cplusplus
357 # define _GL_WARN_EXTERN_C extern "C"
359 # define _GL_WARN_EXTERN_C extern
368 /* Find the index of the least-significant set bit. */
371 _GL_FUNCDECL_SYS (ffs, int, (int i));
373 _GL_CXXALIAS_SYS (ffs, int, (int i));
374 _GL_CXXALIASWARN (ffs);
375 #elif defined GNULIB_POSIXCHECK
377 # if HAVE_RAW_DECL_FFS
378 _GL_WARN_ON_USE (ffs, "ffs is not portable - use the ffs module");
382 /* Compare strings S1 and S2, ignoring case, returning less than, equal to or
383 greater than zero if S1 is lexicographically less than, equal to or greater
385 Note: This function does not work in multibyte locales. */
387 extern int strcasecmp (char const *s1, char const *s2)
388 _GL_ARG_NONNULL ((1, 2));
390 #if defined GNULIB_POSIXCHECK
391 /* strcasecmp() does not work with multibyte strings:
392 POSIX says that it operates on "strings", and "string" in POSIX is defined
393 as a sequence of bytes, not of characters. */
395 # if HAVE_RAW_DECL_STRCASECMP
396 _GL_WARN_ON_USE (strcasecmp, "strcasecmp cannot work correctly on character "
397 "strings in multibyte locales - "
398 "use mbscasecmp if you care about "
399 "internationalization, or use c_strcasecmp , "
400 "gnulib module c-strcase) if you want a locale "
401 "independent function");
405 /* Compare no more than N bytes of strings S1 and S2, ignoring case,
406 returning less than, equal to or greater than zero if S1 is
407 lexicographically less than, equal to or greater than S2.
408 Note: This function cannot work correctly in multibyte locales. */
410 extern int strncasecmp (char const *s1, char const *s2, size_t n)
411 _GL_ARG_NONNULL ((1, 2));
413 #if defined GNULIB_POSIXCHECK
414 /* strncasecmp() does not work with multibyte strings:
415 POSIX says that it operates on "strings", and "string" in POSIX is defined
416 as a sequence of bytes, not of characters. */
418 # if HAVE_RAW_DECL_STRNCASECMP
419 _GL_WARN_ON_USE (strncasecmp, "strncasecmp cannot work correctly on character "
420 "strings in multibyte locales - "
421 "use mbsncasecmp or mbspcasecmp if you care about "
422 "internationalization, or use c_strncasecmp , "
423 "gnulib module c-strcase) if you want a locale "
424 "independent function");
433 #endif /* _GL_STRING_H */
434 #endif /* _GL_STRING_H */