"Fossies" - the Fresh Open Source Software Archive

Member "rush-1.9/gnu/c++defs.h" (19 Apr 2019, 14514 Bytes) of package /linux/privat/rush-1.9.tar.xz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 /* -*- buffer-read-only: t -*- vi: set ro: */
    2 /* DO NOT EDIT! GENERATED AUTOMATICALLY! */
    3 /* C++ compatible function declaration macros.
    4    Copyright (C) 2010-2019 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    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 <https://www.gnu.org/licenses/>.  */
   18 
   19 #ifndef _GL_CXXDEFS_H
   20 #define _GL_CXXDEFS_H
   21 
   22 /* Begin/end the GNULIB_NAMESPACE namespace.  */
   23 #if defined __cplusplus && defined GNULIB_NAMESPACE
   24 # define _GL_BEGIN_NAMESPACE namespace GNULIB_NAMESPACE {
   25 # define _GL_END_NAMESPACE }
   26 #else
   27 # define _GL_BEGIN_NAMESPACE
   28 # define _GL_END_NAMESPACE
   29 #endif
   30 
   31 /* The three most frequent use cases of these macros are:
   32 
   33    * For providing a substitute for a function that is missing on some
   34      platforms, but is declared and works fine on the platforms on which
   35      it exists:
   36 
   37        #if @GNULIB_FOO@
   38        # if !@HAVE_FOO@
   39        _GL_FUNCDECL_SYS (foo, ...);
   40        # endif
   41        _GL_CXXALIAS_SYS (foo, ...);
   42        _GL_CXXALIASWARN (foo);
   43        #elif defined GNULIB_POSIXCHECK
   44        ...
   45        #endif
   46 
   47    * For providing a replacement for a function that exists on all platforms,
   48      but is broken/insufficient and needs to be replaced on some platforms:
   49 
   50        #if @GNULIB_FOO@
   51        # if @REPLACE_FOO@
   52        #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
   53        #   undef foo
   54        #   define foo rpl_foo
   55        #  endif
   56        _GL_FUNCDECL_RPL (foo, ...);
   57        _GL_CXXALIAS_RPL (foo, ...);
   58        # else
   59        _GL_CXXALIAS_SYS (foo, ...);
   60        # endif
   61        _GL_CXXALIASWARN (foo);
   62        #elif defined GNULIB_POSIXCHECK
   63        ...
   64        #endif
   65 
   66    * For providing a replacement for a function that exists on some platforms
   67      but is broken/insufficient and needs to be replaced on some of them and
   68      is additionally either missing or undeclared on some other platforms:
   69 
   70        #if @GNULIB_FOO@
   71        # if @REPLACE_FOO@
   72        #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
   73        #   undef foo
   74        #   define foo rpl_foo
   75        #  endif
   76        _GL_FUNCDECL_RPL (foo, ...);
   77        _GL_CXXALIAS_RPL (foo, ...);
   78        # else
   79        #  if !@HAVE_FOO@   or   if !@HAVE_DECL_FOO@
   80        _GL_FUNCDECL_SYS (foo, ...);
   81        #  endif
   82        _GL_CXXALIAS_SYS (foo, ...);
   83        # endif
   84        _GL_CXXALIASWARN (foo);
   85        #elif defined GNULIB_POSIXCHECK
   86        ...
   87        #endif
   88 */
   89 
   90 /* _GL_EXTERN_C declaration;
   91    performs the declaration with C linkage.  */
   92 #if defined __cplusplus
   93 # define _GL_EXTERN_C extern "C"
   94 #else
   95 # define _GL_EXTERN_C extern
   96 #endif
   97 
   98 /* _GL_FUNCDECL_RPL (func, rettype, parameters_and_attributes);
   99    declares a replacement function, named rpl_func, with the given prototype,
  100    consisting of return type, parameters, and attributes.
  101    Example:
  102      _GL_FUNCDECL_RPL (open, int, (const char *filename, int flags, ...)
  103                                   _GL_ARG_NONNULL ((1)));
  104  */
  105 #define _GL_FUNCDECL_RPL(func,rettype,parameters_and_attributes) \
  106   _GL_FUNCDECL_RPL_1 (rpl_##func, rettype, parameters_and_attributes)
  107 #define _GL_FUNCDECL_RPL_1(rpl_func,rettype,parameters_and_attributes) \
  108   _GL_EXTERN_C rettype rpl_func parameters_and_attributes
  109 
  110 /* _GL_FUNCDECL_SYS (func, rettype, parameters_and_attributes);
  111    declares the system function, named func, with the given prototype,
  112    consisting of return type, parameters, and attributes.
  113    Example:
  114      _GL_FUNCDECL_SYS (open, int, (const char *filename, int flags, ...)
  115                                   _GL_ARG_NONNULL ((1)));
  116  */
  117 #define _GL_FUNCDECL_SYS(func,rettype,parameters_and_attributes) \
  118   _GL_EXTERN_C rettype func parameters_and_attributes
  119 
  120 /* _GL_CXXALIAS_RPL (func, rettype, parameters);
  121    declares a C++ alias called GNULIB_NAMESPACE::func
  122    that redirects to rpl_func, if GNULIB_NAMESPACE is defined.
  123    Example:
  124      _GL_CXXALIAS_RPL (open, int, (const char *filename, int flags, ...));
  125 
  126    Wrapping rpl_func in an object with an inline conversion operator
  127    avoids a reference to rpl_func unless GNULIB_NAMESPACE::func is
  128    actually used in the program.  */
  129 #define _GL_CXXALIAS_RPL(func,rettype,parameters) \
  130   _GL_CXXALIAS_RPL_1 (func, rpl_##func, rettype, parameters)
  131 #if defined __cplusplus && defined GNULIB_NAMESPACE
  132 # define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \
  133     namespace GNULIB_NAMESPACE                                \
  134     {                                                         \
  135       static const struct _gl_ ## func ## _wrapper            \
  136       {                                                       \
  137         typedef rettype (*type) parameters;                   \
  138                                                               \
  139         inline operator type () const                         \
  140         {                                                     \
  141           return ::rpl_func;                                  \
  142         }                                                     \
  143       } func = {};                                            \
  144     }                                                         \
  145     _GL_EXTERN_C int _gl_cxxalias_dummy
  146 #else
  147 # define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \
  148     _GL_EXTERN_C int _gl_cxxalias_dummy
  149 #endif
  150 
  151 /* _GL_CXXALIAS_RPL_CAST_1 (func, rpl_func, rettype, parameters);
  152    is like  _GL_CXXALIAS_RPL_1 (func, rpl_func, rettype, parameters);
  153    except that the C function rpl_func may have a slightly different
  154    declaration.  A cast is used to silence the "invalid conversion" error
  155    that would otherwise occur.  */
  156 #if defined __cplusplus && defined GNULIB_NAMESPACE
  157 # define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \
  158     namespace GNULIB_NAMESPACE                                     \
  159     {                                                              \
  160       static const struct _gl_ ## func ## _wrapper                 \
  161       {                                                            \
  162         typedef rettype (*type) parameters;                        \
  163                                                                    \
  164         inline operator type () const                              \
  165         {                                                          \
  166           return reinterpret_cast<type>(::rpl_func);               \
  167         }                                                          \
  168       } func = {};                                                 \
  169     }                                                              \
  170     _GL_EXTERN_C int _gl_cxxalias_dummy
  171 #else
  172 # define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \
  173     _GL_EXTERN_C int _gl_cxxalias_dummy
  174 #endif
  175 
  176 /* _GL_CXXALIAS_SYS (func, rettype, parameters);
  177    declares a C++ alias called GNULIB_NAMESPACE::func
  178    that redirects to the system provided function func, if GNULIB_NAMESPACE
  179    is defined.
  180    Example:
  181      _GL_CXXALIAS_SYS (open, int, (const char *filename, int flags, ...));
  182 
  183    Wrapping func in an object with an inline conversion operator
  184    avoids a reference to func unless GNULIB_NAMESPACE::func is
  185    actually used in the program.  */
  186 #if defined __cplusplus && defined GNULIB_NAMESPACE
  187 # define _GL_CXXALIAS_SYS(func,rettype,parameters)            \
  188     namespace GNULIB_NAMESPACE                                \
  189     {                                                         \
  190       static const struct _gl_ ## func ## _wrapper            \
  191       {                                                       \
  192         typedef rettype (*type) parameters;                   \
  193                                                               \
  194         inline operator type () const                         \
  195         {                                                     \
  196           return ::func;                                      \
  197         }                                                     \
  198       } func = {};                                            \
  199     }                                                         \
  200     _GL_EXTERN_C int _gl_cxxalias_dummy
  201 #else
  202 # define _GL_CXXALIAS_SYS(func,rettype,parameters) \
  203     _GL_EXTERN_C int _gl_cxxalias_dummy
  204 #endif
  205 
  206 /* _GL_CXXALIAS_SYS_CAST (func, rettype, parameters);
  207    is like  _GL_CXXALIAS_SYS (func, rettype, parameters);
  208    except that the C function func may have a slightly different declaration.
  209    A cast is used to silence the "invalid conversion" error that would
  210    otherwise occur.  */
  211 #if defined __cplusplus && defined GNULIB_NAMESPACE
  212 # define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \
  213     namespace GNULIB_NAMESPACE                          \
  214     {                                                   \
  215       static const struct _gl_ ## func ## _wrapper      \
  216       {                                                 \
  217         typedef rettype (*type) parameters;             \
  218                                                         \
  219         inline operator type () const                   \
  220         {                                               \
  221           return reinterpret_cast<type>(::func);        \
  222         }                                               \
  223       } func = {};                                      \
  224     }                                                   \
  225     _GL_EXTERN_C int _gl_cxxalias_dummy
  226 #else
  227 # define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \
  228     _GL_EXTERN_C int _gl_cxxalias_dummy
  229 #endif
  230 
  231 /* _GL_CXXALIAS_SYS_CAST2 (func, rettype, parameters, rettype2, parameters2);
  232    is like  _GL_CXXALIAS_SYS (func, rettype, parameters);
  233    except that the C function is picked among a set of overloaded functions,
  234    namely the one with rettype2 and parameters2.  Two consecutive casts
  235    are used to silence the "cannot find a match" and "invalid conversion"
  236    errors that would otherwise occur.  */
  237 #if defined __cplusplus && defined GNULIB_NAMESPACE
  238   /* The outer cast must be a reinterpret_cast.
  239      The inner cast: When the function is defined as a set of overloaded
  240      functions, it works as a static_cast<>, choosing the designated variant.
  241      When the function is defined as a single variant, it works as a
  242      reinterpret_cast<>. The parenthesized cast syntax works both ways.  */
  243 # define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \
  244     namespace GNULIB_NAMESPACE                                                \
  245     {                                                                         \
  246       static const struct _gl_ ## func ## _wrapper                            \
  247       {                                                                       \
  248         typedef rettype (*type) parameters;                                   \
  249                                                                               \
  250         inline operator type () const                                         \
  251         {                                                                     \
  252           return reinterpret_cast<type>((rettype2 (*) parameters2)(::func));  \
  253         }                                                                     \
  254       } func = {};                                                            \
  255     }                                                                         \
  256     _GL_EXTERN_C int _gl_cxxalias_dummy
  257 #else
  258 # define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \
  259     _GL_EXTERN_C int _gl_cxxalias_dummy
  260 #endif
  261 
  262 /* _GL_CXXALIASWARN (func);
  263    causes a warning to be emitted when ::func is used but not when
  264    GNULIB_NAMESPACE::func is used.  func must be defined without overloaded
  265    variants.  */
  266 #if defined __cplusplus && defined GNULIB_NAMESPACE
  267 # define _GL_CXXALIASWARN(func) \
  268    _GL_CXXALIASWARN_1 (func, GNULIB_NAMESPACE)
  269 # define _GL_CXXALIASWARN_1(func,namespace) \
  270    _GL_CXXALIASWARN_2 (func, namespace)
  271 /* To work around GCC bug <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>,
  272    we enable the warning only when not optimizing.  */
  273 # if !__OPTIMIZE__
  274 #  define _GL_CXXALIASWARN_2(func,namespace) \
  275     _GL_WARN_ON_USE (func, \
  276                      "The symbol ::" #func " refers to the system function. " \
  277                      "Use " #namespace "::" #func " instead.")
  278 # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
  279 #  define _GL_CXXALIASWARN_2(func,namespace) \
  280      extern __typeof__ (func) func
  281 # else
  282 #  define _GL_CXXALIASWARN_2(func,namespace) \
  283      _GL_EXTERN_C int _gl_cxxalias_dummy
  284 # endif
  285 #else
  286 # define _GL_CXXALIASWARN(func) \
  287     _GL_EXTERN_C int _gl_cxxalias_dummy
  288 #endif
  289 
  290 /* _GL_CXXALIASWARN1 (func, rettype, parameters_and_attributes);
  291    causes a warning to be emitted when the given overloaded variant of ::func
  292    is used but not when GNULIB_NAMESPACE::func is used.  */
  293 #if defined __cplusplus && defined GNULIB_NAMESPACE
  294 # define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \
  295    _GL_CXXALIASWARN1_1 (func, rettype, parameters_and_attributes, \
  296                         GNULIB_NAMESPACE)
  297 # define _GL_CXXALIASWARN1_1(func,rettype,parameters_and_attributes,namespace) \
  298    _GL_CXXALIASWARN1_2 (func, rettype, parameters_and_attributes, namespace)
  299 /* To work around GCC bug <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>,
  300    we enable the warning only when not optimizing.  */
  301 # if !__OPTIMIZE__
  302 #  define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
  303     _GL_WARN_ON_USE_CXX (func, rettype, parameters_and_attributes, \
  304                          "The symbol ::" #func " refers to the system function. " \
  305                          "Use " #namespace "::" #func " instead.")
  306 # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
  307 #  define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
  308      extern __typeof__ (func) func
  309 # else
  310 #  define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
  311      _GL_EXTERN_C int _gl_cxxalias_dummy
  312 # endif
  313 #else
  314 # define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \
  315     _GL_EXTERN_C int _gl_cxxalias_dummy
  316 #endif
  317 
  318 #endif /* _GL_CXXDEFS_H */