~peter-pearse/ubuntu/natty/diffutils/prop001

« back to all changes in this revision

Viewing changes to build-aux/c++defs.h

  • Committer: Bazaar Package Importer
  • Author(s): Santiago Vila
  • Date: 2010-05-04 20:38:00 UTC
  • mfrom: (2.1.7 sid)
  • Revision ID: james.westby@ubuntu.com-20100504203800-f67xd9rsa9xl9qqj
Tags: 1:3.0-1
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* -*- buffer-read-only: t -*- vi: set ro: */
 
2
/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
 
3
/* C++ compatible function declaration macros.
 
4
   Copyright (C) 2010 Free Software Foundation, Inc.
 
5
 
 
6
   This program is free software: you can redistribute it and/or modify it
 
7
   under the terms of the GNU General Public License as published
 
8
   by the Free Software Foundation; either version 3 of the License, or
 
9
   (at your option) 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 GNU
 
14
   Lesser 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_CXXDEFS_H
 
20
#define _GL_CXXDEFS_H
 
21
 
 
22
/* The three most frequent use cases of these macros are:
 
23
 
 
24
   * For providing a substitute for a function that is missing on some
 
25
     platforms, but is declared and works fine on the platforms on which
 
26
     it exists:
 
27
 
 
28
       #if @GNULIB_FOO@
 
29
       # if !@HAVE_FOO@
 
30
       _GL_FUNCDECL_SYS (foo, ...);
 
31
       # endif
 
32
       _GL_CXXALIAS_SYS (foo, ...);
 
33
       _GL_CXXALIASWARN (foo);
 
34
       #elif defined GNULIB_POSIXCHECK
 
35
       ...
 
36
       #endif
 
37
 
 
38
   * For providing a replacement for a function that exists on all platforms,
 
39
     but is broken/insufficient and needs to be replaced on some platforms:
 
40
 
 
41
       #if @GNULIB_FOO@
 
42
       # if @REPLACE_FOO@
 
43
       #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
 
44
       #   undef foo
 
45
       #   define foo rpl_foo
 
46
       #  endif
 
47
       _GL_FUNCDECL_RPL (foo, ...);
 
48
       _GL_CXXALIAS_RPL (foo, ...);
 
49
       # else
 
50
       _GL_CXXALIAS_SYS (foo, ...);
 
51
       # endif
 
52
       _GL_CXXALIASWARN (foo);
 
53
       #elif defined GNULIB_POSIXCHECK
 
54
       ...
 
55
       #endif
 
56
 
 
57
   * For providing a replacement for a function that exists on some platforms
 
58
     but is broken/insufficient and needs to be replaced on some of them and
 
59
     is additionally either missing or undeclared on some other platforms:
 
60
 
 
61
       #if @GNULIB_FOO@
 
62
       # if @REPLACE_FOO@
 
63
       #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
 
64
       #   undef foo
 
65
       #   define foo rpl_foo
 
66
       #  endif
 
67
       _GL_FUNCDECL_RPL (foo, ...);
 
68
       _GL_CXXALIAS_RPL (foo, ...);
 
69
       # else
 
70
       #  if !@HAVE_FOO@   or   if !@HAVE_DECL_FOO@
 
71
       _GL_FUNCDECL_SYS (foo, ...);
 
72
       #  endif
 
73
       _GL_CXXALIAS_SYS (foo, ...);
 
74
       # endif
 
75
       _GL_CXXALIASWARN (foo);
 
76
       #elif defined GNULIB_POSIXCHECK
 
77
       ...
 
78
       #endif
 
79
*/
 
80
 
 
81
/* _GL_EXTERN_C declaration;
 
82
   performs the declaration with C linkage.  */
 
83
#if defined __cplusplus
 
84
# define _GL_EXTERN_C extern "C"
 
85
#else
 
86
# define _GL_EXTERN_C extern
 
87
#endif
 
88
 
 
89
/* _GL_FUNCDECL_RPL (func, rettype, parameters_and_attributes);
 
90
   declares a replacement function, named rpl_func, with the given prototype,
 
91
   consisting of return type, parameters, and attributes.
 
92
   Example:
 
93
     _GL_FUNCDECL_RPL (open, int, (const char *filename, int flags, ...)
 
94
                                  _GL_ARG_NONNULL ((1)));
 
95
 */
 
96
#define _GL_FUNCDECL_RPL(func,rettype,parameters_and_attributes) \
 
