iconv sync 8/x: FreeBSD SVN 281550
[dragonfly.git] / gnu / usr.bin / grep / libgreputils / iconv.h
1 /* DO NOT EDIT! GENERATED AUTOMATICALLY! */
2 /* A GNU-like <iconv.h>.
3
4    Copyright (C) 2007-2014 Free Software Foundation, Inc.
5
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)
9    any later version.
10
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.
15
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/>.  */
18
19 #ifndef _GL_ICONV_H
20
21 #if __GNUC__ >= 3
22 #pragma GCC system_header
23 #endif
24
25
26 /* The include_next requires a split double-inclusion guard.  */
27 #include_next <iconv.h>
28
29 #ifndef _GL_ICONV_H
30 #define _GL_ICONV_H
31
32 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */
33 #ifndef _GL_CXXDEFS_H
34 #define _GL_CXXDEFS_H
35
36 /* The three most frequent use cases of these macros are:
37
38    * For providing a substitute for a function that is missing on some
39      platforms, but is declared and works fine on the platforms on which
40      it exists:
41
42        #if @GNULIB_FOO@
43        # if !@HAVE_FOO@
44        _GL_FUNCDECL_SYS (foo, ...);
45        # endif
46        _GL_CXXALIAS_SYS (foo, ...);
47        _GL_CXXALIASWARN (foo);
48        #elif defined GNULIB_POSIXCHECK
49        ...
50        #endif
51
52    * For providing a replacement for a function that exists on all platforms,
53      but is broken/insufficient and needs to be replaced on some platforms:
54
55        #if @GNULIB_FOO@
56        # if @REPLACE_FOO@
57        #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
58        #   undef foo
59        #   define foo rpl_foo
60        #  endif
61        _GL_FUNCDECL_RPL (foo, ...);
62        _GL_CXXALIAS_RPL (foo, ...);
63        # else
64        _GL_CXXALIAS_SYS (foo, ...);
65        # endif
66        _GL_CXXALIASWARN (foo);
67        #elif defined GNULIB_POSIXCHECK
68        ...
69        #endif
70
71    * For providing a replacement for a function that exists on some platforms
72      but is broken/insufficient and needs to be replaced on some of them and
73      is additionally either missing or undeclared on some other platforms:
74
75        #if @GNULIB_FOO@
76        # if @REPLACE_FOO@
77        #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
78        #   undef foo
79        #   define foo rpl_foo
80        #  endif
81        _GL_FUNCDECL_RPL (foo, ...);
82        _GL_CXXALIAS_RPL (foo, ...);
83        # else
84        #  if !@HAVE_FOO@   or   if !@HAVE_DECL_FOO@
85        _GL_FUNCDECL_SYS (foo, ...);
86        #  endif
87        _GL_CXXALIAS_SYS (foo, ...);
88        # endif
89        _GL_CXXALIASWARN (foo);
90        #elif defined GNULIB_POSIXCHECK
91        ...
92        #endif
93 */
94
95 /* _GL_EXTERN_C declaration;
96    performs the declaration with C linkage.  */
97 #if defined __cplusplus
98 # define _GL_EXTERN_C extern "C"
99 #else
100 # define _GL_EXTERN_C extern
101 #endif
102
103 /* _GL_FUNCDECL_RPL (func, rettype, parameters_and_attributes);
104    declares a replacement function, named rpl_func, with the given prototype,
105    consisting of return type, parameters, and attributes.
106    Example:
107      _GL_FUNCDECL_RPL (open, int, (const char *filename, int flags, ...)
108                                   _GL_ARG_NONNULL ((1)));
109  */
110 #define _GL_FUNCDECL_RPL(func,rettype,parameters_and_attributes) \
111   _GL_FUNCDECL_RPL_1 (rpl_##func, rettype, parameters_and_attributes)
112 #define _GL_FUNCDECL_RPL_1(rpl_func,rettype,parameters_and_attributes) \
113   _GL_EXTERN_C rettype rpl_func parameters_and_attributes
114
115 /* _GL_FUNCDECL_SYS (func, rettype, parameters_and_attributes);
116    declares the system function, named func, with the given prototype,
117    consisting of return type, parameters, and attributes.
118    Example:
119      _GL_FUNCDECL_SYS (open, int, (const char *filename, int flags, ...)
120                                   _GL_ARG_NONNULL ((1)));
121  */
122 #define _GL_FUNCDECL_SYS(func,rettype,parameters_and_attributes) \
123   _GL_EXTERN_C rettype func parameters_and_attributes
124
125 /* _GL_CXXALIAS_RPL (func, rettype, parameters);
126    declares a C++ alias called GNULIB_NAMESPACE::func
127    that redirects to rpl_func, if GNULIB_NAMESPACE is defined.
128    Example:
129      _GL_CXXALIAS_RPL (open, int, (const char *filename, int flags, ...));
130  */
131 #define _GL_CXXALIAS_RPL(func,rettype,parameters) \
132   _GL_CXXALIAS_RPL_1 (func, rpl_##func, rettype, parameters)
133 #if defined __cplusplus && defined GNULIB_NAMESPACE
134 # define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \
135     namespace GNULIB_NAMESPACE                                \
136     {                                                         \
137       rettype (*const func) parameters = ::rpl_func;          \
138     }                                                         \
139     _GL_EXTERN_C int _gl_cxxalias_dummy
140 #else
141 # define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \
142     _GL_EXTERN_C int _gl_cxxalias_dummy
143 #endif
144
145 /* _GL_CXXALIAS_RPL_CAST_1 (func, rpl_func, rettype, parameters);
146    is like  _GL_CXXALIAS_RPL_1 (func, rpl_func, rettype, parameters);
147    except that the C function rpl_func may have a slightly different
148    declaration.  A cast is used to silence the "invalid conversion" error
149    that would otherwise occur.  */
150 #if defined __cplusplus && defined GNULIB_NAMESPACE
151 # define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \
152     namespace GNULIB_NAMESPACE                                     \
153     {                                                              \
154       rettype (*const func) parameters =                           \
155         reinterpret_cast<rettype(*)parameters>(::rpl_func);        \
156     }                                                              \
157     _GL_EXTERN_C int _gl_cxxalias_dummy
158 #else
159 # define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \
160     _GL_EXTERN_C int _gl_cxxalias_dummy
161 #endif
162
163 /* _GL_CXXALIAS_SYS (func, rettype, parameters);
164    declares a C++ alias called GNULIB_NAMESPACE::func
165    that redirects to the system provided function func, if GNULIB_NAMESPACE
166    is defined.
167    Example:
168      _GL_CXXALIAS_SYS (open, int, (const char *filename, int flags, ...));
169  */
170 #if defined __cplusplus && defined GNULIB_NAMESPACE
171   /* If we were to write
172        rettype (*const func) parameters = ::func;
173      like above in _GL_CXXALIAS_RPL_1, the compiler could optimize calls
174      better (remove an indirection through a 'static' pointer variable),
175      but then the _GL_CXXALIASWARN macro below would cause a warning not only
176      for uses of ::func but also for uses of GNULIB_NAMESPACE::func.  */
177 # define _GL_CXXALIAS_SYS(func,rettype,parameters) \
178     namespace GNULIB_NAMESPACE                     \
179     {                                              \
180       static rettype (*func) parameters = ::func;  \
181     }                                              \
182     _GL_EXTERN_C int _gl_cxxalias_dummy
183 #else
184 # define _GL_CXXALIAS_SYS(func,rettype,parameters) \
185     _GL_EXTERN_C int _gl_cxxalias_dummy
186 #endif
187
188 /* _GL_CXXALIAS_SYS_CAST (func, rettype, parameters);
189    is like  _GL_CXXALIAS_SYS (func, rettype, parameters);
190    except that the C function func may have a slightly different declaration.
191    A cast is used to silence the "invalid conversion" error that would
192    otherwise occur.  */
193 #if defined __cplusplus && defined GNULIB_NAMESPACE
194 # define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \
195     namespace GNULIB_NAMESPACE                          \
196     {                                                   \
197       static rettype (*func) parameters =               \
198         reinterpret_cast<rettype(*)parameters>(::func); \
199     }                                                   \
200     _GL_EXTERN_C int _gl_cxxalias_dummy
201 #else
202 # define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \
203     _GL_EXTERN_C int _gl_cxxalias_dummy
204 #endif
205
206 /* _GL_CXXALIAS_SYS_CAST2 (func, rettype, parameters, rettype2, parameters2);
207    is like  _GL_CXXALIAS_SYS (func, rettype, parameters);
208    except that the C function is picked among a set of overloaded functions,
209    namely the one with rettype2 and parameters2.  Two consecutive casts
210    are used to silence the "cannot find a match" and "invalid conversion"
211    errors that would otherwise occur.  */
212 #if defined __cplusplus && defined GNULIB_NAMESPACE
213   /* The outer cast must be a reinterpret_cast.
214      The inner cast: When the function is defined as a set of overloaded
215      functions, it works as a static_cast<>, choosing the designated variant.
216      When the function is defined as a single variant, it works as a
217      reinterpret_cast<>. The parenthesized cast syntax works both ways.  */
218 # define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \
219     namespace GNULIB_NAMESPACE                                                \
220     {                                                                         \
221       static rettype (*func) parameters =                                     \
222         reinterpret_cast<rettype(*)parameters>(                               \
223           (rettype2(*)parameters2)(::func));                                  \
224     }                                                                         \
225     _GL_EXTERN_C int _gl_cxxalias_dummy
226 #else
227 # define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \
228     _GL_EXTERN_C int _gl_cxxalias_dummy
229 #endif
230
231 /* _GL_CXXALIASWARN (func);
232    causes a warning to be emitted when ::func is used but not when
233    GNULIB_NAMESPACE::func is used.  func must be defined without overloaded
234    variants.  */
235 #if defined __cplusplus && defined GNULIB_NAMESPACE
236 # define _GL_CXXALIASWARN(func) \
237    _GL_CXXALIASWARN_1 (func, GNULIB_NAMESPACE)
238 # define _GL_CXXALIASWARN_1(func,namespace) \
239    _GL_CXXALIASWARN_2 (func, namespace)
240 /* To work around GCC bug <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>,
241    we enable the warning only when not optimizing.  */
242 # if !__OPTIMIZE__
243 #  define _GL_CXXALIASWARN_2(func,namespace) \
244     _GL_WARN_ON_USE (func, \
245                      "The symbol ::" #func " refers to the system function. " \
246                      "Use " #namespace "::" #func " instead.")
247 # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
248 #  define _GL_CXXALIASWARN_2(func,namespace) \
249      extern __typeof__ (func) func
250 # else
251 #  define _GL_CXXALIASWARN_2(func,namespace) \
252      _GL_EXTERN_C int _gl_cxxalias_dummy
253 # endif
254 #else
255 # define _GL_CXXALIASWARN(func) \
256     _GL_EXTERN_C int _gl_cxxalias_dummy
257 #endif
258
259 /* _GL_CXXALIASWARN1 (func, rettype, parameters_and_attributes);
260    causes a warning to be emitted when the given overloaded variant of ::func
261    is used but not when GNULIB_NAMESPACE::func is used.  */
262 #if defined __cplusplus && defined GNULIB_NAMESPACE
263 # define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \
264    _GL_CXXALIASWARN1_1 (func, rettype, parameters_and_attributes, \
265                         GNULIB_NAMESPACE)
266 # define _GL_CXXALIASWARN1_1(func,rettype,parameters_and_attributes,namespace) \
267    _GL_CXXALIASWARN1_2 (func, rettype, parameters_and_attributes, namespace)
268 /* To work around GCC bug <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>,
269    we enable the warning only when not optimizing.  */
270 # if !__OPTIMIZE__
271 #  define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
272     _GL_WARN_ON_USE_CXX (func, rettype, parameters_and_attributes, \
273                          "The symbol ::" #func " refers to the system function. " \
274                          "Use " #namespace "::" #func " instead.")
275 # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
276 #  define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
277      extern __typeof__ (func) func
278 # else
279 #  define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
280      _GL_EXTERN_C int _gl_cxxalias_dummy
281 # endif
282 #else
283 # define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \
284     _GL_EXTERN_C int _gl_cxxalias_dummy
285 #endif
286
287 #endif /* _GL_CXXDEFS_H */
288
289 /* The definition of _GL_ARG_NONNULL is copied here.  */
290 /* _GL_ARG_NONNULL((n,...,m)) tells the compiler and static analyzer tools
291    that the values passed as arguments n, ..., m must be non-NULL pointers.
292    n = 1 stands for the first argument, n = 2 for the second argument etc.  */
293 #ifndef _GL_ARG_NONNULL
294 # if (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) || __GNUC__ > 3
295 #  define _GL_ARG_NONNULL(params) __attribute__ ((__nonnull__ params))
296 # else
297 #  define _GL_ARG_NONNULL(params)
298 # endif
299 #endif
300
301 /* The definition of _GL_WARN_ON_USE is copied here.  */
302 #ifndef _GL_WARN_ON_USE
303
304 # if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__)
305 /* A compiler attribute is available in gcc versions 4.3.0 and later.  */
306 #  define _GL_WARN_ON_USE(function, message) \
307 extern __typeof__ (function) function __attribute__ ((__warning__ (message)))
308 # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
309 /* Verify the existence of the function.  */
310 #  define _GL_WARN_ON_USE(function, message) \
311 extern __typeof__ (function) function
312 # else /* Unsupported.  */
313 #  define _GL_WARN_ON_USE(function, message) \
314 _GL_WARN_EXTERN_C int _gl_warn_on_use
315 # endif
316 #endif
317
318 /* _GL_WARN_ON_USE_CXX (function, rettype, parameters_and_attributes, "string")
319    is like _GL_WARN_ON_USE (function, "string"), except that the function is
320    declared with the given prototype, consisting of return type, parameters,
321    and attributes.
322    This variant is useful for overloaded functions in C++. _GL_WARN_ON_USE does
323    not work in this case.  */
324 #ifndef _GL_WARN_ON_USE_CXX
325 # if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__)
326 #  define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
327 extern rettype function parameters_and_attributes \
328      __attribute__ ((__warning__ (msg)))
329 # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
330 /* Verify the existence of the function.  */
331 #  define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
332 extern rettype function parameters_and_attributes
333 # else /* Unsupported.  */
334 #  define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
335 _GL_WARN_EXTERN_C int _gl_warn_on_use
336 # endif
337 #endif
338
339 /* _GL_WARN_EXTERN_C declaration;
340    performs the declaration with C linkage.  */
341 #ifndef _GL_WARN_EXTERN_C
342 # if defined __cplusplus
343 #  define _GL_WARN_EXTERN_C extern "C"
344 # else
345 #  define _GL_WARN_EXTERN_C extern
346 # endif
347 #endif
348
349
350 #if 1
351 # if 0
352 /* An iconv_open wrapper that supports the IANA standardized encoding names
353    ("ISO-8859-1" etc.) as far as possible.  */
354 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
355 #   define iconv_open rpl_iconv_open
356 #  endif
357 _GL_FUNCDECL_RPL (iconv_open, iconv_t,
358                   (const char *tocode, const char *fromcode)
359                   _GL_ARG_NONNULL ((1, 2)));
360 _GL_CXXALIAS_RPL (iconv_open, iconv_t,
361                   (const char *tocode, const char *fromcode));
362 # else
363 _GL_CXXALIAS_SYS (iconv_open, iconv_t,
364                   (const char *tocode, const char *fromcode));
365 # endif
366 _GL_CXXALIASWARN (iconv_open);
367 #endif
368
369 #if 0
370 /* Special constants for supporting UTF-{16,32}{BE,LE} encodings.
371    Not public.  */
372 # define _ICONV_UTF8_UTF16BE (iconv_t)(-161)
373 # define _ICONV_UTF8_UTF16LE (iconv_t)(-162)
374 # define _ICONV_UTF8_UTF32BE (iconv_t)(-163)
375 # define _ICONV_UTF8_UTF32LE (iconv_t)(-164)
376 # define _ICONV_UTF16BE_UTF8 (iconv_t)(-165)
377 # define _ICONV_UTF16LE_UTF8 (iconv_t)(-166)
378 # define _ICONV_UTF32BE_UTF8 (iconv_t)(-167)
379 # define _ICONV_UTF32LE_UTF8 (iconv_t)(-168)
380 #endif
381
382 #if 1
383 # if 0
384 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
385 #   define iconv rpl_iconv
386 #  endif
387 _GL_FUNCDECL_RPL (iconv, size_t,
388                   (iconv_t cd,
389                    const char **inbuf, size_t *inbytesleft,
390                    char **outbuf, size_t *outbytesleft));
391 _GL_CXXALIAS_RPL (iconv, size_t,
392                   (iconv_t cd,
393                    const char **inbuf, size_t *inbytesleft,
394                    char **outbuf, size_t *outbytesleft));
395 # else
396 _GL_CXXALIAS_SYS (iconv, size_t,
397                   (iconv_t cd,
398                    const char **inbuf, size_t *inbytesleft,
399                    char **outbuf, size_t *outbytesleft));
400 # endif
401 _GL_CXXALIASWARN (iconv);
402 # ifndef ICONV_CONST
403 #  define ICONV_CONST
404 # endif
405 #endif
406
407 #if 1
408 # if 0
409 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
410 #   define iconv_close rpl_iconv_close
411 #  endif
412 _GL_FUNCDECL_RPL (iconv_close, int, (iconv_t cd));
413 _GL_CXXALIAS_RPL (iconv_close, int, (iconv_t cd));
414 # else
415 _GL_CXXALIAS_SYS (iconv_close, int, (iconv_t cd));
416 # endif
417 _GL_CXXALIASWARN (iconv_close);
418 #endif
419
420
421 #endif /* _GL_ICONV_H */
422 #endif /* _GL_ICONV_H */