a5bd9f6
From d02bf953c4fb2eb34998274b304bf1a2ac755c89 Mon Sep 17 00:00:00 2001
a5bd9f6
From: Vladimir 'phcoder' Serbinenko <phcoder@gmail.com>
a5bd9f6
Date: Wed, 17 Apr 2013 07:00:37 +0200
a5bd9f6
Subject: [PATCH 320/364] 	* build-aux/snippet: Add missing gnulib files.
a5bd9f6
a5bd9f6
---
a5bd9f6
 ChangeLog                       |   4 +
a5bd9f6
 build-aux/snippet/_Noreturn.h   |  10 ++
a5bd9f6
 build-aux/snippet/arg-nonnull.h |  26 ++++
a5bd9f6
 build-aux/snippet/c++defs.h     | 271 ++++++++++++++++++++++++++++++++++++++++
a5bd9f6
 build-aux/snippet/warn-on-use.h | 109 ++++++++++++++++
a5bd9f6
 5 files changed, 420 insertions(+)
a5bd9f6
 create mode 100644 build-aux/snippet/_Noreturn.h
a5bd9f6
 create mode 100644 build-aux/snippet/arg-nonnull.h
a5bd9f6
 create mode 100644 build-aux/snippet/c++defs.h
a5bd9f6
 create mode 100644 build-aux/snippet/warn-on-use.h
a5bd9f6
a5bd9f6
diff --git a/ChangeLog b/ChangeLog
a5bd9f6
index b60a71d..073207a 100644
a5bd9f6
--- a/ChangeLog
a5bd9f6
+++ b/ChangeLog
a5bd9f6
@@ -1,3 +1,7 @@
a5bd9f6
+2013-04-17  Vladimir Serbinenko  <phcoder@gmail.com>
a5bd9f6
+
a5bd9f6
+	* build-aux/snippet: Add missing gnulib files.
a5bd9f6
+
a5bd9f6
 2013-04-16  Andrey Borzenkov <arvidjaar@gmail.com>
a5bd9f6
 
a5bd9f6
 	* grub-core/disk/efi/efidisk.c: Really limit transfer chunk size.
