diff options
author | Thomas Guyot-Sionnest <dermoth@aei.ca> | 2010-04-08 01:11:46 (GMT) |
---|---|---|
committer | Thomas Guyot-Sionnest <dermoth@aei.ca> | 2010-04-13 01:26:35 (GMT) |
commit | 74da141e618ef99959d509cb2e7be35a348a39db (patch) | |
tree | 88ebc38b381a1021fc2d74864a71e230ae591c3d /build-aux | |
parent | c63a4f726a0b6ad8cf6040f947754a81fd4683bb (diff) | |
download | monitoring-plugins-74da141e618ef99959d509cb2e7be35a348a39db.tar.gz |
Sync with the latest Gnulib code (177f525)
Signed-off-by: Thomas Guyot-Sionnest <dermoth@aei.ca>
Diffstat (limited to 'build-aux')
-rw-r--r-- | build-aux/arg-nonnull.h | 26 | ||||
-rw-r--r-- | build-aux/c++defs.h | 251 | ||||
-rwxr-xr-x | build-aux/config.rpath | 2 | ||||
-rwxr-xr-x | build-aux/mkinstalldirs | 158 | ||||
-rw-r--r-- | build-aux/warn-on-use.h | 102 |
5 files changed, 380 insertions, 159 deletions
diff --git a/build-aux/arg-nonnull.h b/build-aux/arg-nonnull.h new file mode 100644 index 0000000..7e3e2db --- /dev/null +++ b/build-aux/arg-nonnull.h | |||
@@ -0,0 +1,26 @@ | |||
1 | /* A C macro for declaring that specific arguments must not be NULL. | ||
2 | Copyright (C) 2009, 2010 Free Software Foundation, Inc. | ||
3 | |||
4 | This program is free software: you can redistribute it and/or modify it | ||
5 | under the terms of the GNU General Public License as published | ||
6 | by the Free Software Foundation; either version 3 of the License, or | ||
7 | (at your option) any later version. | ||
8 | |||
9 | This program is distributed in the hope that it will be useful, | ||
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
12 | Lesser General Public License for more details. | ||
13 | |||
14 | You should have received a copy of the GNU General Public License | ||
15 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ | ||
16 | |||
17 | /* _GL_ARG_NONNULL((n,...,m)) tells the compiler and static analyzer tools | ||
18 | that the values passed as arguments n, ..., m must be non-NULL pointers. | ||
19 | n = 1 stands for the first argument, n = 2 for the second argument etc. */ | ||
20 | #ifndef _GL_ARG_NONNULL | ||
21 | # if (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) || __GNUC__ > 3 | ||
22 | # define _GL_ARG_NONNULL(params) __attribute__ ((__nonnull__ params)) | ||
23 | # else | ||
24 | # define _GL_ARG_NONNULL(params) | ||
25 | # endif | ||
26 | #endif | ||
diff --git a/build-aux/c++defs.h b/build-aux/c++defs.h new file mode 100644 index 0000000..7d71089 --- /dev/null +++ b/build-aux/c++defs.h | |||
@@ -0,0 +1,251 @@ | |||
1 | /* C++ compatible function declaration macros. | ||
2 | Copyright (C) 2010 Free Software Foundation, Inc. | ||
3 | |||
4 | This program is free software: you can redistribute it and/or modify it | ||
5 | under the terms of the GNU General Public License as published | ||
6 | by the Free Software Foundation; either version 3 of the License, or | ||
7 | (at your option) any later version. | ||
8 | |||
9 | This program is distributed in the hope that it will be useful, | ||
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
12 | Lesser General Public License for more details. | ||
13 | |||
14 | You should have received a copy of the GNU General Public License | ||
15 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ | ||
16 | |||
17 | #ifndef _GL_CXXDEFS_H | ||
18 | #define _GL_CXXDEFS_H | ||
19 | |||
20 | /* The three most frequent use cases of these macros are: | ||
21 | |||
22 | * For providing a substitute for a function that is missing on some | ||
23 | platforms, but is declared and works fine on the platforms on which | ||
24 | it exists: | ||
25 | |||
26 | #if @GNULIB_FOO@ | ||
27 | # if !@HAVE_FOO@ | ||
28 | _GL_FUNCDECL_SYS (foo, ...); | ||
29 | # endif | ||
30 | _GL_CXXALIAS_SYS (foo, ...); | ||
31 | _GL_CXXALIASWARN (foo); | ||
32 | #elif defined GNULIB_POSIXCHECK | ||
33 | ... | ||
34 | #endif | ||
35 | |||
36 | * For providing a replacement for a function that exists on all platforms, | ||
37 | but is broken/insufficient and needs to be replaced on some platforms: | ||
38 | |||
39 | #if @GNULIB_FOO@ | ||
40 | # if @REPLACE_FOO@ | ||
41 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||
42 | # undef foo | ||
43 | # define foo rpl_foo | ||
44 | # endif | ||
45 | _GL_FUNCDECL_RPL (foo, ...); | ||
46 | _GL_CXXALIAS_RPL (foo, ...); | ||
47 | # else | ||
48 | _GL_CXXALIAS_SYS (foo, ...); | ||
49 | # endif | ||
50 | _GL_CXXALIASWARN (foo); | ||
51 | #elif defined GNULIB_POSIXCHECK | ||
52 | ... | ||
53 | #endif | ||
54 | |||
55 | * For providing a replacement for a function that exists on some platforms | ||
56 | but is broken/insufficient and needs to be replaced on some of them and | ||
57 | is additionally either missing or undeclared on some other platforms: | ||
58 | |||
59 | #if @GNULIB_FOO@ | ||
60 | # if @REPLACE_FOO@ | ||
61 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||
62 | # undef foo | ||
63 | # define foo rpl_foo | ||
64 | # endif | ||
65 | _GL_FUNCDECL_RPL (foo, ...); | ||
66 | _GL_CXXALIAS_RPL (foo, ...); | ||
67 | # else | ||
68 | # if !@HAVE_FOO@ or if !@HAVE_DECL_FOO@ | ||
69 | _GL_FUNCDECL_SYS (foo, ...); | ||
70 | # endif | ||
71 | _GL_CXXALIAS_SYS (foo, ...); | ||
72 | # endif | ||
73 | _GL_CXXALIASWARN (foo); | ||
74 | #elif defined GNULIB_POSIXCHECK | ||
75 | ... | ||
76 | #endif | ||
77 | */ | ||
78 | |||
79 | /* _GL_EXTERN_C declaration; | ||
80 | performs the declaration with C linkage. */ | ||
81 | #if defined __cplusplus | ||
82 | # define _GL_EXTERN_C extern "C" | ||
83 | #else | ||
84 | # define _GL_EXTERN_C extern | ||
85 | #endif | ||
86 | |||
87 | /* _GL_FUNCDECL_RPL (func, rettype, parameters_and_attributes); | ||
88 | declares a replacement function, named rpl_func, with the given prototype, | ||
89 | consisting of return type, parameters, and attributes. | ||
90 | Example: | ||
91 | _GL_FUNCDECL_RPL (open, int, (const char *filename, int flags, ...) | ||
92 | _GL_ARG_NONNULL ((1))); | ||
93 | */ | ||
94 | #define _GL_FUNCDECL_RPL(func,rettype,parameters_and_attributes) \ | ||
95 | _GL_FUNCDECL_RPL_1 (rpl_##func, rettype, parameters_and_attributes) | ||
96 | #define _GL_FUNCDECL_RPL_1(rpl_func,rettype,parameters_and_attributes) \ | ||
97 | _GL_EXTERN_C rettype rpl_func parameters_and_attributes | ||
98 | |||
99 | /* _GL_FUNCDECL_SYS (func, rettype, parameters_and_attributes); | ||
100 | declares the system function, named func, with the given prototype, | ||
101 | consisting of return type, parameters, and attributes. | ||
102 | Example: | ||
103 | _GL_FUNCDECL_SYS (open, int, (const char *filename, int flags, ...) | ||
104 | _GL_ARG_NONNULL ((1))); | ||
105 | */ | ||
106 | #define _GL_FUNCDECL_SYS(func,rettype,parameters_and_attributes) \ | ||
107 | _GL_EXTERN_C rettype func parameters_and_attributes | ||
108 | |||
109 | /* _GL_CXXALIAS_RPL (func, rettype, parameters); | ||
110 | declares a C++ alias called GNULIB_NAMESPACE::func | ||
111 | that redirects to rpl_func, if GNULIB_NAMESPACE is defined. | ||
112 | Example: | ||
113 | _GL_CXXALIAS_RPL (open, int, (const char *filename, int flags, ...)); | ||
114 | */ | ||
115 | #define _GL_CXXALIAS_RPL(func,rettype,parameters) \ | ||
116 | _GL_CXXALIAS_RPL_1 (func, rpl_##func, rettype, parameters) | ||
117 | #if defined __cplusplus && defined GNULIB_NAMESPACE | ||
118 | # define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \ | ||
119 | namespace GNULIB_NAMESPACE \ | ||
120 | { \ | ||
121 | rettype (*const func) parameters = ::rpl_func; \ | ||
122 | } \ | ||
123 | _GL_EXTERN_C int _gl_cxxalias_dummy | ||
124 | #else | ||
125 | # define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \ | ||
126 | _GL_EXTERN_C int _gl_cxxalias_dummy | ||
127 | #endif | ||
128 | |||
129 | /* _GL_CXXALIAS_RPL_CAST_1 (func, rpl_func, rettype, parameters); | ||
130 | is like _GL_CXXALIAS_RPL_1 (func, rpl_func, rettype, parameters); | ||
131 | except that the C function rpl_func may have a slightly different | ||
132 | declaration. A cast is used to silence the "invalid conversion" error | ||
133 | that would otherwise occur. */ | ||
134 | #if defined __cplusplus && defined GNULIB_NAMESPACE | ||
135 | # define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \ | ||
136 | namespace GNULIB_NAMESPACE \ | ||
137 | { \ | ||
138 | rettype (*const func) parameters = \ | ||
139 | reinterpret_cast<rettype(*)parameters>(::rpl_func); \ | ||
140 | } \ | ||
141 | _GL_EXTERN_C int _gl_cxxalias_dummy | ||
142 | #else | ||
143 | # define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \ | ||
144 | _GL_EXTERN_C int _gl_cxxalias_dummy | ||
145 | #endif | ||
146 | |||
147 | /* _GL_CXXALIAS_SYS (func, rettype, parameters); | ||
148 | declares a C++ alias called GNULIB_NAMESPACE::func | ||
149 | that redirects to the system provided function func, if GNULIB_NAMESPACE | ||
150 | is defined. | ||
151 | Example: | ||
152 | _GL_CXXALIAS_SYS (open, int, (const char *filename, int flags, ...)); | ||
153 | */ | ||
154 | #if defined __cplusplus && defined GNULIB_NAMESPACE | ||
155 | /* If we were to write | ||
156 | rettype (*const func) parameters = ::func; | ||
157 | like above in _GL_CXXALIAS_RPL_1, the compiler could optimize calls | ||
158 | better (remove an indirection through a 'static' pointer variable), | ||
159 | but then the _GL_CXXALIASWARN macro below would cause a warning not only | ||
160 | for uses of ::func but also for uses of GNULIB_NAMESPACE::func. */ | ||
161 | # define _GL_CXXALIAS_SYS(func,rettype,parameters) \ | ||
162 | namespace GNULIB_NAMESPACE \ | ||
163 | { \ | ||
164 | static rettype (*func) parameters = ::func; \ | ||
165 | } \ | ||
166 | _GL_EXTERN_C int _gl_cxxalias_dummy | ||
167 | #else | ||
168 | # define _GL_CXXALIAS_SYS(func,rettype,parameters) \ | ||
169 | _GL_EXTERN_C int _gl_cxxalias_dummy | ||
170 | #endif | ||
171 | |||
172 | /* _GL_CXXALIAS_SYS_CAST (func, rettype, parameters); | ||
173 | is like _GL_CXXALIAS_SYS (func, rettype, parameters); | ||
174 | except that the C function func may have a slightly different declaration. | ||
175 | A cast is used to silence the "invalid conversion" error that would | ||
176 | otherwise occur. */ | ||
177 | #if defined __cplusplus && defined GNULIB_NAMESPACE | ||
178 | # define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \ | ||
179 | namespace GNULIB_NAMESPACE \ | ||
180 | { \ | ||
181 | static rettype (*func) parameters = \ | ||
182 | reinterpret_cast<rettype(*)parameters>(::func); \ | ||
183 | } \ | ||
184 | _GL_EXTERN_C int _gl_cxxalias_dummy | ||
185 | #else | ||
186 | # define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \ | ||
187 | _GL_EXTERN_C int _gl_cxxalias_dummy | ||
188 | #endif | ||
189 | |||
190 | /* _GL_CXXALIAS_SYS_CAST2 (func, rettype, parameters, rettype2, parameters2); | ||
191 | is like _GL_CXXALIAS_SYS (func, rettype, parameters); | ||
192 | except that the C function is picked among a set of overloaded functions, | ||
193 | namely the one with rettype2 and parameters2. Two consecutive casts | ||
194 | are used to silence the "cannot find a match" and "invalid conversion" | ||
195 | errors that would otherwise occur. */ | ||
196 | #if defined __cplusplus && defined GNULIB_NAMESPACE | ||
197 | /* The outer cast must be a reinterpret_cast. | ||
198 | The inner cast: When the function is defined as a set of overloaded | ||
199 | functions, it works as a static_cast<>, choosing the designated variant. | ||
200 | When the function is defined as a single variant, it works as a | ||
201 | reinterpret_cast<>. The parenthesized cast syntax works both ways. */ | ||
202 | # define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \ | ||
203 | namespace GNULIB_NAMESPACE \ | ||
204 | { \ | ||
205 | static rettype (*func) parameters = \ | ||
206 | reinterpret_cast<rettype(*)parameters>( \ | ||
207 | (rettype2(*)parameters2)(::func)); \ | ||
208 | } \ | ||
209 | _GL_EXTERN_C int _gl_cxxalias_dummy | ||
210 | #else | ||
211 | # define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \ | ||
212 | _GL_EXTERN_C int _gl_cxxalias_dummy | ||
213 | #endif | ||
214 | |||
215 | /* _GL_CXXALIASWARN (func); | ||
216 | causes a warning to be emitted when ::func is used but not when | ||
217 | GNULIB_NAMESPACE::func is used. func must be defined without overloaded | ||
218 | variants. */ | ||
219 | #if defined __cplusplus && defined GNULIB_NAMESPACE | ||
220 | # define _GL_CXXALIASWARN(func) \ | ||
221 | _GL_CXXALIASWARN_1 (func, GNULIB_NAMESPACE) | ||
222 | # define _GL_CXXALIASWARN_1(func,namespace) \ | ||
223 | _GL_CXXALIASWARN_2 (func, namespace) | ||
224 | # define _GL_CXXALIASWARN_2(func,namespace) \ | ||
225 | _GL_WARN_ON_USE (func, \ | ||
226 | "The symbol ::" #func " refers to the system function. " \ | ||
227 | "Use " #namespace "::" #func " instead.") | ||
228 | #else | ||
229 | # define _GL_CXXALIASWARN(func) \ | ||
230 | _GL_EXTERN_C int _gl_cxxalias_dummy | ||
231 | #endif | ||
232 | |||
233 | /* _GL_CXXALIASWARN1 (func, rettype, parameters_and_attributes); | ||
234 | causes a warning to be emitted when the given overloaded variant of ::func | ||
235 | is used but not when GNULIB_NAMESPACE::func is used. */ | ||
236 | #if defined __cplusplus && defined GNULIB_NAMESPACE | ||
237 | # define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \ | ||
238 | _GL_CXXALIASWARN1_1 (func, rettype, parameters_and_attributes, \ | ||
239 | GNULIB_NAMESPACE) | ||
240 | # define _GL_CXXALIASWARN1_1(func,rettype,parameters_and_attributes,namespace) \ | ||
241 | _GL_CXXALIASWARN1_2 (func, rettype, parameters_and_attributes, namespace) | ||
242 | # define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \ | ||
243 | _GL_WARN_ON_USE_CXX (func, rettype, parameters_and_attributes, \ | ||
244 | "The symbol ::" #func " refers to the system function. " \ | ||
245 | "Use " #namespace "::" #func " instead.") | ||
246 | #else | ||
247 | # define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \ | ||
248 | _GL_EXTERN_C int _gl_cxxalias_dummy | ||
249 | #endif | ||
250 | |||
251 | #endif /* _GL_CXXDEFS_H */ | ||
diff --git a/build-aux/config.rpath b/build-aux/config.rpath index 85c2f20..17298f2 100755 --- a/build-aux/config.rpath +++ b/build-aux/config.rpath | |||
@@ -2,7 +2,7 @@ | |||
2 | # Output a system dependent set of variables, describing how to set the | 2 | # Output a system dependent set of variables, describing how to set the |
3 | # run time search path of shared libraries in an executable. | 3 | # run time search path of shared libraries in an executable. |
4 | # | 4 | # |
5 | # Copyright 1996-2008 Free Software Foundation, Inc. | 5 | # Copyright 1996-2010 Free Software Foundation, Inc. |
6 | # Taken from GNU libtool, 2001 | 6 | # Taken from GNU libtool, 2001 |
7 | # Originally by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996 | 7 | # Originally by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996 |
8 | # | 8 | # |
diff --git a/build-aux/mkinstalldirs b/build-aux/mkinstalldirs deleted file mode 100755 index 259dbfc..0000000 --- a/build-aux/mkinstalldirs +++ /dev/null | |||
@@ -1,158 +0,0 @@ | |||
1 | #! /bin/sh | ||
2 | # mkinstalldirs --- make directory hierarchy | ||
3 | |||
4 | scriptversion=2005-06-29.22 | ||
5 | |||
6 | # Original author: Noah Friedman <friedman@prep.ai.mit.edu> | ||
7 | # Created: 1993-05-16 | ||
8 | # Public domain. | ||
9 | # | ||
10 | # This file is maintained in Automake, please report | ||
11 | # bugs to <bug-automake@gnu.org> or send patches to | ||
12 | # <automake-patches@gnu.org>. | ||
13 | |||
14 | errstatus=0 | ||
15 | dirmode= | ||
16 | |||
17 | usage="\ | ||
18 | Usage: mkinstalldirs [-h] [--help] [--version] [-m MODE] DIR ... | ||
19 | |||
20 | Create each directory DIR (with mode MODE, if specified), including all | ||
21 | leading file name components. | ||
22 | |||
23 | Report bugs to <bug-automake@gnu.org>." | ||
24 | |||
25 | # process command line arguments | ||
26 | while test $# -gt 0 ; do | ||
27 | case $1 in | ||
28 | -h | --help | --h*) # -h for help | ||
29 | echo "$usage" | ||
30 | exit $? | ||
31 | ;; | ||
32 | -m) # -m PERM arg | ||
33 | shift | ||
34 | test $# -eq 0 && { echo "$usage" 1>&2; exit 1; } | ||
35 | dirmode=$1 | ||
36 | shift | ||
37 | ;; | ||
38 | --version) | ||
39 | echo "$0 $scriptversion" | ||
40 | exit $? | ||
41 | ;; | ||
42 | --) # stop option processing | ||
43 | shift | ||
44 | break | ||
45 | ;; | ||
46 | -*) # unknown option | ||
47 | echo "$usage" 1>&2 | ||
48 | exit 1 | ||
49 | ;; | ||
50 | *) # first non-opt arg | ||
51 | break | ||
52 | ;; | ||
53 | esac | ||
54 | done | ||
55 | |||
56 | for file | ||
57 | do | ||
58 | if test -d "$file"; then | ||
59 | shift | ||
60 | else | ||
61 | break | ||
62 | fi | ||
63 | done | ||
64 | |||
65 | case $# in | ||
66 | 0) exit 0 ;; | ||
67 | esac | ||
68 | |||
69 | # Solaris 8's mkdir -p isn't thread-safe. If you mkdir -p a/b and | ||
70 | # mkdir -p a/c at the same time, both will detect that a is missing, | ||
71 | # one will create a, then the other will try to create a and die with | ||
72 | # a "File exists" error. This is a problem when calling mkinstalldirs | ||
73 | # from a parallel make. We use --version in the probe to restrict | ||
74 | # ourselves to GNU mkdir, which is thread-safe. | ||
75 | case $dirmode in | ||
76 | '') | ||
77 | if mkdir -p --version . >/dev/null 2>&1 && test ! -d ./--version; then | ||
78 | echo "mkdir -p -- $*" | ||
79 | exec mkdir -p -- "$@" | ||
80 | else | ||
81 | # On NextStep and OpenStep, the `mkdir' command does not | ||
82 | # recognize any option. It will interpret all options as | ||
83 | # directories to create, and then abort because `.' already | ||
84 | # exists. | ||
85 | test -d ./-p && rmdir ./-p | ||
86 | test -d ./--version && rmdir ./--version | ||
87 | fi | ||
88 | ;; | ||
89 | *) | ||
90 | if mkdir -m "$dirmode" -p --version . >/dev/null 2>&1 && | ||
91 | test ! -d ./--version; then | ||
92 | echo "mkdir -m $dirmode -p -- $*" | ||
93 | exec mkdir -m "$dirmode" -p -- "$@" | ||
94 | else | ||
95 | # Clean up after NextStep and OpenStep mkdir. | ||
96 | for d in ./-m ./-p ./--version "./$dirmode"; | ||
97 | do | ||
98 | test -d $d && rmdir $d | ||
99 | done | ||
100 | fi | ||
101 | ;; | ||
102 | esac | ||
103 | |||
104 | for file | ||
105 | do | ||
106 | case $file in | ||
107 | /*) pathcomp=/ ;; | ||
108 | *) pathcomp= ;; | ||
109 | esac | ||
110 | oIFS=$IFS | ||
111 | IFS=/ | ||
112 | set fnord $file | ||
113 | shift | ||
114 | IFS=$oIFS | ||
115 | |||
116 | for d | ||
117 | do | ||
118 | test "x$d" = x && continue | ||
119 | |||
120 | pathcomp=$pathcomp$d | ||
121 | case $pathcomp in | ||
122 | -*) pathcomp=./$pathcomp ;; | ||
123 | esac | ||
124 | |||
125 | if test ! -d "$pathcomp"; then | ||
126 | echo "mkdir $pathcomp" | ||
127 | |||
128 | mkdir "$pathcomp" || lasterr=$? | ||
129 | |||
130 | if test ! -d "$pathcomp"; then | ||
131 | errstatus=$lasterr | ||
132 | else | ||
133 | if test ! -z "$dirmode"; then | ||
134 | echo "chmod $dirmode $pathcomp" | ||
135 | lasterr= | ||
136 | chmod "$dirmode" "$pathcomp" || lasterr=$? | ||
137 | |||
138 | if test ! -z "$lasterr"; then | ||
139 | errstatus=$lasterr | ||
140 | fi | ||
141 | fi | ||
142 | fi | ||
143 | fi | ||
144 | |||
145 | pathcomp=$pathcomp/ | ||
146 | done | ||
147 | done | ||
148 | |||
149 | exit $errstatus | ||
150 | |||
151 | # Local Variables: | ||
152 | # mode: shell-script | ||
153 | # sh-indentation: 2 | ||
154 | # eval: (add-hook 'write-file-hooks 'time-stamp) | ||
155 | # time-stamp-start: "scriptversion=" | ||
156 | # time-stamp-format: "%:y-%02m-%02d.%02H" | ||
157 | # time-stamp-end: "$" | ||
158 | # End: | ||
diff --git a/build-aux/warn-on-use.h b/build-aux/warn-on-use.h new file mode 100644 index 0000000..1cd5062 --- /dev/null +++ b/build-aux/warn-on-use.h | |||
@@ -0,0 +1,102 @@ | |||
1 | /* A C macro for emitting warnings if a function is used. | ||
2 | Copyright (C) 2010 Free Software Foundation, Inc. | ||
3 | |||
4 | This program is free software: you can redistribute it and/or modify it | ||
5 | under the terms of the GNU General Public License as published | ||
6 | by the Free Software Foundation; either version 3 of the License, or | ||
7 | (at your option) any later version. | ||
8 | |||
9 | This program is distributed in the hope that it will be useful, | ||
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
12 | Lesser General Public License for more details. | ||
13 | |||
14 | You should have received a copy of the GNU General Public License | ||
15 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ | ||
16 | |||
17 | /* _GL_WARN_ON_USE (function, "literal string") issues a declaration | ||
18 | for FUNCTION which will then trigger a compiler warning containing | ||
19 | the text of "literal string" anywhere that function is called, if | ||
20 | supported by the compiler. If the compiler does not support this | ||
21 | feature, the macro expands to an unused extern declaration. | ||
22 | |||
23 | This macro is useful for marking a function as a potential | ||
24 | portability trap, with the intent that "literal string" include | ||
25 | instructions on the replacement function that should be used | ||
26 | instead. However, one of the reasons that a function is a | ||
27 | portability trap is if it has the wrong signature. Declaring | ||
28 | FUNCTION with a different signature in C is a compilation error, so | ||
29 | this macro must use the same type as any existing declaration so | ||
30 | that programs that avoid the problematic FUNCTION do not fail to | ||
31 | compile merely because they included a header that poisoned the | ||
32 | function. But this implies that _GL_WARN_ON_USE is only safe to | ||
33 | use if FUNCTION is known to already have a declaration. Use of | ||
34 | this macro implies that there must not be any other macro hiding | ||
35 | the declaration of FUNCTION; but undefining FUNCTION first is part | ||
36 | of the poisoning process anyway (although for symbols that are | ||
37 | provided only via a macro, the result is a compilation error rather | ||
38 | than a warning containing "literal string"). Also note that in | ||
39 | C++, it is only safe to use if FUNCTION has no overloads. | ||
40 | |||
41 | For an example, it is possible to poison 'getline' by: | ||
42 | - adding a call to gl_WARN_ON_USE_PREPARE([[#include <stdio.h>]], | ||
43 | [getline]) in configure.ac, which potentially defines | ||
44 | HAVE_RAW_DECL_GETLINE | ||
45 | - adding this code to a header that wraps the system <stdio.h>: | ||
46 | #undef getline | ||
47 | #if HAVE_RAW_DECL_GETLINE | ||
48 | _GL_WARN_ON_USE (getline, "getline is required by POSIX 2008, but" | ||
49 | "not universally present; use the gnulib module getline"); | ||
50 | #endif | ||
51 | |||
52 | It is not possible to directly poison global variables. But it is | ||
53 | possible to write a wrapper accessor function, and poison that | ||
54 | (less common usage, like &environ, will cause a compilation error | ||
55 | rather than issue the nice warning, but the end result of informing | ||
56 | the developer about their portability problem is still achieved): | ||
57 | #if HAVE_RAW_DECL_ENVIRON | ||
58 | static inline char ***rpl_environ (void) { return &environ; } | ||
59 | _GL_WARN_ON_USE (rpl_environ, "environ is not always properly declared"); | ||
60 | # undef environ | ||
61 | # define environ (*rpl_environ ()) | ||
62 | #endif | ||
63 | */ | ||
64 | #ifndef _GL_WARN_ON_USE | ||
65 | |||
66 | # if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__) | ||
67 | /* A compiler attribute is available in gcc versions 4.3.0 and later. */ | ||
68 | # define _GL_WARN_ON_USE(function, message) \ | ||
69 | extern __typeof__ (function) function __attribute__ ((__warning__ (message))) | ||
70 | |||
71 | # else /* Unsupported. */ | ||
72 | # define _GL_WARN_ON_USE(function, message) \ | ||
73 | _GL_WARN_EXTERN_C int _gl_warn_on_use | ||
74 | # endif | ||
75 | #endif | ||
76 | |||
77 | /* _GL_WARN_ON_USE_CXX (function, rettype, parameters_and_attributes, "string") | ||
78 | is like _GL_WARN_ON_USE (function, "string"), except that the function is | ||
79 | declared with the given prototype, consisting of return type, parameters, | ||
80 | and attributes. | ||
81 | This variant is useful for overloaded functions in C++. _GL_WARN_ON_USE does | ||
82 | not work in this case. */ | ||
83 | #ifndef _GL_WARN_ON_USE_CXX | ||
84 | # if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__) | ||
85 | # define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \ | ||
86 | extern rettype function parameters_and_attributes \ | ||
87 | __attribute__ ((__warning__ (msg))) | ||
88 | # else /* Unsupported. */ | ||
89 | # define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \ | ||
90 | _GL_WARN_EXTERN_C int _gl_warn_on_use | ||
91 | # endif | ||
92 | #endif | ||
93 | |||
94 | /* _GL_WARN_EXTERN_C declaration; | ||
95 | performs the declaration with C linkage. */ | ||
96 | #ifndef _GL_WARN_EXTERN_C | ||
97 | # if defined __cplusplus | ||
98 | # define _GL_WARN_EXTERN_C extern "C" | ||
99 | # else | ||
100 | # define _GL_WARN_EXTERN_C extern | ||
101 | # endif | ||
102 | #endif | ||