97
  _GL_FUNCDECL_RPL_1 (rpl_##func, rettype, parameters_and_attributes)
 
98
#define _GL_FUNCDECL_RPL_1(rpl_func,rettype,parameters_and_attributes) \
 
99
  _GL_EXTERN_C rettype rpl_func parameters_and_attributes
 
100
 
 
101
/* _GL_FUNCDECL_SYS (func, rettype, parameters_and_attributes);
 
102
   declares the system function, named func, with the given prototype,
 
103
   consisting of return type, parameters, and attributes.
 
104
   Example:
 
105
     _GL_FUNCDECL_SYS (open, int, (const char *filename, int flags, ...)
 
106
                                  _GL_ARG_NONNULL ((1)));
 
107
 */
 
108
#define _GL_FUNCDECL_SYS(func,rettype,parameters_and_attributes) \
 
109
  _GL_EXTERN_C rettype func parameters_and_attributes
 
110
 
 
111
/* _GL_CXXALIAS_RPL (func, rettype, parameters);
 
112
   declares a C++ alias called GNULIB_NAMESPACE::func
 
113
   that redirects to rpl_func, if GNULIB_NAMESPACE is defined.
 
114
   Example:
 
115
     _GL_CXXALIAS_RPL (open, int, (const char *filename, int flags, ...));
 
116
 */
 
117
#define _GL_CXXALIAS_RPL(func,rettype,parameters) \
 
118
  _GL_CXXALIAS_RPL_1 (func, rpl_##func, rettype, parameters)
 
119
#if defined __cplusplus && defined GNULIB_NAMESPACE
 
120
# define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \
 
121
    namespace GNULIB_NAMESPACE                                \
 
122
    {                                                         \
 
123
      rettype (*const func) parameters = ::rpl_func;          \
 
124
    }                                                         \
 
125
    _GL_EXTERN_C int _gl_cxxalias_dummy
 
126
#else
 
127
# define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \
 
128
    _GL_EXTERN_C int _gl_cxxalias_dummy
 
129
#endif
 
130
 
 
131
/* _GL_CXXALIAS_RPL_CAST_1 (func, rpl_func, rettype, parameters);
 
132
   is like  _GL_CXXALIAS_RPL_1 (func, rpl_func, rettype, parameters);
 
133
   except that the C function rpl_func may have a slightly different
 
134
   declaration.  A cast is used to silence the "invalid conversion" error
 
135
   that would otherwise occur.  */
 
136
#if defined __cplusplus && defined GNULIB_NAMESPACE
 
137
# define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \
 
138
    namespace GNULIB_NAMESPACE                                     \
 
139
    {                                                              \
 
140
      rettype (*const func) parameters =                           \
 
141
        reinterpret_cast<rettype(*)parameters>(::rpl_func);        \
 
142
    }                                                              \
 
143
    _GL_EXTERN_C int _gl_cxxalias_dummy
 
144
#else
 
145
# define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \
 
146
    _GL_EXTERN_C int _gl_cxxalias_dummy
 
147
#endif
 
148
 
 
149
/* _GL_CXXALIAS_SYS (func, rettype, parameters);
 
150
   declares a C++ alias called GNULIB_NAMESPACE::func
 
151
   that redirects to the system provided function func, if GNULIB_NAMESPACE
 
152
   is defined.
 
153
   Example:
 
154
     _GL_CXXALIAS_SYS (open, int, (const char *filename, int flags, ...));
 
155
 */
 
156
#if defined __cplusplus && defined GNULIB_NAMESPACE
 
157
  /* If we were to write
 
158
       rettype (*const func) parameters = ::func;
 
159
     like above in _GL_CXXALIAS_RPL_1, the compiler could optimize calls
 
160
     better (remove an indirection through a 'static' pointer variable),
 
161
     but then the _GL_CXXALIASWARN macro below would cause a warning not only
 
162
     for uses of ::func but also for uses of GNULIB_NAMESPACE::func.  */
 
163
# define _GL_CXXALIAS_SYS(func,rettype,parameters) \
 
164
    namespace GNULIB_NAMESPACE                     \
 
165
    {                                              \
 
166
      static rettype (*func) parameters = ::func;  \
 
167
    }                                              \
 
168
    _GL_EXTERN_C int _gl_cxxalias_dummy
 
169
#else
 
170
# define _GL_CXXALIAS_SYS(func,rettype,parameters) \
 
171
    _GL_EXTERN_C int _gl_cxxalias_dummy
 
172
#endif
 
173
 
 
174
/* _GL_CXXALIAS_SYS_CAST (func, rettype, parameters);
 
175
   is like  _GL_CXXALIAS_SYS (func, rettype, parameters);
 
176
   except that the C function func may have a slightly different declaration.
 
177
   A cast is used to silence the "invalid conversion" error that would
 
178
   otherwise occur.  */
 
179
#if defined __cplusplus && defined GNULIB_NAMESPACE
 
180
# define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \
 
181
    namespace GNULIB_NAMESPACE                          \
 
182
    {                                                   \
 
183
      static rettype (*func) parameters =               \
 
184
        reinterpret_cast<rettype(*)parameters>(::func); \
 
185
    }                                                   \
 
186
    _GL_EXTERN_C int _gl_cxxalias_dummy
 
187
#else
 
188
# define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \
 
189
    _GL_EXTERN_C int _gl_cxxalias_dummy
 
190
#endif
 
191
 
 
192
/* _GL_CXXALIAS_SYS_CAST2 (func, rettype, parameters, rettype2, parameters2);
 
193
   is like  _GL_CXXALIAS_SYS (func, rettype, parameters);
 
194
   except that the C function is picked among a set of overloaded functions,
 
195
   namely the one with rettype2 and parameters2.  Two consecutive casts
 
196
   are used to silence the "cannot find a match" and "invalid conversion"
 
197
   errors that would otherwise occur.  */
 
198
#if defined __cplusplus && defined GNULIB_NAMESPACE
 
199
  /* The outer cast must be a reinterpret_cast.
 
200
     The inner cast: When the function is defined as a set of overloaded
 
201
     functions, it works as a static_cast<>, choosing the designated variant.
 
202
     When the function is defined as a single variant, it works as a
 
203
     reinterpret_cast<>. The parenthesized cast syntax works both ways.  */
 
204
# define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \
 
205
    namespace GNULIB_NAMESPACE                                                \
 
206
    {                                                                         \
 
207
      static rettype (*func) parameters =                                     \
 
208
        reinterpret_cast<rettype(*)parameters>(                               \
 
209
          (rettype2(*)parameters2)(::func));                                  \
 
210
    }                                                                         \
 
211
    _GL_EXTERN_C int _gl_cxxalias_dummy
 
212
#else
 
213
# define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \
 
214
    _GL_EXTERN_C int _gl_cxxalias_dummy
 
215
#endif
 
216
 
 
217
/* _GL_CXXALIASWARN (func);
 
218
   causes a warning to be emitted when ::func is used but not when
 
219
   GNULIB_NAMESPACE::func is used.  func must be defined without overloaded
 
220
   variants.  */
 
221
#if defined __cplusplus && defined GNULIB_NAMESPACE
 
222
# define _GL_CXXALIASWARN(func) \
 
223
   _GL_CXXALIASWARN_1 (func, GNULIB_NAMESPACE)
 
224
# define _GL_CXXALIASWARN_1(func,namespace) \
 
225
   _GL_CXXALIASWARN_2 (func, namespace)
 
226
# define _GL_CXXALIASWARN_2(func,namespace) \
 
227
   _GL_WARN_ON_USE (func, \
 
228
                    "The symbol ::" #func " refers to the system function. " \
 
229
                    "Use " #namespace "::" #func " instead.")
 
230
#else
 
231
# define _GL_CXXALIASWARN(func) \
 
232
    _GL_EXTERN_C int _gl_cxxalias_dummy
 
233
#endif
 
234
 
 
235
/* _GL_CXXALIASWARN1 (func, rettype, parameters_and_attributes);
 
236
   causes a warning to be emitted when the given overloaded variant of ::func
 
237
   is used but not when GNULIB_NAMESPACE::func is used.  */
 
238
#if defined __cplusplus && defined GNULIB_NAMESPACE
 
239
# define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \
 
240
   _GL_CXXALIASWARN1_1 (func, rettype, parameters_and_attributes, \
 
241
                        GNULIB_NAMESPACE)
 
242
# define _GL_CXXALIASWARN1_1(func,rettype,parameters_and_attributes,namespace) \
 
243
   _GL_CXXALIASWARN1_2 (func, rettype, parameters_and_attributes, namespace)
 
244
# define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
 
245
   _GL_WARN_ON_USE_CXX (func, rettype, parameters_and_attributes, \
 
246
                        "The symbol ::" #func " refers to the system function. " \
 
247
                        "Use " #namespace "::" #func " instead.")
 
248
#else
 
249
# define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \
 
250
    _GL_EXTERN_C int _gl_cxxalias_dummy
 
251
#endif
 
252
 
 
253
#endif /* _GL_CXXDEFS_H */