a5bd9f6
diff --git a/build-aux/snippet/_Noreturn.h b/build-aux/snippet/_Noreturn.h
a5bd9f6
new file mode 100644
a5bd9f6
index 0000000..c44ad89
a5bd9f6
--- /dev/null
a5bd9f6
+++ b/build-aux/snippet/_Noreturn.h
a5bd9f6
@@ -0,0 +1,10 @@
a5bd9f6
+#if !defined _Noreturn && __STDC_VERSION__ < 201112
a5bd9f6
+# if (3 <= __GNUC__ || (__GNUC__ == 2 && 8 <= __GNUC_MINOR__) \
a5bd9f6
+      || 0x5110 <= __SUNPRO_C)
a5bd9f6
+#  define _Noreturn __attribute__ ((__noreturn__))
a5bd9f6
+# elif 1200 <= _MSC_VER
a5bd9f6
+#  define _Noreturn __declspec (noreturn)
a5bd9f6
+# else
a5bd9f6
+#  define _Noreturn
a5bd9f6
+# endif
a5bd9f6
+#endif
a5bd9f6
diff --git a/build-aux/snippet/arg-nonnull.h b/build-aux/snippet/arg-nonnull.h
a5bd9f6
new file mode 100644
a5bd9f6
index 0000000..8ea2a47
a5bd9f6
--- /dev/null
a5bd9f6
+++ b/build-aux/snippet/arg-nonnull.h
a5bd9f6
@@ -0,0 +1,26 @@
a5bd9f6
+/* A C macro for declaring that specific arguments must not be NULL.
a5bd9f6
+   Copyright (C) 2009-2013 Free Software Foundation, Inc.
a5bd9f6
+
a5bd9f6
+   This program is free software: you can redistribute it and/or modify it
a5bd9f6
+   under the terms of the GNU General Public License as published
a5bd9f6
+   by the Free Software Foundation; either version 3 of the License, or
a5bd9f6
+   (at your option) any later version.
a5bd9f6
+
a5bd9f6
+   This program is distributed in the hope that it will be useful,
a5bd9f6
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
a5bd9f6
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
a5bd9f6
+   General Public License for more details.
a5bd9f6
+
a5bd9f6
+   You should have received a copy of the GNU General Public License
a5bd9f6
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
a5bd9f6
+
a5bd9f6
+/* _GL_ARG_NONNULL((n,...,m)) tells the compiler and static analyzer tools
a5bd9f6
+   that the values passed as arguments n, ..., m must be non-NULL pointers.
a5bd9f6
+   n = 1 stands for the first argument, n = 2 for the second argument etc.  */
a5bd9f6
+#ifndef _GL_ARG_NONNULL
a5bd9f6
+# if (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) || __GNUC__ > 3
a5bd9f6
+#  define _GL_ARG_NONNULL(params) __attribute__ ((__nonnull__ params))
a5bd9f6
+# else
a5bd9f6
+#  define _GL_ARG_NONNULL(params)
a5bd9f6
+# endif
a5bd9f6
+#endif
a5bd9f6
diff --git a/build-aux/snippet/c++defs.h b/build-aux/snippet/c++defs.h
a5bd9f6
new file mode 100644
a5bd9f6
index 0000000..b35b933
a5bd9f6
--- /dev/null
a5bd9f6
+++ b/build-aux/snippet/c++defs.h
a5bd9f6
@@ -0,0 +1,271 @@
a5bd9f6
+/* C++ compatible function declaration macros.
a5bd9f6
+   Copyright (C) 2010-2013 Free Software Foundation, Inc.
a5bd9f6
+
a5bd9f6
+   This program is free software: you can redistribute it and/or modify it
a5bd9f6
+   under the terms of the GNU General Public License as published
a5bd9f6
+   by the Free Software Foundation; either version 3 of the License, or
a5bd9f6
+   (at your option) any later version.
a5bd9f6
+
a5bd9f6
+   This program is distributed in the hope that it will be useful,
a5bd9f6
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
a5bd9f6
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
a5bd9f6
+   General Public License for more details.
a5bd9f6
+
a5bd9f6
+   You should have received a copy of the GNU General Public License
a5bd9f6
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
a5bd9f6
+
a5bd9f6
+#ifndef _GL_CXXDEFS_H
a5bd9f6
+#define _GL_CXXDEFS_H
a5bd9f6
+
a5bd9f6
+/* The three most frequent use cases of these macros are:
a5bd9f6
+
a5bd9f6
+   * For providing a substitute for a function that is missing on some
a5bd9f6
+     platforms, but is declared and works fine on the platforms on which
a5bd9f6
+     it exists:
a5bd9f6
+
a5bd9f6
+       #if @GNULIB_FOO@
a5bd9f6
+       # if !@HAVE_FOO@
a5bd9f6
+       _GL_FUNCDECL_SYS (foo, ...);
a5bd9f6
+       # endif
a5bd9f6
+       _GL_CXXALIAS_SYS (foo, ...);
a5bd9f6
+       _GL_CXXALIASWARN (foo);
a5bd9f6
+       #elif defined GNULIB_POSIXCHECK
a5bd9f6
+       ...
a5bd9f6
+       #endif
a5bd9f6
+
a5bd9f6
+   * For providing a replacement for a function that exists on all platforms,
a5bd9f6
+     but is broken/insufficient and needs to be replaced on some platforms:
a5bd9f6
+
a5bd9f6
+       #if @GNULIB_FOO@
a5bd9f6
+       # if @REPLACE_FOO@
a5bd9f6
+       #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
a5bd9f6
+       #   undef foo
a5bd9f6
+       #   define foo rpl_foo
a5bd9f6
+       #  endif
a5bd9f6
+       _GL_FUNCDECL_RPL (foo, ...);
a5bd9f6
+       _GL_CXXALIAS_RPL (foo, ...);
a5bd9f6
+       # else
a5bd9f6
+       _GL_CXXALIAS_SYS (foo, ...);
a5bd9f6
+       # endif
a5bd9f6
+       _GL_CXXALIASWARN (foo);
a5bd9f6
+       #elif defined GNULIB_POSIXCHECK
a5bd9f6
+       ...
a5bd9f6
+       #endif
a5bd9f6
+
a5bd9f6
+   * For providing a replacement for a function that exists on some platforms
a5bd9f6
+     but is broken/insufficient and needs to be replaced on some of them and
a5bd9f6
+     is additionally either missing or undeclared on some other platforms:
a5bd9f6
+
a5bd9f6
+       #if @GNULIB_FOO@
a5bd9f6
+       # if @REPLACE_FOO@
a5bd9f6
+       #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
a5bd9f6
+       #   undef foo
a5bd9f6
+       #   define foo rpl_foo
a5bd9f6
+       #  endif
a5bd9f6
+       _GL_FUNCDECL_RPL (foo, ...);
a5bd9f6
+       _GL_CXXALIAS_RPL (foo, ...);
a5bd9f6
+       # else
a5bd9f6
+       #  if !@HAVE_FOO@   or   if !@HAVE_DECL_FOO@
a5bd9f6
+       _GL_FUNCDECL_SYS (foo, ...);
a5bd9f6
+       #  endif
a5bd9f6
+       _GL_CXXALIAS_SYS (foo, ...);
a5bd9f6
+       # endif
a5bd9f6
+       _GL_CXXALIASWARN (foo);
a5bd9f6
+       #elif defined GNULIB_POSIXCHECK
a5bd9f6
+       ...
a5bd9f6
+       #endif
a5bd9f6
+*/
a5bd9f6
+
a5bd9f6
+/* _GL_EXTERN_C declaration;
a5bd9f6
+   performs the declaration with C linkage.  */
a5bd9f6
+#if defined __cplusplus
a5bd9f6
+# define _GL_EXTERN_C extern "C"
a5bd9f6
+#else
a5bd9f6
+# define _GL_EXTERN_C extern
a5bd9f6
+#endif
a5bd9f6
+
a5bd9f6
+/* _GL_FUNCDECL_RPL (func, rettype, parameters_and_attributes);
a5bd9f6
+   declares a replacement function, named rpl_func, with the given prototype,
a5bd9f6
+   consisting of return type, parameters, and attributes.
a5bd9f6
+   Example:
a5bd9f6
+     _GL_FUNCDECL_RPL (open, int, (const char *filename, int flags, ...)
a5bd9f6
+                                  _GL_ARG_NONNULL ((1)));
a5bd9f6
+ */
a5bd9f6
+#define _GL_FUNCDECL_RPL(func,rettype,parameters_and_attributes) \
a5bd9f6
+  _GL_FUNCDECL_RPL_1 (rpl_##func, rettype, parameters_and_attributes)
a5bd9f6
+#define _GL_FUNCDECL_RPL_1(rpl_func,rettype,parameters_and_attributes) \
a5bd9f6
+  _GL_EXTERN_C rettype rpl_func parameters_and_attributes
a5bd9f6
+
a5bd9f6
+/* _GL_FUNCDECL_SYS (func, rettype, parameters_and_attributes);
a5bd9f6
+   declares the system function, named func, with the given prototype,
a5bd9f6
+   consisting of return type, parameters, and attributes.
a5bd9f6
+   Example:
a5bd9f6
+     _GL_FUNCDECL_SYS (open, int, (const char *filename, int flags, ...)
a5bd9f6
+                                  _GL_ARG_NONNULL ((1)));
a5bd9f6
+ */
a5bd9f6
+#define _GL_FUNCDECL_SYS(func,rettype,parameters_and_attributes) \
a5bd9f6
+  _GL_EXTERN_C rettype func parameters_and_attributes
a5bd9f6
+
a5bd9f6
+/* _GL_CXXALIAS_RPL (func, rettype, parameters);
a5bd9f6
+   declares a C++ alias called GNULIB_NAMESPACE::func
a5bd9f6
+   that redirects to rpl_func, if GNULIB_NAMESPACE is defined.
a5bd9f6
+   Example:
a5bd9f6
+     _GL_CXXALIAS_RPL (open, int, (const char *filename, int flags, ...));
a5bd9f6
+ */
a5bd9f6
+#define _GL_CXXALIAS_RPL(func,rettype,parameters) \
a5bd9f6
+  _GL_CXXALIAS_RPL_1 (func, rpl_##func, rettype, parameters)
a5bd9f6
+#if defined __cplusplus && defined GNULIB_NAMESPACE
a5bd9f6
+# define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \
a5bd9f6
+    namespace GNULIB_NAMESPACE                                \
a5bd9f6
+    {                                                         \
a5bd9f6
+      rettype (*const func) parameters = ::rpl_func;          \
a5bd9f6
+    }                                                         \
a5bd9f6
+    _GL_EXTERN_C int _gl_cxxalias_dummy
a5bd9f6
+#else
a5bd9f6
+# define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \
a5bd9f6
+    _GL_EXTERN_C int _gl_cxxalias_dummy
a5bd9f6
+#endif
a5bd9f6
+
a5bd9f6
+/* _GL_CXXALIAS_RPL_CAST_1 (func, rpl_func, rettype, parameters);
a5bd9f6
+   is like  _GL_CXXALIAS_RPL_1 (func, rpl_func, rettype, parameters);
a5bd9f6
+   except that the C function rpl_func may have a slightly different
a5bd9f6
+   declaration.  A cast is used to silence the "invalid conversion" error
a5bd9f6
+   that would otherwise occur.  */
a5bd9f6
+#if defined __cplusplus && defined GNULIB_NAMESPACE
a5bd9f6
+# define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \
a5bd9f6
+    namespace GNULIB_NAMESPACE                                     \
a5bd9f6
+    {                                                              \
a5bd9f6
+      rettype (*const func) parameters =                           \
a5bd9f6
+        reinterpret_cast<rettype(*)parameters>(::rpl_func);        \
a5bd9f6
+    }                                                              \
a5bd9f6
+    _GL_EXTERN_C int _gl_cxxalias_dummy
a5bd9f6
+#else
a5bd9f6
+# define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \
a5bd9f6
+    _GL_EXTERN_C int _gl_cxxalias_dummy
a5bd9f6
+#endif
a5bd9f6
+
a5bd9f6
+/* _GL_CXXALIAS_SYS (func, rettype, parameters);
a5bd9f6
+   declares a C++ alias called GNULIB_NAMESPACE::func
a5bd9f6
+   that redirects to the system provided function func, if GNULIB_NAMESPACE
a5bd9f6
+   is defined.
a5bd9f6
+   Example:
a5bd9f6
+     _GL_CXXALIAS_SYS (open, int, (const char *filename, int flags, ...));
a5bd9f6
+ */
a5bd9f6
+#if defined __cplusplus && defined GNULIB_NAMESPACE
a5bd9f6
+  /* If we were to write
a5bd9f6
+       rettype (*const func) parameters = ::func;
a5bd9f6
+     like above in _GL_CXXALIAS_RPL_1, the compiler could optimize calls
a5bd9f6
+     better (remove an indirection through a 'static' pointer variable),
a5bd9f6
+     but then the _GL_CXXALIASWARN macro below would cause a warning not only
a5bd9f6
+     for uses of ::func but also for uses of GNULIB_NAMESPACE::func.  */
a5bd9f6
+# define _GL_CXXALIAS_SYS(func,rettype,parameters) \
a5bd9f6
+    namespace GNULIB_NAMESPACE                     \
a5bd9f6
+    {                                              \
a5bd9f6
+      static rettype (*func) parameters = ::func;  \
a5bd9f6
+    }                                              \
a5bd9f6
+    _GL_EXTERN_C int _gl_cxxalias_dummy
a5bd9f6
+#else
a5bd9f6
+# define _GL_CXXALIAS_SYS(func,rettype,parameters) \
a5bd9f6
+    _GL_EXTERN_C int _gl_cxxalias_dummy
a5bd9f6
+#endif
a5bd9f6
+
a5bd9f6
+/* _GL_CXXALIAS_SYS_CAST (func, rettype, parameters);
a5bd9f6
+   is like  _GL_CXXALIAS_SYS (func, rettype, parameters);
a5bd9f6
+   except that the C function func may have a slightly different declaration.
a5bd9f6
+   A cast is used to silence the "invalid conversion" error that would
a5bd9f6
+   otherwise occur.  */
a5bd9f6
+#if defined __cplusplus && defined GNULIB_NAMESPACE
a5bd9f6
+# define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \
a5bd9f6
+    namespace GNULIB_NAMESPACE                          \
a5bd9f6
+    {                                                   \
a5bd9f6
+      static rettype (*func) parameters =               \
a5bd9f6
+        reinterpret_cast<rettype(*)parameters>(::func); \
a5bd9f6
+    }                                                   \
a5bd9f6
+    _GL_EXTERN_C int _gl_cxxalias_dummy
a5bd9f6
+#else
a5bd9f6
+# define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \
a5bd9f6
+    _GL_EXTERN_C int _gl_cxxalias_dummy
a5bd9f6
+#endif
a5bd9f6
+
a5bd9f6
+/* _GL_CXXALIAS_SYS_CAST2 (func, rettype, parameters, rettype2, parameters2);
a5bd9f6
+   is like  _GL_CXXALIAS_SYS (func, rettype, parameters);
a5bd9f6
+   except that the C function is picked among a set of overloaded functions,
a5bd9f6
+   namely the one with rettype2 and parameters2.  Two consecutive casts
a5bd9f6
+   are used to silence the "cannot find a match" and "invalid conversion"
a5bd9f6
+   errors that would otherwise occur.  */
a5bd9f6
+#if defined __cplusplus && defined GNULIB_NAMESPACE
a5bd9f6
+  /* The outer cast must be a reinterpret_cast.
a5bd9f6
+     The inner cast: When the function is defined as a set of overloaded
a5bd9f6
+     functions, it works as a static_cast<>, choosing the designated variant.
a5bd9f6
+     When the function is defined as a single variant, it works as a
a5bd9f6
+     reinterpret_cast<>. The parenthesized cast syntax works both ways.  */
a5bd9f6
+# define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \
a5bd9f6
+    namespace GNULIB_NAMESPACE                                                \
a5bd9f6
+    {                                                                         \
a5bd9f6
+      static rettype (*func) parameters =                                     \
a5bd9f6
+        reinterpret_cast<rettype(*)parameters>(                               \
a5bd9f6
+          (rettype2(*)parameters2)(::func));                                  \
a5bd9f6
+    }                                                                         \
a5bd9f6
+    _GL_EXTERN_C int _gl_cxxalias_dummy
a5bd9f6
+#else
a5bd9f6
+# define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \
a5bd9f6
+    _GL_EXTERN_C int _gl_cxxalias_dummy
a5bd9f6
+#endif
a5bd9f6
+
a5bd9f6
+/* _GL_CXXALIASWARN (func);
a5bd9f6
+   causes a warning to be emitted when ::func is used but not when
a5bd9f6
+   GNULIB_NAMESPACE::func is used.  func must be defined without overloaded
a5bd9f6
+   variants.  */
a5bd9f6
+#if defined __cplusplus && defined GNULIB_NAMESPACE
a5bd9f6
+# define _GL_CXXALIASWARN(func) \
a5bd9f6
+   _GL_CXXALIASWARN_1 (func, GNULIB_NAMESPACE)
a5bd9f6
+# define _GL_CXXALIASWARN_1(func,namespace) \
a5bd9f6
+   _GL_CXXALIASWARN_2 (func, namespace)
a5bd9f6
+/* To work around GCC bug <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>,
a5bd9f6
+   we enable the warning only when not optimizing.  */
a5bd9f6
+# if !__OPTIMIZE__
a5bd9f6
+#  define _GL_CXXALIASWARN_2(func,namespace) \
a5bd9f6
+    _GL_WARN_ON_USE (func, \
a5bd9f6
+                     "The symbol ::" #func " refers to the system function. " \
a5bd9f6
+                     "Use " #namespace "::" #func " instead.")
a5bd9f6
+# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
a5bd9f6
+#  define _GL_CXXALIASWARN_2(func,namespace) \
a5bd9f6
+     extern __typeof__ (func) func
a5bd9f6
+# else
a5bd9f6
+#  define _GL_CXXALIASWARN_2(func,namespace) \
a5bd9f6
+     _GL_EXTERN_C int _gl_cxxalias_dummy
a5bd9f6
+# endif
a5bd9f6
+#else
a5bd9f6
+# define _GL_CXXALIASWARN(func) \
a5bd9f6
+    _GL_EXTERN_C int _gl_cxxalias_dummy
a5bd9f6
+#endif
a5bd9f6
+
a5bd9f6
+/* _GL_CXXALIASWARN1 (func, rettype, parameters_and_attributes);
a5bd9f6
+   causes a warning to be emitted when the given overloaded variant of ::func
a5bd9f6
+   is used but not when GNULIB_NAMESPACE::func is used.  */
a5bd9f6
+#if defined __cplusplus && defined GNULIB_NAMESPACE
a5bd9f6
+# define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \
a5bd9f6
+   _GL_CXXALIASWARN1_1 (func, rettype, parameters_and_attributes, \
a5bd9f6
+                        GNULIB_NAMESPACE)
a5bd9f6
+# define _GL_CXXALIASWARN1_1(func,rettype,parameters_and_attributes,namespace) \
a5bd9f6
+   _GL_CXXALIASWARN1_2 (func, rettype, parameters_and_attributes, namespace)
a5bd9f6
+/* To work around GCC bug <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>,
a5bd9f6
+   we enable the warning only when not optimizing.  */
a5bd9f6
+# if !__OPTIMIZE__
a5bd9f6
+#  define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
a5bd9f6
+    _GL_WARN_ON_USE_CXX (func, rettype, parameters_and_attributes, \
a5bd9f6
+                         "The symbol ::" #func " refers to the system function. " \
a5bd9f6
+                         "Use " #namespace "::" #func " instead.")
a5bd9f6
+# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
a5bd9f6
+#  define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
a5bd9f6
+     extern __typeof__ (func) func
a5bd9f6
+# else
a5bd9f6
+#  define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
a5bd9f6
+     _GL_EXTERN_C int _gl_cxxalias_dummy
a5bd9f6
+# endif
a5bd9f6
+#else
a5bd9f6
+# define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \
a5bd9f6
+    _GL_EXTERN_C int _gl_cxxalias_dummy
a5bd9f6
+#endif
a5bd9f6
+
a5bd9f6
+#endif /* _GL_CXXDEFS_H */
a5bd9f6
diff --git a/build-aux/snippet/warn-on-use.h b/build-aux/snippet/warn-on-use.h
a5bd9f6
new file mode 100644
a5bd9f6
index 0000000..1736a1b
a5bd9f6
--- /dev/null
a5bd9f6
+++ b/build-aux/snippet/warn-on-use.h
a5bd9f6
@@ -0,0 +1,109 @@
a5bd9f6
+/* A C macro for emitting warnings if a function is used.
a5bd9f6
+   Copyright (C) 2010-2013 Free Software Foundation, Inc.
a5bd9f6
+
a5bd9f6
+   This program is free software: you can redistribute it and/or modify it
a5bd9f6
+   under the terms of the GNU General Public License as published
a5bd9f6
+   by the Free Software Foundation; either version 3 of the License, or
a5bd9f6
+   (at your option) any later version.
a5bd9f6
+
a5bd9f6
+   This program is distributed in the hope that it will be useful,
a5bd9f6
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
a5bd9f6
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
a5bd9f6
+   General Public License for more details.
a5bd9f6
+
a5bd9f6
+   You should have received a copy of the GNU General Public License
a5bd9f6
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
a5bd9f6
+
a5bd9f6
+/* _GL_WARN_ON_USE (function, "literal string") issues a declaration
a5bd9f6
+   for FUNCTION which will then trigger a compiler warning containing
a5bd9f6
+   the text of "literal string" anywhere that function is called, if
a5bd9f6
+   supported by the compiler.  If the compiler does not support this
a5bd9f6
+   feature, the macro expands to an unused extern declaration.
a5bd9f6
+
a5bd9f6
+   This macro is useful for marking a function as a potential
a5bd9f6
+   portability trap, with the intent that "literal string" include
a5bd9f6
+   instructions on the replacement function that should be used
a5bd9f6
+   instead.  However, one of the reasons that a function is a
a5bd9f6
+   portability trap is if it has the wrong signature.  Declaring
a5bd9f6
+   FUNCTION with a different signature in C is a compilation error, so
a5bd9f6
+   this macro must use the same type as any existing declaration so
a5bd9f6
+   that programs that avoid the problematic FUNCTION do not fail to
a5bd9f6
+   compile merely because they included a header that poisoned the
a5bd9f6
+   function.  But this implies that _GL_WARN_ON_USE is only safe to
a5bd9f6
+   use if FUNCTION is known to already have a declaration.  Use of
a5bd9f6
+   this macro implies that there must not be any other macro hiding
a5bd9f6
+   the declaration of FUNCTION; but undefining FUNCTION first is part
a5bd9f6
+   of the poisoning process anyway (although for symbols that are
a5bd9f6
+   provided only via a macro, the result is a compilation error rather
a5bd9f6
+   than a warning containing "literal string").  Also note that in
a5bd9f6
+   C++, it is only safe to use if FUNCTION has no overloads.
a5bd9f6
+
a5bd9f6
+   For an example, it is possible to poison 'getline' by:
a5bd9f6
+   - adding a call to gl_WARN_ON_USE_PREPARE([[#include <stdio.h>]],
a5bd9f6
+     [getline]) in configure.ac, which potentially defines
a5bd9f6
+     HAVE_RAW_DECL_GETLINE
a5bd9f6
+   - adding this code to a header that wraps the system <stdio.h>:
a5bd9f6
+     #undef getline
a5bd9f6
+     #if HAVE_RAW_DECL_GETLINE
a5bd9f6
+     _GL_WARN_ON_USE (getline, "getline is required by POSIX 2008, but"
a5bd9f6
+       "not universally present; use the gnulib module getline");
a5bd9f6
+     #endif
a5bd9f6
+
a5bd9f6
+   It is not possible to directly poison global variables.  But it is
a5bd9f6
+   possible to write a wrapper accessor function, and poison that
a5bd9f6
+   (less common usage, like &environ, will cause a compilation error
a5bd9f6
+   rather than issue the nice warning, but the end result of informing
a5bd9f6
+   the developer about their portability problem is still achieved):
a5bd9f6
+   #if HAVE_RAW_DECL_ENVIRON
a5bd9f6
+   static char ***rpl_environ (void) { return &environ; }
a5bd9f6
+   _GL_WARN_ON_USE (rpl_environ, "environ is not always properly declared");
a5bd9f6
+   # undef environ
a5bd9f6
+   # define environ (*rpl_environ ())
a5bd9f6
+   #endif
a5bd9f6
+   */
a5bd9f6
+#ifndef _GL_WARN_ON_USE
a5bd9f6
+
a5bd9f6
+# if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__)
a5bd9f6
+/* A compiler attribute is available in gcc versions 4.3.0 and later.  */
a5bd9f6
+#  define _GL_WARN_ON_USE(function, message) \
a5bd9f6
+extern __typeof__ (function) function __attribute__ ((__warning__ (message)))
a5bd9f6
+# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
a5bd9f6
+/* Verify the existence of the function.  */
a5bd9f6
+#  define _GL_WARN_ON_USE(function, message) \
a5bd9f6
+extern __typeof__ (function) function
a5bd9f6
+# else /* Unsupported.  */
a5bd9f6
+#  define _GL_WARN_ON_USE(function, message) \
a5bd9f6
+_GL_WARN_EXTERN_C int _gl_warn_on_use
a5bd9f6
+# endif
a5bd9f6
+#endif
a5bd9f6
+
a5bd9f6
+/* _GL_WARN_ON_USE_CXX (function, rettype, parameters_and_attributes, "string")
a5bd9f6
+   is like _GL_WARN_ON_USE (function, "string"), except that the function is
a5bd9f6
+   declared with the given prototype, consisting of return type, parameters,
a5bd9f6
+   and attributes.
a5bd9f6
+   This variant is useful for overloaded functions in C++. _GL_WARN_ON_USE does
a5bd9f6
+   not work in this case.  */
a5bd9f6
+#ifndef _GL_WARN_ON_USE_CXX
a5bd9f6
+# if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__)
a5bd9f6
+#  define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
a5bd9f6
+extern rettype function parameters_and_attributes \
a5bd9f6
+     __attribute__ ((__warning__ (msg)))
a5bd9f6
+# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
a5bd9f6
+/* Verify the existence of the function.  */
a5bd9f6
+#  define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
a5bd9f6
+extern rettype function parameters_and_attributes
a5bd9f6
+# else /* Unsupported.  */
a5bd9f6
+#  define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
a5bd9f6
+_GL_WARN_EXTERN_C int _gl_warn_on_use
a5bd9f6
+# endif
a5bd9f6
+#endif
a5bd9f6
+
a5bd9f6
+/* _GL_WARN_EXTERN_C declaration;
a5bd9f6
+   performs the declaration with C linkage.  */
a5bd9f6
+#ifndef _GL_WARN_EXTERN_C
a5bd9f6
+# if defined __cplusplus
a5bd9f6
+#  define _GL_WARN_EXTERN_C extern "C"
a5bd9f6
+# else
a5bd9f6
+#  define _GL_WARN_EXTERN_C extern
a5bd9f6
+# endif
a5bd9f6
+#endif
a5bd9f6
-- 
a5bd9f6
1.8.1.4
a5bd9f6