diff options
author | Thomas Guyot-Sionnest <dermoth@users.sourceforge.net> | 2008-02-12 12:03:58 (GMT) |
---|---|---|
committer | Thomas Guyot-Sionnest <dermoth@users.sourceforge.net> | 2008-02-12 12:03:58 (GMT) |
commit | abbad00edd7f5f3d33ae77a9d5ac338e5bea5fb3 (patch) | |
tree | 0d55fb4d8e5ad7a9376d1bccdea31104cbecacfe /gl | |
parent | bd7029a99b0c2974265c6665638ef14a052f42ab (diff) | |
download | monitoring-plugins-abbad00edd7f5f3d33ae77a9d5ac338e5bea5fb3.tar.gz |
Import Gnulib floorf and base64 and removed our old base64 library.
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1926 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'gl')
-rw-r--r-- | gl/Makefile.am | 81 | ||||
-rw-r--r-- | gl/base64.c | 425 | ||||
-rw-r--r-- | gl/base64.h | 45 | ||||
-rw-r--r-- | gl/charset.alias | 5 | ||||
-rw-r--r-- | gl/configmake.h | 25 | ||||
-rw-r--r-- | gl/floor.c | 93 | ||||
-rw-r--r-- | gl/floorf.c | 20 | ||||
-rw-r--r-- | gl/m4/base64.m4 | 16 | ||||
-rw-r--r-- | gl/m4/floorf.m4 | 62 | ||||
-rw-r--r-- | gl/m4/gnulib-cache.m4 | 4 | ||||
-rw-r--r-- | gl/m4/gnulib-comp.m4 | 12 | ||||
-rw-r--r-- | gl/m4/math_h.m4 | 66 | ||||
-rw-r--r-- | gl/math.h | 442 | ||||
-rw-r--r-- | gl/math.in.h | 413 | ||||
-rw-r--r-- | gl/ref-add.sed | 10 | ||||
-rw-r--r-- | gl/ref-del.sed | 5 | ||||
-rw-r--r-- | gl/stdio.h | 411 | ||||
-rw-r--r-- | gl/stdlib.h | 237 | ||||
-rw-r--r-- | gl/string.h | 598 | ||||
-rw-r--r-- | gl/unistd.h | 321 |
20 files changed, 3288 insertions, 3 deletions
diff --git a/gl/Makefile.am b/gl/Makefile.am index 92c675e..1eefee9 100644 --- a/gl/Makefile.am +++ b/gl/Makefile.am | |||
@@ -9,7 +9,7 @@ | |||
9 | # the same distribution terms as the rest of that program. | 9 | # the same distribution terms as the rest of that program. |
10 | # | 10 | # |
11 | # Generated by gnulib-tool. | 11 | # Generated by gnulib-tool. |
12 | # Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=gl --m4-base=gl/m4 --doc-base=doc --aux-dir=build-aux --no-libtool --macro-prefix=gl dirname fsusage getaddrinfo gethostname getloadavg getopt gettext mountlist regex vasprintf vsnprintf | 12 | # Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=gl --m4-base=gl/m4 --doc-base=doc --aux-dir=build-aux --no-libtool --macro-prefix=gl base64 dirname floorf fsusage getaddrinfo gethostname getloadavg getopt gettext mountlist regex vasprintf vsnprintf |
13 | 13 | ||
14 | AUTOMAKE_OPTIONS = 1.5 gnits | 14 | AUTOMAKE_OPTIONS = 1.5 gnits |
15 | 15 | ||
@@ -89,6 +89,12 @@ MOSTLYCLEANDIRS += arpa | |||
89 | 89 | ||
90 | ## end gnulib module arpa_inet | 90 | ## end gnulib module arpa_inet |
91 | 91 | ||
92 | ## begin gnulib module base64 | ||
93 | |||
94 | libgnu_a_SOURCES += base64.h base64.c | ||
95 | |||
96 | ## end gnulib module base64 | ||
97 | |||
92 | ## begin gnulib module c-strtod | 98 | ## begin gnulib module c-strtod |
93 | 99 | ||
94 | 100 | ||
@@ -219,6 +225,15 @@ EXTRA_DIST += float.in.h | |||
219 | 225 | ||
220 | ## end gnulib module float | 226 | ## end gnulib module float |
221 | 227 | ||
228 | ## begin gnulib module floorf | ||
229 | |||
230 | |||
231 | EXTRA_DIST += floor.c floorf.c | ||
232 | |||
233 | EXTRA_libgnu_a_SOURCES += floor.c floorf.c | ||
234 | |||
235 | ## end gnulib module floorf | ||
236 | |||
222 | ## begin gnulib module fsusage | 237 | ## begin gnulib module fsusage |
223 | 238 | ||
224 | 239 | ||
@@ -415,6 +430,70 @@ EXTRA_libgnu_a_SOURCES += malloc.c | |||
415 | 430 | ||
416 | ## end gnulib module malloc-posix | 431 | ## end gnulib module malloc-posix |
417 | 432 | ||
433 | ## begin gnulib module math | ||
434 | |||
435 | BUILT_SOURCES += math.h | ||
436 | |||
437 | # We need the following in order to create <math.h> when the system | ||
438 | # doesn't have one that works with the given compiler. | ||
439 | math.h: math.in.h | ||
440 | rm -f $@-t $@ | ||
441 | { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ | ||
442 | sed -e 's/@''INCLUDE_NEXT''@/$(INCLUDE_NEXT)/g' \ | ||
443 | -e 's|@''NEXT_MATH_H''@|$(NEXT_MATH_H)|g' \ | ||
444 | -e 's|@''GNULIB_CEILF''@|$(GNULIB_CEILF)|g' \ | ||
445 | -e 's|@''GNULIB_CEILL''@|$(GNULIB_CEILL)|g' \ | ||
446 | -e 's|@''GNULIB_FLOORF''@|$(GNULIB_FLOORF)|g' \ | ||
447 | -e 's|@''GNULIB_FLOORL''@|$(GNULIB_FLOORL)|g' \ | ||
448 | -e 's|@''GNULIB_FREXP''@|$(GNULIB_FREXP)|g' \ | ||
449 | -e 's|@''GNULIB_FREXPL''@|$(GNULIB_FREXPL)|g' \ | ||
450 | -e 's|@''GNULIB_ISFINITE''@|$(GNULIB_ISFINITE)|g' \ | ||
451 | -e 's|@''GNULIB_LDEXPL''@|$(GNULIB_LDEXPL)|g' \ | ||
452 | -e 's|@''GNULIB_MATHL''@|$(GNULIB_MATHL)|g' \ | ||
453 | -e 's|@''GNULIB_ROUND''@|$(GNULIB_ROUND)|g' \ | ||
454 | -e 's|@''GNULIB_ROUNDF''@|$(GNULIB_ROUNDF)|g' \ | ||
455 | -e 's|@''GNULIB_ROUNDL''@|$(GNULIB_ROUNDL)|g' \ | ||
456 | -e 's|@''GNULIB_SIGNBIT''@|$(GNULIB_SIGNBIT)|g' \ | ||
457 | -e 's|@''GNULIB_TRUNC''@|$(GNULIB_TRUNC)|g' \ | ||
458 | -e 's|@''GNULIB_TRUNCF''@|$(GNULIB_TRUNCF)|g' \ | ||
459 | -e 's|@''GNULIB_TRUNCL''@|$(GNULIB_TRUNCL)|g' \ | ||
460 | -e 's|@''HAVE_DECL_ACOSL''@|$(HAVE_DECL_ACOSL)|g' \ | ||
461 | -e 's|@''HAVE_DECL_ASINL''@|$(HAVE_DECL_ASINL)|g' \ | ||
462 | -e 's|@''HAVE_DECL_ATANL''@|$(HAVE_DECL_ATANL)|g' \ | ||
463 | -e 's|@''HAVE_DECL_COSL''@|$(HAVE_DECL_COSL)|g' \ | ||
464 | -e 's|@''HAVE_DECL_EXPL''@|$(HAVE_DECL_EXPL)|g' \ | ||
465 | -e 's|@''HAVE_DECL_FREXPL''@|$(HAVE_DECL_FREXPL)|g' \ | ||
466 | -e 's|@''HAVE_DECL_LDEXPL''@|$(HAVE_DECL_LDEXPL)|g' \ | ||
467 | -e 's|@''HAVE_DECL_LOGL''@|$(HAVE_DECL_LOGL)|g' \ | ||
468 | -e 's|@''HAVE_DECL_SINL''@|$(HAVE_DECL_SINL)|g' \ | ||
469 | -e 's|@''HAVE_DECL_SQRTL''@|$(HAVE_DECL_SQRTL)|g' \ | ||
470 | -e 's|@''HAVE_DECL_TANL''@|$(HAVE_DECL_TANL)|g' \ | ||
471 | -e 's|@''HAVE_DECL_TRUNC''@|$(HAVE_DECL_TRUNC)|g' \ | ||
472 | -e 's|@''HAVE_DECL_TRUNCF''@|$(HAVE_DECL_TRUNCF)|g' \ | ||
473 | -e 's|@''HAVE_DECL_TRUNCL''@|$(HAVE_DECL_TRUNCL)|g' \ | ||
474 | -e 's|@''REPLACE_CEILF''@|$(REPLACE_CEILF)|g' \ | ||
475 | -e 's|@''REPLACE_CEILL''@|$(REPLACE_CEILL)|g' \ | ||
476 | -e 's|@''REPLACE_FLOORF''@|$(REPLACE_FLOORF)|g' \ | ||
477 | -e 's|@''REPLACE_FLOORL''@|$(REPLACE_FLOORL)|g' \ | ||
478 | -e 's|@''REPLACE_FREXP''@|$(REPLACE_FREXP)|g' \ | ||
479 | -e 's|@''REPLACE_FREXPL''@|$(REPLACE_FREXPL)|g' \ | ||
480 | -e 's|@''REPLACE_ISFINITE''@|$(REPLACE_ISFINITE)|g' \ | ||
481 | -e 's|@''REPLACE_LDEXPL''@|$(REPLACE_LDEXPL)|g' \ | ||
482 | -e 's|@''REPLACE_ROUND''@|$(REPLACE_ROUND)|g' \ | ||
483 | -e 's|@''REPLACE_ROUNDF''@|$(REPLACE_ROUNDF)|g' \ | ||
484 | -e 's|@''REPLACE_ROUNDL''@|$(REPLACE_ROUNDL)|g' \ | ||
485 | -e 's|@''REPLACE_SIGNBIT''@|$(REPLACE_SIGNBIT)|g' \ | ||
486 | -e 's|@''REPLACE_SIGNBIT_USING_GCC''@|$(REPLACE_SIGNBIT_USING_GCC)|g' \ | ||
487 | -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \ | ||
488 | < $(srcdir)/math.in.h; \ | ||
489 | } > $@-t | ||
490 | mv $@-t $@ | ||
491 | MOSTLYCLEANFILES += math.h math.h-t | ||
492 | |||
493 | EXTRA_DIST += math.in.h | ||
494 | |||
495 | ## end gnulib module math | ||
496 | |||
418 | ## begin gnulib module mountlist | 497 | ## begin gnulib module mountlist |
419 | 498 | ||
420 | 499 | ||
diff --git a/gl/base64.c b/gl/base64.c new file mode 100644 index 0000000..e67075d --- /dev/null +++ b/gl/base64.c | |||
@@ -0,0 +1,425 @@ | |||
1 | /* base64.c -- Encode binary data using printable characters. | ||
2 | Copyright (C) 1999, 2000, 2001, 2004, 2005, 2006 Free Software | ||
3 | Foundation, Inc. | ||
4 | |||
5 | This program is free software; you can redistribute it and/or modify | ||
6 | it under the terms of the GNU General Public License as published by | ||
7 | the Free Software Foundation; either version 3, or (at your option) | ||
8 | any later version. | ||
9 | |||
10 | This program is distributed in the hope that it will be useful, | ||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | GNU General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU General Public License | ||
16 | along with this program; if not, write to the Free Software Foundation, | ||
17 | Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ | ||
18 | |||
19 | /* Written by Simon Josefsson. Partially adapted from GNU MailUtils | ||
20 | * (mailbox/filter_trans.c, as of 2004-11-28). Improved by review | ||
21 | * from Paul Eggert, Bruno Haible, and Stepan Kasal. | ||
22 | * | ||
23 | * See also RFC 3548 <http://www.ietf.org/rfc/rfc3548.txt>. | ||
24 | * | ||
25 | * Be careful with error checking. Here is how you would typically | ||
26 | * use these functions: | ||
27 | * | ||
28 | * bool ok = base64_decode_alloc (in, inlen, &out, &outlen); | ||
29 | * if (!ok) | ||
30 | * FAIL: input was not valid base64 | ||
31 | * if (out == NULL) | ||
32 | * FAIL: memory allocation error | ||
33 | * OK: data in OUT/OUTLEN | ||
34 | * | ||
35 | * size_t outlen = base64_encode_alloc (in, inlen, &out); | ||
36 | * if (out == NULL && outlen == 0 && inlen != 0) | ||
37 | * FAIL: input too long | ||
38 | * if (out == NULL) | ||
39 | * FAIL: memory allocation error | ||
40 | * OK: data in OUT/OUTLEN. | ||
41 | * | ||
42 | */ | ||
43 | |||
44 | #include <config.h> | ||
45 | |||
46 | /* Get prototype. */ | ||
47 | #include "base64.h" | ||
48 | |||
49 | /* Get malloc. */ | ||
50 | #include <stdlib.h> | ||
51 | |||
52 | /* Get UCHAR_MAX. */ | ||
53 | #include <limits.h> | ||
54 | |||
55 | /* C89 compliant way to cast 'char' to 'unsigned char'. */ | ||
56 | static inline unsigned char | ||
57 | to_uchar (char ch) | ||
58 | { | ||
59 | return ch; | ||
60 | } | ||
61 | |||
62 | /* Base64 encode IN array of size INLEN into OUT array of size OUTLEN. | ||
63 | If OUTLEN is less than BASE64_LENGTH(INLEN), write as many bytes as | ||
64 | possible. If OUTLEN is larger than BASE64_LENGTH(INLEN), also zero | ||
65 | terminate the output buffer. */ | ||
66 | void | ||
67 | base64_encode (const char *restrict in, size_t inlen, | ||
68 | char *restrict out, size_t outlen) | ||
69 | { | ||
70 | static const char b64str[64] = | ||
71 | "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; | ||
72 | |||
73 | while (inlen && outlen) | ||
74 | { | ||
75 | *out++ = b64str[(to_uchar (in[0]) >> 2) & 0x3f]; | ||
76 | if (!--outlen) | ||
77 | break; | ||
78 | *out++ = b64str[((to_uchar (in[0]) << 4) | ||
79 | + (--inlen ? to_uchar (in[1]) >> 4 : 0)) | ||
80 | & 0x3f]; | ||
81 | if (!--outlen) | ||
82 | break; | ||
83 | *out++ = | ||
84 | (inlen | ||
85 | ? b64str[((to_uchar (in[1]) << 2) | ||
86 | + (--inlen ? to_uchar (in[2]) >> 6 : 0)) | ||
87 | & 0x3f] | ||
88 | : '='); | ||
89 | if (!--outlen) | ||
90 | break; | ||
91 | *out++ = inlen ? b64str[to_uchar (in[2]) & 0x3f] : '='; | ||
92 | if (!--outlen) | ||
93 | break; | ||
94 | if (inlen) | ||
95 | inlen--; | ||
96 | if (inlen) | ||
97 | in += 3; | ||
98 | } | ||
99 | |||
100 | if (outlen) | ||
101 | *out = '\0'; | ||
102 | } | ||
103 | |||
104 | /* Allocate a buffer and store zero terminated base64 encoded data | ||
105 | from array IN of size INLEN, returning BASE64_LENGTH(INLEN), i.e., | ||
106 | the length of the encoded data, excluding the terminating zero. On | ||
107 | return, the OUT variable will hold a pointer to newly allocated | ||
108 | memory that must be deallocated by the caller. If output string | ||
109 | length would overflow, 0 is returned and OUT is set to NULL. If | ||
110 | memory allocation failed, OUT is set to NULL, and the return value | ||
111 | indicates length of the requested memory block, i.e., | ||
112 | BASE64_LENGTH(inlen) + 1. */ | ||
113 | size_t | ||
114 | base64_encode_alloc (const char *in, size_t inlen, char **out) | ||
115 | { | ||
116 | size_t outlen = 1 + BASE64_LENGTH (inlen); | ||
117 | |||
118 | /* Check for overflow in outlen computation. | ||
119 | * | ||
120 | * If there is no overflow, outlen >= inlen. | ||
121 | * | ||
122 | * If the operation (inlen + 2) overflows then it yields at most +1, so | ||
123 | * outlen is 0. | ||
124 | * | ||
125 | * If the multiplication overflows, we lose at least half of the | ||
126 | * correct value, so the result is < ((inlen + 2) / 3) * 2, which is | ||
127 | * less than (inlen + 2) * 0.66667, which is less than inlen as soon as | ||
128 | * (inlen > 4). | ||
129 | */ | ||
130 | if (inlen > outlen) | ||
131 | { | ||
132 | *out = NULL; | ||
133 | return 0; | ||
134 | } | ||
135 | |||
136 | *out = malloc (outlen); | ||
137 | if (!*out) | ||
138 | return outlen; | ||
139 | |||
140 | base64_encode (in, inlen, *out, outlen); | ||
141 | |||
142 | return outlen - 1; | ||
143 | } | ||
144 | |||
145 | /* With this approach this file works independent of the charset used | ||
146 | (think EBCDIC). However, it does assume that the characters in the | ||
147 | Base64 alphabet (A-Za-z0-9+/) are encoded in 0..255. POSIX | ||
148 | 1003.1-2001 require that char and unsigned char are 8-bit | ||
149 | quantities, though, taking care of that problem. But this may be a | ||
150 | potential problem on non-POSIX C99 platforms. | ||
151 | |||
152 | IBM C V6 for AIX mishandles "#define B64(x) ...'x'...", so use "_" | ||
153 | as the formal parameter rather than "x". */ | ||
154 | #define B64(_) \ | ||
155 | ((_) == 'A' ? 0 \ | ||
156 | : (_) == 'B' ? 1 \ | ||
157 | : (_) == 'C' ? 2 \ | ||
158 | : (_) == 'D' ? 3 \ | ||
159 | : (_) == 'E' ? 4 \ | ||
160 | : (_) == 'F' ? 5 \ | ||
161 | : (_) == 'G' ? 6 \ | ||
162 | : (_) == 'H' ? 7 \ | ||
163 | : (_) == 'I' ? 8 \ | ||
164 | : (_) == 'J' ? 9 \ | ||
165 | : (_) == 'K' ? 10 \ | ||
166 | : (_) == 'L' ? 11 \ | ||
167 | : (_) == 'M' ? 12 \ | ||
168 | : (_) == 'N' ? 13 \ | ||
169 | : (_) == 'O' ? 14 \ | ||
170 | : (_) == 'P' ? 15 \ | ||
171 | : (_) == 'Q' ? 16 \ | ||
172 | : (_) == 'R' ? 17 \ | ||
173 | : (_) == 'S' ? 18 \ | ||
174 | : (_) == 'T' ? 19 \ | ||
175 | : (_) == 'U' ? 20 \ | ||
176 | : (_) == 'V' ? 21 \ | ||
177 | : (_) == 'W' ? 22 \ | ||
178 | : (_) == 'X' ? 23 \ | ||
179 | : (_) == 'Y' ? 24 \ | ||
180 | : (_) == 'Z' ? 25 \ | ||
181 | : (_) == 'a' ? 26 \ | ||
182 | : (_) == 'b' ? 27 \ | ||
183 | : (_) == 'c' ? 28 \ | ||
184 | : (_) == 'd' ? 29 \ | ||
185 | : (_) == 'e' ? 30 \ | ||
186 | : (_) == 'f' ? 31 \ | ||
187 | : (_) == 'g' ? 32 \ | ||
188 | : (_) == 'h' ? 33 \ | ||
189 | : (_) == 'i' ? 34 \ | ||
190 | : (_) == 'j' ? 35 \ | ||
191 | : (_) == 'k' ? 36 \ | ||
192 | : (_) == 'l' ? 37 \ | ||
193 | : (_) == 'm' ? 38 \ | ||
194 | : (_) == 'n' ? 39 \ | ||
195 | : (_) == 'o' ? 40 \ | ||
196 | : (_) == 'p' ? 41 \ | ||
197 | : (_) == 'q' ? 42 \ | ||
198 | : (_) == 'r' ? 43 \ | ||
199 | : (_) == 's' ? 44 \ | ||
200 | : (_) == 't' ? 45 \ | ||
201 | : (_) == 'u' ? 46 \ | ||
202 | : (_) == 'v' ? 47 \ | ||
203 | : (_) == 'w' ? 48 \ | ||
204 | : (_) == 'x' ? 49 \ | ||
205 | : (_) == 'y' ? 50 \ | ||
206 | : (_) == 'z' ? 51 \ | ||
207 | : (_) == '0' ? 52 \ | ||
208 | : (_) == '1' ? 53 \ | ||
209 | : (_) == '2' ? 54 \ | ||
210 | : (_) == '3' ? 55 \ | ||
211 | : (_) == '4' ? 56 \ | ||
212 | : (_) == '5' ? 57 \ | ||
213 | : (_) == '6' ? 58 \ | ||
214 | : (_) == '7' ? 59 \ | ||
215 | : (_) == '8' ? 60 \ | ||
216 | : (_) == '9' ? 61 \ | ||
217 | : (_) == '+' ? 62 \ | ||
218 | : (_) == '/' ? 63 \ | ||
219 | : -1) | ||
220 | |||
221 | static const signed char b64[0x100] = { | ||
222 | B64 (0), B64 (1), B64 (2), B64 (3), | ||
223 | B64 (4), B64 (5), B64 (6), B64 (7), | ||
224 | B64 (8), B64 (9), B64 (10), B64 (11), | ||
225 | B64 (12), B64 (13), B64 (14), B64 (15), | ||
226 | B64 (16), B64 (17), B64 (18), B64 (19), | ||
227 | B64 (20), B64 (21), B64 (22), B64 (23), | ||
228 | B64 (24), B64 (25), B64 (26), B64 (27), | ||
229 | B64 (28), B64 (29), B64 (30), B64 (31), | ||
230 | B64 (32), B64 (33), B64 (34), B64 (35), | ||
231 | B64 (36), B64 (37), B64 (38), B64 (39), | ||
232 | B64 (40), B64 (41), B64 (42), B64 (43), | ||
233 | B64 (44), B64 (45), B64 (46), B64 (47), | ||
234 | B64 (48), B64 (49), B64 (50), B64 (51), | ||
235 | B64 (52), B64 (53), B64 (54), B64 (55), | ||
236 | B64 (56), B64 (57), B64 (58), B64 (59), | ||
237 | B64 (60), B64 (61), B64 (62), B64 (63), | ||
238 | B64 (64), B64 (65), B64 (66), B64 (67), | ||
239 | B64 (68), B64 (69), B64 (70), B64 (71), | ||
240 | B64 (72), B64 (73), B64 (74), B64 (75), | ||
241 | B64 (76), B64 (77), B64 (78), B64 (79), | ||
242 | B64 (80), B64 (81), B64 (82), B64 (83), | ||
243 | B64 (84), B64 (85), B64 (86), B64 (87), | ||
244 | B64 (88), B64 (89), B64 (90), B64 (91), | ||
245 | B64 (92), B64 (93), B64 (94), B64 (95), | ||
246 | B64 (96), B64 (97), B64 (98), B64 (99), | ||
247 | B64 (100), B64 (101), B64 (102), B64 (103), | ||
248 | B64 (104), B64 (105), B64 (106), B64 (107), | ||
249 | B64 (108), B64 (109), B64 (110), B64 (111), | ||
250 | B64 (112), B64 (113), B64 (114), B64 (115), | ||
251 | B64 (116), B64 (117), B64 (118), B64 (119), | ||
252 | B64 (120), B64 (121), B64 (122), B64 (123), | ||
253 | B64 (124), B64 (125), B64 (126), B64 (127), | ||
254 | B64 (128), B64 (129), B64 (130), B64 (131), | ||
255 | B64 (132), B64 (133), B64 (134), B64 (135), | ||
256 | B64 (136), B64 (137), B64 (138), B64 (139), | ||
257 | B64 (140), B64 (141), B64 (142), B64 (143), | ||
258 | B64 (144), B64 (145), B64 (146), B64 (147), | ||
259 | B64 (148), B64 (149), B64 (150), B64 (151), | ||
260 | B64 (152), B64 (153), B64 (154), B64 (155), | ||
261 | B64 (156), B64 (157), B64 (158), B64 (159), | ||
262 | B64 (160), B64 (161), B64 (162), B64 (163), | ||
263 | B64 (164), B64 (165), B64 (166), B64 (167), | ||
264 | B64 (168), B64 (169), B64 (170), B64 (171), | ||
265 | B64 (172), B64 (173), B64 (174), B64 (175), | ||
266 | B64 (176), B64 (177), B64 (178), B64 (179), | ||
267 | B64 (180), B64 (181), B64 (182), B64 (183), | ||
268 | B64 (184), B64 (185), B64 (186), B64 (187), | ||
269 | B64 (188), B64 (189), B64 (190), B64 (191), | ||
270 | B64 (192), B64 (193), B64 (194), B64 (195), | ||
271 | B64 (196), B64 (197), B64 (198), B64 (199), | ||
272 | B64 (200), B64 (201), B64 (202), B64 (203), | ||
273 | B64 (204), B64 (205), B64 (206), B64 (207), | ||
274 | B64 (208), B64 (209), B64 (210), B64 (211), | ||
275 | B64 (212), B64 (213), B64 (214), B64 (215), | ||
276 | B64 (216), B64 (217), B64 (218), B64 (219), | ||
277 | B64 (220), B64 (221), B64 (222), B64 (223), | ||
278 | B64 (224), B64 (225), B64 (226), B64 (227), | ||
279 | B64 (228), B64 (229), B64 (230), B64 (231), | ||
280 | B64 (232), B64 (233), B64 (234), B64 (235), | ||
281 | B64 (236), B64 (237), B64 (238), B64 (239), | ||
282 | B64 (240), B64 (241), B64 (242), B64 (243), | ||
283 | B64 (244), B64 (245), B64 (246), B64 (247), | ||
284 | B64 (248), B64 (249), B64 (250), B64 (251), | ||
285 | B64 (252), B64 (253), B64 (254), B64 (255) | ||
286 | }; | ||
287 | |||
288 | #if UCHAR_MAX == 255 | ||
289 | # define uchar_in_range(c) true | ||
290 | #else | ||
291 | # define uchar_in_range(c) ((c) <= 255) | ||
292 | #endif | ||
293 | |||
294 | /* Return true if CH is a character from the Base64 alphabet, and | ||
295 | false otherwise. Note that '=' is padding and not considered to be | ||
296 | part of the alphabet. */ | ||
297 | bool | ||
298 | isbase64 (char ch) | ||
299 | { | ||
300 | return uchar_in_range (to_uchar (ch)) && 0 <= b64[to_uchar (ch)]; | ||
301 | } | ||
302 | |||
303 | /* Decode base64 encoded input array IN of length INLEN to output | ||
304 | array OUT that can hold *OUTLEN bytes. Return true if decoding was | ||
305 | successful, i.e. if the input was valid base64 data, false | ||
306 | otherwise. If *OUTLEN is too small, as many bytes as possible will | ||
307 | be written to OUT. On return, *OUTLEN holds the length of decoded | ||
308 | bytes in OUT. Note that as soon as any non-alphabet characters are | ||
309 | encountered, decoding is stopped and false is returned. This means | ||
310 | that, when applicable, you must remove any line terminators that is | ||
311 | part of the data stream before calling this function. */ | ||
312 | bool | ||
313 | base64_decode (const char *restrict in, size_t inlen, | ||
314 | char *restrict out, size_t *outlen) | ||
315 | { | ||
316 | size_t outleft = *outlen; | ||
317 | |||
318 | while (inlen >= 2) | ||
319 | { | ||
320 | if (!isbase64 (in[0]) || !isbase64 (in[1])) | ||
321 | break; | ||
322 | |||
323 | if (outleft) | ||
324 | { | ||
325 | *out++ = ((b64[to_uchar (in[0])] << 2) | ||
326 | | (b64[to_uchar (in[1])] >> 4)); | ||
327 | outleft--; | ||
328 | } | ||
329 | |||
330 | if (inlen == 2) | ||
331 | break; | ||
332 | |||
333 | if (in[2] == '=') | ||
334 | { | ||
335 | if (inlen != 4) | ||
336 | break; | ||
337 | |||
338 | if (in[3] != '=') | ||
339 | break; | ||
340 | |||
341 | } | ||
342 | else | ||
343 | { | ||
344 | if (!isbase64 (in[2])) | ||
345 | break; | ||
346 | |||
347 | if (outleft) | ||
348 | { | ||
349 | *out++ = (((b64[to_uchar (in[1])] << 4) & 0xf0) | ||
350 | | (b64[to_uchar (in[2])] >> 2)); | ||
351 | outleft--; | ||
352 | } | ||
353 | |||
354 | if (inlen == 3) | ||
355 | break; | ||
356 | |||
357 | if (in[3] == '=') | ||
358 | { | ||
359 | if (inlen != 4) | ||
360 | break; | ||
361 | } | ||
362 | else | ||
363 | { | ||
364 | if (!isbase64 (in[3])) | ||
365 | break; | ||
366 | |||
367 | if (outleft) | ||
368 | { | ||
369 | *out++ = (((b64[to_uchar (in[2])] << 6) & 0xc0) | ||
370 | | b64[to_uchar (in[3])]); | ||
371 | outleft--; | ||
372 | } | ||
373 | } | ||
374 | } | ||
375 | |||
376 | in += 4; | ||
377 | inlen -= 4; | ||
378 | } | ||
379 | |||
380 | *outlen -= outleft; | ||
381 | |||
382 | if (inlen != 0) | ||
383 | return false; | ||
384 | |||
385 | return true; | ||
386 | } | ||
387 | |||
388 | /* Allocate an output buffer in *OUT, and decode the base64 encoded | ||
389 | data stored in IN of size INLEN to the *OUT buffer. On return, the | ||
390 | size of the decoded data is stored in *OUTLEN. OUTLEN may be NULL, | ||
391 | if the caller is not interested in the decoded length. *OUT may be | ||
392 | NULL to indicate an out of memory error, in which case *OUTLEN | ||
393 | contains the size of the memory block needed. The function returns | ||
394 | true on successful decoding and memory allocation errors. (Use the | ||
395 | *OUT and *OUTLEN parameters to differentiate between successful | ||
396 | decoding and memory error.) The function returns false if the | ||
397 | input was invalid, in which case *OUT is NULL and *OUTLEN is | ||
398 | undefined. */ | ||
399 | bool | ||
400 | base64_decode_alloc (const char *in, size_t inlen, char **out, | ||
401 | size_t *outlen) | ||
402 | { | ||
403 | /* This may allocate a few bytes too much, depending on input, | ||
404 | but it's not worth the extra CPU time to compute the exact amount. | ||
405 | The exact amount is 3 * inlen / 4, minus 1 if the input ends | ||
406 | with "=" and minus another 1 if the input ends with "==". | ||
407 | Dividing before multiplying avoids the possibility of overflow. */ | ||
408 | size_t needlen = 3 * (inlen / 4) + 2; | ||
409 | |||
410 | *out = malloc (needlen); | ||
411 | if (!*out) | ||
412 | return true; | ||
413 | |||
414 | if (!base64_decode (in, inlen, *out, &needlen)) | ||
415 | { | ||
416 | free (*out); | ||
417 | *out = NULL; | ||
418 | return false; | ||
419 | } | ||
420 | |||
421 | if (outlen) | ||
422 | *outlen = needlen; | ||
423 | |||
424 | return true; | ||
425 | } | ||
diff --git a/gl/base64.h b/gl/base64.h new file mode 100644 index 0000000..1f9b203 --- /dev/null +++ b/gl/base64.h | |||
@@ -0,0 +1,45 @@ | |||
1 | /* base64.h -- Encode binary data using printable characters. | ||
2 | Copyright (C) 2004, 2005, 2006 Free Software Foundation, Inc. | ||
3 | Written by Simon Josefsson. | ||
4 | |||
5 | This program is free software; you can redistribute it and/or modify | ||
6 | it under the terms of the GNU General Public License as published by | ||
7 | the Free Software Foundation; either version 3, or (at your option) | ||
8 | any later version. | ||
9 | |||
10 | This program is distributed in the hope that it will be useful, | ||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | GNU General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU General Public License | ||
16 | along with this program; if not, write to the Free Software Foundation, | ||
17 | Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ | ||
18 | |||
19 | #ifndef BASE64_H | ||
20 | # define BASE64_H | ||
21 | |||
22 | /* Get size_t. */ | ||
23 | # include <stddef.h> | ||
24 | |||
25 | /* Get bool. */ | ||
26 | # include <stdbool.h> | ||
27 | |||
28 | /* This uses that the expression (n+(k-1))/k means the smallest | ||
29 | integer >= n/k, i.e., the ceiling of n/k. */ | ||
30 | # define BASE64_LENGTH(inlen) ((((inlen) + 2) / 3) * 4) | ||
31 | |||
32 | extern bool isbase64 (char ch); | ||
33 | |||
34 | extern void base64_encode (const char *restrict in, size_t inlen, | ||
35 | char *restrict out, size_t outlen); | ||
36 | |||
37 | extern size_t base64_encode_alloc (const char *in, size_t inlen, char **out); | ||
38 | |||
39 | extern bool base64_decode (const char *restrict in, size_t inlen, | ||
40 | char *restrict out, size_t *outlen); | ||
41 | |||
42 | extern bool base64_decode_alloc (const char *in, size_t inlen, | ||
43 | char **out, size_t *outlen); | ||
44 | |||
45 | #endif /* BASE64_H */ | ||
diff --git a/gl/charset.alias b/gl/charset.alias new file mode 100644 index 0000000..d9501e2 --- /dev/null +++ b/gl/charset.alias | |||
@@ -0,0 +1,5 @@ | |||
1 | # This file contains a table of character encoding aliases, | ||
2 | # suitable for operating system 'linux-gnu'. | ||
3 | # It was automatically generated from config.charset. | ||
4 | # Packages using this file: | ||
5 | ISO_646.IRV:1983 ASCII | ||
diff --git a/gl/configmake.h b/gl/configmake.h new file mode 100644 index 0000000..f73bc38 --- /dev/null +++ b/gl/configmake.h | |||
@@ -0,0 +1,25 @@ | |||
1 | /* DO NOT EDIT! GENERATED AUTOMATICALLY! */ | ||
2 | #define PREFIX "/usr/local/nagios" | ||
3 | #define EXEC_PREFIX "/usr/local/nagios" | ||
4 | #define BINDIR "/usr/local/nagios/bin" | ||
5 | #define SBINDIR "/usr/local/nagios/sbin" | ||
6 | #define LIBEXECDIR "/usr/local/nagios/libexec" | ||
7 | #define DATAROOTDIR "/usr/local/nagios/share" | ||
8 | #define DATADIR "/usr/local/nagios/share" | ||
9 | #define SYSCONFDIR "/usr/local/nagios/etc" | ||
10 | #define SHAREDSTATEDIR "/usr/local/nagios/com" | ||
11 | #define LOCALSTATEDIR "/usr/local/nagios/var" | ||
12 | #define INCLUDEDIR "/usr/local/nagios/include" | ||
13 | #define OLDINCLUDEDIR "/usr/include" | ||
14 | #define DOCDIR "/usr/local/nagios/share/doc/nagios-plugins" | ||
15 | #define INFODIR "/usr/local/nagios/share/info" | ||
16 | #define HTMLDIR "/usr/local/nagios/share/doc/nagios-plugins" | ||
17 | #define DVIDIR "/usr/local/nagios/share/doc/nagios-plugins" | ||
18 | #define PDFDIR "/usr/local/nagios/share/doc/nagios-plugins" | ||
19 | #define PSDIR "/usr/local/nagios/share/doc/nagios-plugins" | ||
20 | #define LIBDIR "/usr/local/nagios/lib" | ||
21 | #define LOCALEDIR "/usr/local/nagios/share/locale" | ||
22 | #define MANDIR "/usr/local/nagios/share/man" | ||
23 | #define PKGDATADIR "/usr/local/nagios/share/nagios-plugins" | ||
24 | #define PKGINCLUDEDIR "/usr/local/nagios/include/nagios-plugins" | ||
25 | #define PKGLIBDIR "/usr/local/nagios/lib/nagios-plugins" | ||
diff --git a/gl/floor.c b/gl/floor.c new file mode 100644 index 0000000..05a6591 --- /dev/null +++ b/gl/floor.c | |||
@@ -0,0 +1,93 @@ | |||
1 | /* Round towards negative infinity. | ||
2 | Copyright (C) 2007 Free Software Foundation, Inc. | ||
3 | |||
4 | This program is free software: you can redistribute it and/or modify | ||
5 | it under the terms of the GNU General Public License as published by | ||
6 | 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 | ||
12 | GNU 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 | /* Written by Bruno Haible <bruno@clisp.org>, 2007. */ | ||
18 | |||
19 | #include <config.h> | ||
20 | |||
21 | /* Specification. */ | ||
22 | #include <math.h> | ||
23 | |||
24 | #include <float.h> | ||
25 | |||
26 | #ifdef USE_LONG_DOUBLE | ||
27 | # define FUNC floorl | ||
28 | # define DOUBLE long double | ||
29 | # define MANT_DIG LDBL_MANT_DIG | ||
30 | # define L_(literal) literal##L | ||
31 | #elif ! defined USE_FLOAT | ||
32 | # define FUNC floor | ||
33 | # define DOUBLE double | ||
34 | # define MANT_DIG DBL_MANT_DIG | ||
35 | # define L_(literal) literal | ||
36 | #else /* defined USE_FLOAT */ | ||
37 | # define FUNC floorf | ||
38 | # define DOUBLE float | ||
39 | # define MANT_DIG FLT_MANT_DIG | ||
40 | # define L_(literal) literal##f | ||
41 | #endif | ||
42 | |||
43 | /* 2^(MANT_DIG-1). */ | ||
44 | static const DOUBLE TWO_MANT_DIG = | ||
45 | /* Assume MANT_DIG <= 5 * 31. | ||
46 | Use the identity | ||
47 | n = floor(n/5) + floor((n+1)/5) + ... + floor((n+4)/5). */ | ||
48 | (DOUBLE) (1U << ((MANT_DIG - 1) / 5)) | ||
49 | * (DOUBLE) (1U << ((MANT_DIG - 1 + 1) / 5)) | ||
50 | * (DOUBLE) (1U << ((MANT_DIG - 1 + 2) / 5)) | ||
51 | * (DOUBLE) (1U << ((MANT_DIG - 1 + 3) / 5)) | ||
52 | * (DOUBLE) (1U << ((MANT_DIG - 1 + 4) / 5)); | ||
53 | |||
54 | DOUBLE | ||
55 | FUNC (DOUBLE x) | ||
56 | { | ||
57 | /* The use of 'volatile' guarantees that excess precision bits are dropped | ||
58 | at each addition step and before the following comparison at the caller's | ||
59 | site. It is necessary on x86 systems where double-floats are not IEEE | ||
60 | compliant by default, to avoid that the results become platform and compiler | ||
61 | option dependent. 'volatile' is a portable alternative to gcc's | ||
62 | -ffloat-store option. */ | ||
63 | volatile DOUBLE y = x; | ||
64 | volatile DOUBLE z = y; | ||
65 | |||
66 | if (z > L_(0.0)) | ||
67 | { | ||
68 | /* Avoid rounding errors for values near 2^k, where k >= MANT_DIG-1. */ | ||
69 | if (z < TWO_MANT_DIG) | ||
70 | { | ||
71 | /* Round to the next integer (nearest or up or down, doesn't matter). */ | ||
72 | z += TWO_MANT_DIG; | ||
73 | z -= TWO_MANT_DIG; | ||
74 | /* Enforce rounding down. */ | ||
75 | if (z > y) | ||
76 | z -= L_(1.0); | ||
77 | } | ||
78 | } | ||
79 | else if (z < L_(0.0)) | ||
80 | { | ||
81 | /* Avoid rounding errors for values near -2^k, where k >= MANT_DIG-1. */ | ||
82 | if (z > - TWO_MANT_DIG) | ||
83 | { | ||
84 | /* Round to the next integer (nearest or up or down, doesn't matter). */ | ||
85 | z -= TWO_MANT_DIG; | ||
86 | z += TWO_MANT_DIG; | ||
87 | /* Enforce rounding down. */ | ||
88 | if (z > y) | ||
89 | z -= L_(1.0); | ||
90 | } | ||
91 | } | ||
92 | return z; | ||
93 | } | ||
diff --git a/gl/floorf.c b/gl/floorf.c new file mode 100644 index 0000000..f0aff33 --- /dev/null +++ b/gl/floorf.c | |||
@@ -0,0 +1,20 @@ | |||
1 | /* Round towards negative infinity. | ||
2 | Copyright (C) 2007 Free Software Foundation, Inc. | ||
3 | |||
4 | This program is free software: you can redistribute it and/or modify | ||
5 | it under the terms of the GNU General Public License as published by | ||
6 | 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 | ||
12 | GNU 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 | /* Written by Bruno Haible <bruno@clisp.org>, 2007. */ | ||
18 | |||
19 | #define USE_FLOAT | ||
20 | #include "floor.c" | ||
diff --git a/gl/m4/base64.m4 b/gl/m4/base64.m4 new file mode 100644 index 0000000..24801ef --- /dev/null +++ b/gl/m4/base64.m4 | |||
@@ -0,0 +1,16 @@ | |||
1 | # base64.m4 serial 3 | ||
2 | dnl Copyright (C) 2004, 2006 Free Software Foundation, Inc. | ||
3 | dnl This file is free software; the Free Software Foundation | ||
4 | dnl gives unlimited permission to copy and/or distribute it, | ||
5 | dnl with or without modifications, as long as this notice is preserved. | ||
6 | |||
7 | AC_DEFUN([gl_FUNC_BASE64], | ||
8 | [ | ||
9 | gl_PREREQ_BASE64 | ||
10 | ]) | ||
11 | |||
12 | # Prerequisites of lib/base64.c. | ||
13 | AC_DEFUN([gl_PREREQ_BASE64], [ | ||
14 | AC_REQUIRE([AC_C_INLINE]) | ||
15 | AC_REQUIRE([AC_C_RESTRICT]) | ||
16 | ]) | ||
diff --git a/gl/m4/floorf.m4 b/gl/m4/floorf.m4 new file mode 100644 index 0000000..8cdaa94 --- /dev/null +++ b/gl/m4/floorf.m4 | |||
@@ -0,0 +1,62 @@ | |||
1 | # floorf.m4 serial 3 | ||
2 | dnl Copyright (C) 2007 Free Software Foundation, Inc. | ||
3 | dnl This file is free software; the Free Software Foundation | ||
4 | dnl gives unlimited permission to copy and/or distribute it, | ||
5 | dnl with or without modifications, as long as this notice is preserved. | ||
6 | |||
7 | AC_DEFUN([gl_FUNC_FLOORF], | ||
8 | [ | ||
9 | AC_REQUIRE([gl_MATH_H_DEFAULTS]) | ||
10 | dnl Persuade glibc <math.h> to declare floorf(). | ||
11 | AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) | ||
12 | dnl Test whether floorf() is declared. | ||
13 | AC_CHECK_DECLS([floorf], , , [#include <math.h>]) | ||
14 | if test "$ac_cv_have_decl_floorf" = yes; then | ||
15 | dnl Test whether floorf() can be used without libm. | ||
16 | gl_FUNC_FLOORF_LIBS | ||
17 | if test "$FLOORF_LIBM" = "?"; then | ||
18 | dnl Sun C 5.0 on Solaris declares floorf() and has it in the system-wide | ||
19 | dnl libm.so, but not in the libm.so that the compiler uses. | ||
20 | REPLACE_FLOORF=1 | ||
21 | fi | ||
22 | else | ||
23 | REPLACE_FLOORF=1 | ||
24 | fi | ||
25 | if test $REPLACE_FLOORF = 1; then | ||
26 | AC_LIBOBJ([floorf]) | ||
27 | FLOORF_LIBM= | ||
28 | fi | ||
29 | AC_SUBST([REPLACE_FLOORF]) | ||
30 | AC_SUBST([FLOORF_LIBM]) | ||
31 | ]) | ||
32 | |||
33 | # Determines the libraries needed to get the floorf() function. | ||
34 | # Sets FLOORF_LIBM. | ||
35 | AC_DEFUN([gl_FUNC_FLOORF_LIBS], | ||
36 | [ | ||
37 | AC_CACHE_VAL([gl_cv_func_floorf_libm], [ | ||
38 | gl_cv_func_floorf_libm=? | ||
39 | AC_TRY_LINK([ | ||
40 | #ifndef __NO_MATH_INLINES | ||
41 | # define __NO_MATH_INLINES 1 /* for glibc */ | ||
42 | #endif | ||
43 | #include <math.h> | ||
44 | float x;], | ||
45 | [x = floorf(x);], | ||
46 | [gl_cv_func_floorf_libm=]) | ||
47 | if test "$gl_cv_func_floorf_libm" = "?"; then | ||
48 | save_LIBS="$LIBS" | ||
49 | LIBS="$LIBS -lm" | ||
50 | AC_TRY_LINK([ | ||
51 | #ifndef __NO_MATH_INLINES | ||
52 | # define __NO_MATH_INLINES 1 /* for glibc */ | ||
53 | #endif | ||
54 | #include <math.h> | ||
55 | float x;], | ||
56 | [x = floorf(x);], | ||
57 | [gl_cv_func_floorf_libm="-lm"]) | ||
58 | LIBS="$save_LIBS" | ||
59 | fi | ||
60 | ]) | ||
61 | FLOORF_LIBM="$gl_cv_func_floorf_libm" | ||
62 | ]) | ||
diff --git a/gl/m4/gnulib-cache.m4 b/gl/m4/gnulib-cache.m4 index 6da4d65..302dc19 100644 --- a/gl/m4/gnulib-cache.m4 +++ b/gl/m4/gnulib-cache.m4 | |||
@@ -15,11 +15,11 @@ | |||
15 | 15 | ||
16 | 16 | ||
17 | # Specification in the form of a command-line invocation: | 17 | # Specification in the form of a command-line invocation: |
18 | # gnulib-tool --import --dir=. --lib=libgnu --source-base=gl --m4-base=gl/m4 --doc-base=doc --aux-dir=build-aux --no-libtool --macro-prefix=gl dirname fsusage getaddrinfo gethostname getloadavg getopt gettext mountlist regex vasprintf vsnprintf | 18 | # gnulib-tool --import --dir=. --lib=libgnu --source-base=gl --m4-base=gl/m4 --doc-base=doc --aux-dir=build-aux --no-libtool --macro-prefix=gl base64 dirname floorf fsusage getaddrinfo gethostname getloadavg getopt gettext mountlist regex vasprintf vsnprintf |
19 | 19 | ||
20 | # Specification in the form of a few gnulib-tool.m4 macro invocations: | 20 | # Specification in the form of a few gnulib-tool.m4 macro invocations: |
21 | gl_LOCAL_DIR([]) | 21 | gl_LOCAL_DIR([]) |
22 | gl_MODULES([dirname fsusage getaddrinfo gethostname getloadavg getopt gettext mountlist regex vasprintf vsnprintf]) | 22 | gl_MODULES([base64 dirname floorf fsusage getaddrinfo gethostname getloadavg getopt gettext mountlist regex vasprintf vsnprintf]) |
23 | gl_AVOID([]) | 23 | gl_AVOID([]) |
24 | gl_SOURCE_BASE([gl]) | 24 | gl_SOURCE_BASE([gl]) |
25 | gl_M4_BASE([gl/m4]) | 25 | gl_M4_BASE([gl/m4]) |
diff --git a/gl/m4/gnulib-comp.m4 b/gl/m4/gnulib-comp.m4 index a17e36a..85ad2e9 100644 --- a/gl/m4/gnulib-comp.m4 +++ b/gl/m4/gnulib-comp.m4 | |||
@@ -44,6 +44,7 @@ AC_DEFUN([gl_INIT], | |||
44 | gl_FUNC_ALLOCA | 44 | gl_FUNC_ALLOCA |
45 | gl_HEADER_ARPA_INET | 45 | gl_HEADER_ARPA_INET |
46 | AC_PROG_MKDIR_P | 46 | AC_PROG_MKDIR_P |
47 | gl_FUNC_BASE64 | ||
47 | gl_C_STRTOD | 48 | gl_C_STRTOD |
48 | gl_CLOEXEC | 49 | gl_CLOEXEC |
49 | gl_DIRNAME | 50 | gl_DIRNAME |
@@ -56,6 +57,8 @@ AC_DEFUN([gl_INIT], | |||
56 | gl_FCNTL_SAFER | 57 | gl_FCNTL_SAFER |
57 | gl_MODULE_INDICATOR([fcntl-safer]) | 58 | gl_MODULE_INDICATOR([fcntl-safer]) |
58 | gl_FLOAT_H | 59 | gl_FLOAT_H |
60 | gl_FUNC_FLOORF | ||
61 | gl_MATH_MODULE_INDICATOR([floorf]) | ||
59 | gl_FSUSAGE | 62 | gl_FSUSAGE |
60 | gl_GETADDRINFO | 63 | gl_GETADDRINFO |
61 | gl_FUNC_GETHOSTNAME | 64 | gl_FUNC_GETHOSTNAME |
@@ -74,6 +77,7 @@ AC_DEFUN([gl_INIT], | |||
74 | AC_DEFINE([GNULIB_MALLOC_GNU], 1, [Define to indicate the 'malloc' module.]) | 77 | AC_DEFINE([GNULIB_MALLOC_GNU], 1, [Define to indicate the 'malloc' module.]) |
75 | gl_FUNC_MALLOC_POSIX | 78 | gl_FUNC_MALLOC_POSIX |
76 | gl_STDLIB_MODULE_INDICATOR([malloc-posix]) | 79 | gl_STDLIB_MODULE_INDICATOR([malloc-posix]) |
80 | gl_MATH_H | ||
77 | gl_MOUNTLIST | 81 | gl_MOUNTLIST |
78 | gl_HEADER_NETINET_IN | 82 | gl_HEADER_NETINET_IN |
79 | AC_PROG_MKDIR_P | 83 | AC_PROG_MKDIR_P |
@@ -240,6 +244,8 @@ AC_DEFUN([gl_FILE_LIST], [ | |||
240 | lib/alloca.in.h | 244 | lib/alloca.in.h |
241 | lib/asnprintf.c | 245 | lib/asnprintf.c |
242 | lib/asprintf.c | 246 | lib/asprintf.c |
247 | lib/base64.c | ||
248 | lib/base64.h | ||
243 | lib/basename.c | 249 | lib/basename.c |
244 | lib/c-strtod.c | 250 | lib/c-strtod.c |
245 | lib/c-strtod.h | 251 | lib/c-strtod.h |
@@ -259,6 +265,8 @@ AC_DEFUN([gl_FILE_LIST], [ | |||
259 | lib/fd-safer.c | 265 | lib/fd-safer.c |
260 | lib/float+.h | 266 | lib/float+.h |
261 | lib/float.in.h | 267 | lib/float.in.h |
268 | lib/floor.c | ||
269 | lib/floorf.c | ||
262 | lib/fsusage.c | 270 | lib/fsusage.c |
263 | lib/fsusage.h | 271 | lib/fsusage.h |
264 | lib/full-read.c | 272 | lib/full-read.c |
@@ -281,6 +289,7 @@ AC_DEFUN([gl_FILE_LIST], [ | |||
281 | lib/localcharset.c | 289 | lib/localcharset.c |
282 | lib/localcharset.h | 290 | lib/localcharset.h |
283 | lib/malloc.c | 291 | lib/malloc.c |
292 | lib/math.in.h | ||
284 | lib/mountlist.c | 293 | lib/mountlist.c |
285 | lib/mountlist.h | 294 | lib/mountlist.h |
286 | lib/netinet_in.in.h | 295 | lib/netinet_in.in.h |
@@ -333,6 +342,7 @@ AC_DEFUN([gl_FILE_LIST], [ | |||
333 | m4/absolute-header.m4 | 342 | m4/absolute-header.m4 |
334 | m4/alloca.m4 | 343 | m4/alloca.m4 |
335 | m4/arpa_inet_h.m4 | 344 | m4/arpa_inet_h.m4 |
345 | m4/base64.m4 | ||
336 | m4/c-strtod.m4 | 346 | m4/c-strtod.m4 |
337 | m4/cloexec.m4 | 347 | m4/cloexec.m4 |
338 | m4/codeset.m4 | 348 | m4/codeset.m4 |
@@ -345,6 +355,7 @@ AC_DEFUN([gl_FILE_LIST], [ | |||
345 | m4/extensions.m4 | 355 | m4/extensions.m4 |
346 | m4/fcntl-safer.m4 | 356 | m4/fcntl-safer.m4 |
347 | m4/float_h.m4 | 357 | m4/float_h.m4 |
358 | m4/floorf.m4 | ||
348 | m4/fstypename.m4 | 359 | m4/fstypename.m4 |
349 | m4/fsusage.m4 | 360 | m4/fsusage.m4 |
350 | m4/getaddrinfo.m4 | 361 | m4/getaddrinfo.m4 |
@@ -376,6 +387,7 @@ AC_DEFUN([gl_FILE_LIST], [ | |||
376 | m4/longlong.m4 | 387 | m4/longlong.m4 |
377 | m4/ls-mntd-fs.m4 | 388 | m4/ls-mntd-fs.m4 |
378 | m4/malloc.m4 | 389 | m4/malloc.m4 |
390 | m4/math_h.m4 | ||
379 | m4/mountlist.m4 | 391 | m4/mountlist.m4 |
380 | m4/netinet_in_h.m4 | 392 | m4/netinet_in_h.m4 |
381 | m4/nls.m4 | 393 | m4/nls.m4 |
diff --git a/gl/m4/math_h.m4 b/gl/m4/math_h.m4 new file mode 100644 index 0000000..dd99e7f --- /dev/null +++ b/gl/m4/math_h.m4 | |||
@@ -0,0 +1,66 @@ | |||
1 | # math_h.m4 serial 9 | ||
2 | dnl Copyright (C) 2007-2008 Free Software Foundation, Inc. | ||
3 | dnl This file is free software; the Free Software Foundation | ||
4 | dnl gives unlimited permission to copy and/or distribute it, | ||
5 | dnl with or without modifications, as long as this notice is preserved. | ||
6 | |||
7 | AC_DEFUN([gl_MATH_H], | ||
8 | [ | ||
9 | AC_REQUIRE([gl_MATH_H_DEFAULTS]) | ||
10 | gl_CHECK_NEXT_HEADERS([math.h]) | ||
11 | ]) | ||
12 | |||
13 | AC_DEFUN([gl_MATH_MODULE_INDICATOR], | ||
14 | [ | ||
15 | dnl Use AC_REQUIRE here, so that the default settings are expanded once only. | ||
16 | AC_REQUIRE([gl_MATH_H_DEFAULTS]) | ||
17 | GNULIB_[]m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./-],[ABCDEFGHIJKLMNOPQRSTUVWXYZ___])=1 | ||
18 | ]) | ||
19 | |||
20 | AC_DEFUN([gl_MATH_H_DEFAULTS], | ||
21 | [ | ||
22 | GNULIB_CEILF=0; AC_SUBST([GNULIB_CEILF]) | ||
23 | GNULIB_CEILL=0; AC_SUBST([GNULIB_CEILL]) | ||
24 | GNULIB_FLOORF=0; AC_SUBST([GNULIB_FLOORF]) | ||
25 | GNULIB_FLOORL=0; AC_SUBST([GNULIB_FLOORL]) | ||
26 | GNULIB_FREXP=0; AC_SUBST([GNULIB_FREXP]) | ||
27 | GNULIB_FREXPL=0; AC_SUBST([GNULIB_FREXPL]) | ||
28 | GNULIB_ISFINITE=0; AC_SUBST([GNULIB_ISFINITE]) | ||
29 | GNULIB_LDEXPL=0; AC_SUBST([GNULIB_LDEXPL]) | ||
30 | GNULIB_MATHL=0; AC_SUBST([GNULIB_MATHL]) | ||
31 | GNULIB_ROUND=0; AC_SUBST([GNULIB_ROUND]) | ||
32 | GNULIB_ROUNDF=0; AC_SUBST([GNULIB_ROUNDF]) | ||
33 | GNULIB_ROUNDL=0; AC_SUBST([GNULIB_ROUNDL]) | ||
34 | GNULIB_SIGNBIT=0; AC_SUBST([GNULIB_SIGNBIT]) | ||
35 | GNULIB_TRUNC=0; AC_SUBST([GNULIB_TRUNC]) | ||
36 | GNULIB_TRUNCF=0; AC_SUBST([GNULIB_TRUNCF]) | ||
37 | GNULIB_TRUNCL=0; AC_SUBST([GNULIB_TRUNCL]) | ||
38 | dnl Assume proper GNU behavior unless another module says otherwise. | ||
39 | HAVE_DECL_ACOSL=1; AC_SUBST([HAVE_DECL_ACOSL]) | ||
40 | HAVE_DECL_ASINL=1; AC_SUBST([HAVE_DECL_ASINL]) | ||
41 | HAVE_DECL_ATANL=1; AC_SUBST([HAVE_DECL_ATANL]) | ||
42 | HAVE_DECL_COSL=1; AC_SUBST([HAVE_DECL_COSL]) | ||
43 | HAVE_DECL_EXPL=1; AC_SUBST([HAVE_DECL_EXPL]) | ||
44 | HAVE_DECL_FREXPL=1; AC_SUBST([HAVE_DECL_FREXPL]) | ||
45 | HAVE_DECL_LDEXPL=1; AC_SUBST([HAVE_DECL_LDEXPL]) | ||
46 | HAVE_DECL_LOGL=1; AC_SUBST([HAVE_DECL_LOGL]) | ||
47 | HAVE_DECL_SINL=1; AC_SUBST([HAVE_DECL_SINL]) | ||
48 | HAVE_DECL_SQRTL=1; AC_SUBST([HAVE_DECL_SQRTL]) | ||
49 | HAVE_DECL_TANL=1; AC_SUBST([HAVE_DECL_TANL]) | ||
50 | HAVE_DECL_TRUNC=1; AC_SUBST([HAVE_DECL_TRUNC]) | ||
51 | HAVE_DECL_TRUNCF=1; AC_SUBST([HAVE_DECL_TRUNCF]) | ||
52 | HAVE_DECL_TRUNCL=1; AC_SUBST([HAVE_DECL_TRUNCL]) | ||
53 | REPLACE_CEILF=0; AC_SUBST([REPLACE_CEILF]) | ||
54 | REPLACE_CEILL=0; AC_SUBST([REPLACE_CEILL]) | ||
55 | REPLACE_FLOORF=0; AC_SUBST([REPLACE_FLOORF]) | ||
56 | REPLACE_FLOORL=0; AC_SUBST([REPLACE_FLOORL]) | ||
57 | REPLACE_FREXP=0; AC_SUBST([REPLACE_FREXP]) | ||
58 | REPLACE_FREXPL=0; AC_SUBST([REPLACE_FREXPL]) | ||
59 | REPLACE_ISFINITE=0; AC_SUBST([REPLACE_ISFINITE]) | ||
60 | REPLACE_LDEXPL=0; AC_SUBST([REPLACE_LDEXPL]) | ||
61 | REPLACE_ROUND=0; AC_SUBST([REPLACE_ROUND]) | ||
62 | REPLACE_ROUNDF=0; AC_SUBST([REPLACE_ROUNDF]) | ||
63 | REPLACE_ROUNDL=0; AC_SUBST([REPLACE_ROUNDL]) | ||
64 | REPLACE_SIGNBIT=0; AC_SUBST([REPLACE_SIGNBIT]) | ||
65 | REPLACE_SIGNBIT_USING_GCC=0; AC_SUBST([REPLACE_SIGNBIT_USING_GCC]) | ||
66 | ]) | ||
diff --git a/gl/math.h b/gl/math.h new file mode 100644 index 0000000..9db986e --- /dev/null +++ b/gl/math.h | |||
@@ -0,0 +1,442 @@ | |||
1 | /* DO NOT EDIT! GENERATED AUTOMATICALLY! */ | ||
2 | /* A GNU-like <math.h>. | ||
3 | |||
4 | Copyright (C) 2002-2003, 2007 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 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 | ||
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_MATH_H | ||
20 | |||
21 | /* The include_next requires a split double-inclusion guard. */ | ||
22 | #include_next <math.h> | ||
23 | |||
24 | #ifndef _GL_MATH_H | ||
25 | #define _GL_MATH_H | ||
26 | |||
27 | |||
28 | /* The definition of GL_LINK_WARNING is copied here. */ | ||
29 | /* GL_LINK_WARNING("literal string") arranges to emit the literal string as | ||
30 | a linker warning on most glibc systems. | ||
31 | We use a linker warning rather than a preprocessor warning, because | ||
32 | #warning cannot be used inside macros. */ | ||
33 | #ifndef GL_LINK_WARNING | ||
34 | /* This works on platforms with GNU ld and ELF object format. | ||
35 | Testing __GLIBC__ is sufficient for asserting that GNU ld is in use. | ||
36 | Testing __ELF__ guarantees the ELF object format. | ||
37 | Testing __GNUC__ is necessary for the compound expression syntax. */ | ||
38 | # if defined __GLIBC__ && defined __ELF__ && defined __GNUC__ | ||
39 | # define GL_LINK_WARNING(message) \ | ||
40 | GL_LINK_WARNING1 (__FILE__, __LINE__, message) | ||
41 | # define GL_LINK_WARNING1(file, line, message) \ | ||
42 | GL_LINK_WARNING2 (file, line, message) /* macroexpand file and line */ | ||
43 | # define GL_LINK_WARNING2(file, line, message) \ | ||
44 | GL_LINK_WARNING3 (file ":" #line ": warning: " message) | ||
45 | # define GL_LINK_WARNING3(message) \ | ||
46 | ({ static const char warning[sizeof (message)] \ | ||
47 | __attribute__ ((__unused__, \ | ||
48 | __section__ (".gnu.warning"), \ | ||
49 | __aligned__ (1))) \ | ||
50 | = message "\n"; \ | ||
51 | (void)0; \ | ||
52 | }) | ||
53 | # else | ||
54 | # define GL_LINK_WARNING(message) ((void) 0) | ||
55 | # endif | ||
56 | #endif | ||
57 | |||
58 | |||
59 | #ifdef __cplusplus | ||
60 | extern "C" { | ||
61 | #endif | ||
62 | |||
63 | |||
64 | /* Write x as | ||
65 | x = mantissa * 2^exp | ||
66 | where | ||
67 | If x finite and nonzero: 0.5 <= |mantissa| < 1.0. | ||
68 | If x is zero: mantissa = x, exp = 0. | ||
69 | If x is infinite or NaN: mantissa = x, exp unspecified. | ||
70 | Store exp in *EXPPTR and return mantissa. */ | ||
71 | #if 0 | ||
72 | # if 0 | ||
73 | # define frexp rpl_frexp | ||
74 | extern double frexp (double x, int *expptr); | ||
75 | # endif | ||
76 | #elif defined GNULIB_POSIXCHECK | ||
77 | # undef frexp | ||
78 | # define frexp(x,e) \ | ||
79 | (GL_LINK_WARNING ("frexp is unportable - " \ | ||
80 | "use gnulib module frexp for portability"), \ | ||
81 | frexp (x, e)) | ||
82 | #endif | ||
83 | |||
84 | |||
85 | #if 0 || !1 | ||
86 | extern long double acosl (long double x); | ||
87 | #endif | ||
88 | #if !0 && defined GNULIB_POSIXCHECK | ||
89 | # undef acosl | ||
90 | # define acosl(x) \ | ||
91 | (GL_LINK_WARNING ("acosl is unportable - " \ | ||
92 | "use gnulib module mathl for portability"), \ | ||
93 | acosl (x)) | ||
94 | #endif | ||
95 | |||
96 | |||
97 | #if 0 || !1 | ||
98 | extern long double asinl (long double x); | ||
99 | #endif | ||
100 | #if !0 && defined GNULIB_POSIXCHECK | ||
101 | # undef asinl | ||
102 | # define asinl(x) \ | ||
103 | (GL_LINK_WARNING ("asinl is unportable - " \ | ||
104 | "use gnulib module mathl for portability"), \ | ||
105 | asinl (x)) | ||
106 | #endif | ||
107 | |||
108 | |||
109 | #if 0 || !1 | ||
110 | extern long double atanl (long double x); | ||
111 | #endif | ||
112 | #if !0 && defined GNULIB_POSIXCHECK | ||
113 | # undef atanl | ||
114 | # define atanl(x) \ | ||
115 | (GL_LINK_WARNING ("atanl is unportable - " \ | ||
116 | "use gnulib module mathl for portability"), \ | ||
117 | atanl (x)) | ||
118 | #endif | ||
119 | |||
120 | |||
121 | #if 0 | ||
122 | # if 0 | ||
123 | # define ceilf rpl_ceilf | ||
124 | extern float ceilf (float x); | ||
125 | # endif | ||
126 | #elif defined GNULIB_POSIXCHECK | ||
127 | # undef ceilf | ||
128 | # define ceilf(x) \ | ||
129 | (GL_LINK_WARNING ("ceilf is unportable - " \ | ||
130 | "use gnulib module ceilf for portability"), \ | ||
131 | ceilf (x)) | ||
132 | #endif | ||
133 | |||
134 | #if 0 | ||
135 | # if 0 | ||
136 | # define ceill rpl_ceill | ||
137 | extern long double ceill (long double x); | ||
138 | # endif | ||
139 | #elif defined GNULIB_POSIXCHECK | ||
140 | # undef ceill | ||
141 | # define ceill(x) \ | ||
142 | (GL_LINK_WARNING ("ceill is unportable - " \ | ||
143 | "use gnulib module ceill for portability"), \ | ||
144 | ceill (x)) | ||
145 | #endif | ||
146 | |||
147 | |||
148 | #if 0 || !1 | ||
149 | extern long double cosl (long double x); | ||
150 | #endif | ||
151 | #if !0 && defined GNULIB_POSIXCHECK | ||
152 | # undef cosl | ||
153 | # define cosl(x) \ | ||
154 | (GL_LINK_WARNING ("cosl is unportable - " \ | ||
155 | "use gnulib module mathl for portability"), \ | ||
156 | cosl (x)) | ||
157 | #endif | ||
158 | |||
159 | |||
160 | #if 0 || !1 | ||
161 | extern long double expl (long double x); | ||
162 | #endif | ||
163 | #if !0 && defined GNULIB_POSIXCHECK | ||
164 | # undef expl | ||
165 | # define expl(x) \ | ||
166 | (GL_LINK_WARNING ("expl is unportable - " \ | ||
167 | "use gnulib module mathl for portability"), \ | ||
168 | expl (x)) | ||
169 | #endif | ||
170 | |||
171 | |||
172 | #if 1 | ||
173 | # if 0 | ||
174 | # define floorf rpl_floorf | ||
175 | extern float floorf (float x); | ||
176 | # endif | ||
177 | #elif defined GNULIB_POSIXCHECK | ||
178 | # undef floorf | ||
179 | # define floorf(x) \ | ||
180 | (GL_LINK_WARNING ("floorf is unportable - " \ | ||
181 | "use gnulib module floorf for portability"), \ | ||
182 | floorf (x)) | ||
183 | #endif | ||
184 | |||
185 | #if 0 | ||
186 | # if 0 | ||
187 | # define floorl rpl_floorl | ||
188 | extern long double floorl (long double x); | ||
189 | # endif | ||
190 | #elif defined GNULIB_POSIXCHECK | ||
191 | # undef floorl | ||
192 | # define floorl(x) \ | ||
193 | (GL_LINK_WARNING ("floorl is unportable - " \ | ||
194 | "use gnulib module floorl for portability"), \ | ||
195 | floorl (x)) | ||
196 | #endif | ||
197 | |||
198 | |||
199 | /* Write x as | ||
200 | x = mantissa * 2^exp | ||
201 | where | ||
202 | If x finite and nonzero: 0.5 <= |mantissa| < 1.0. | ||
203 | If x is zero: mantissa = x, exp = 0. | ||
204 | If x is infinite or NaN: mantissa = x, exp unspecified. | ||
205 | Store exp in *EXPPTR and return mantissa. */ | ||
206 | #if 0 && 0 | ||
207 | # define frexpl rpl_frexpl | ||
208 | #endif | ||
209 | #if (0 && 0) || !1 | ||
210 | extern long double frexpl (long double x, int *expptr); | ||
211 | #endif | ||
212 | #if !0 && defined GNULIB_POSIXCHECK | ||
213 | # undef frexpl | ||
214 | # define frexpl(x,e) \ | ||
215 | (GL_LINK_WARNING ("frexpl is unportable - " \ | ||
216 | "use gnulib module frexpl for portability"), \ | ||
217 | frexpl (x, e)) | ||
218 | #endif | ||
219 | |||
220 | |||
221 | /* Return x * 2^exp. */ | ||
222 | #if 0 && 0 | ||
223 | # define ldexpl rpl_ldexpl | ||
224 | #endif | ||
225 | #if (0 && 0) || !1 | ||
226 | extern long double ldexpl (long double x, int exp); | ||
227 | #endif | ||
228 | #if !0 && defined GNULIB_POSIXCHECK | ||
229 | # undef ldexpl | ||
230 | # define ldexpl(x,e) \ | ||
231 | (GL_LINK_WARNING ("ldexpl is unportable - " \ | ||
232 | "use gnulib module ldexpl for portability"), \ | ||
233 | ldexpl (x, e)) | ||
234 | #endif | ||
235 | |||
236 | |||
237 | #if 0 || !1 | ||
238 | extern long double logl (long double x); | ||
239 | #endif | ||
240 | #if !0 && defined GNULIB_POSIXCHECK | ||
241 | # undef logl | ||
242 | # define logl(x) \ | ||
243 | (GL_LINK_WARNING ("logl is unportable - " \ | ||
244 | "use gnulib module mathl for portability"), \ | ||
245 | logl (x)) | ||
246 | #endif | ||
247 | |||
248 | |||
249 | #if 0 | ||
250 | # if 0 | ||
251 | # undef roundf | ||
252 | # define roundf rpl_roundf | ||
253 | extern float roundf (float x); | ||
254 | # endif | ||
255 | #elif defined GNULIB_POSIXCHECK | ||
256 | # undef roundf | ||
257 | # define roundf(x) \ | ||
258 | (GL_LINK_WARNING ("roundf is unportable - " \ | ||
259 | "use gnulib module roundf for portability"), \ | ||
260 | roundf (x)) | ||
261 | #endif | ||
262 | |||
263 | #if 0 | ||
264 | # if 0 | ||
265 | # undef round | ||
266 | # define round rpl_round | ||
267 | extern double round (double x); | ||
268 | # endif | ||
269 | #elif defined GNULIB_POSIXCHECK | ||
270 | # undef round | ||
271 | # define round(x) \ | ||
272 | (GL_LINK_WARNING ("round is unportable - " \ | ||
273 | "use gnulib module round for portability"), \ | ||
274 | round (x)) | ||
275 | #endif | ||
276 | |||
277 | #if 0 | ||
278 | # if 0 | ||
279 | # undef roundl | ||
280 | # define roundl rpl_roundl | ||
281 | extern long double roundl (long double x); | ||
282 | # endif | ||
283 | #elif defined GNULIB_POSIXCHECK | ||
284 | # undef roundl | ||
285 | # define roundl(x) \ | ||
286 | (GL_LINK_WARNING ("roundl is unportable - " \ | ||
287 | "use gnulib module roundl for portability"), \ | ||
288 | roundl (x)) | ||
289 | #endif | ||
290 | |||
291 | |||
292 | #if 0 || !1 | ||
293 | extern long double sinl (long double x); | ||
294 | #endif | ||
295 | #if !0 && defined GNULIB_POSIXCHECK | ||
296 | # undef sinl | ||
297 | # define sinl(x) \ | ||
298 | (GL_LINK_WARNING ("sinl is unportable - " \ | ||
299 | "use gnulib module mathl for portability"), \ | ||
300 | sinl (x)) | ||
301 | #endif | ||
302 | |||
303 | |||
304 | #if 0 || !1 | ||
305 | extern long double sqrtl (long double x); | ||
306 | #endif | ||
307 | #if !0 && defined GNULIB_POSIXCHECK | ||
308 | # undef sqrtl | ||
309 | # define sqrtl(x) \ | ||
310 | (GL_LINK_WARNING ("sqrtl is unportable - " \ | ||
311 | "use gnulib module mathl for portability"), \ | ||
312 | sqrtl (x)) | ||
313 | #endif | ||
314 | |||
315 | |||
316 | #if 0 || !1 | ||
317 | extern long double tanl (long double x); | ||
318 | #endif | ||
319 | #if !0 && defined GNULIB_POSIXCHECK | ||
320 | # undef tanl | ||
321 | # define tanl(x) \ | ||
322 | (GL_LINK_WARNING ("tanl is unportable - " \ | ||
323 | "use gnulib module mathl for portability"), \ | ||
324 | tanl (x)) | ||
325 | #endif | ||
326 | |||
327 | |||
328 | #if 0 | ||
329 | # if !1 | ||
330 | # define truncf rpl_truncf | ||
331 | extern float truncf (float x); | ||
332 | # endif | ||
333 | #elif defined GNULIB_POSIXCHECK | ||
334 | # undef truncf | ||
335 | # define truncf(x) \ | ||
336 | (GL_LINK_WARNING ("truncf is unportable - " \ | ||
337 | "use gnulib module truncf for portability"), \ | ||
338 | truncf (x)) | ||
339 | #endif | ||
340 | |||
341 | #if 0 | ||
342 | # if !1 | ||
343 | # define trunc rpl_trunc | ||
344 | extern double trunc (double x); | ||
345 | # endif | ||
346 | #elif defined GNULIB_POSIXCHECK | ||
347 | # undef trunc | ||
348 | # define trunc(x) \ | ||
349 | (GL_LINK_WARNING ("trunc is unportable - " \ | ||
350 | "use gnulib module trunc for portability"), \ | ||
351 | trunc (x)) | ||
352 | #endif | ||
353 | |||
354 | #if 0 | ||
355 | # if !1 | ||
356 | # define truncl rpl_truncl | ||
357 | extern long double truncl (long double x); | ||
358 | # endif | ||
359 | #elif defined GNULIB_POSIXCHECK | ||
360 | # undef truncl | ||
361 | # define truncl(x) \ | ||
362 | (GL_LINK_WARNING ("truncl is unportable - " \ | ||
363 | "use gnulib module truncl for portability"), \ | ||
364 | truncl (x)) | ||
365 | #endif | ||
366 | |||
367 | |||
368 | #if 0 | ||
369 | # if 0 | ||
370 | extern int gl_isfinitef (float x); | ||
371 | extern int gl_isfinited (double x); | ||
372 | extern int gl_isfinitel (long double x); | ||
373 | # undef isfinite | ||
374 | # define isfinite(x) \ | ||
375 | (sizeof (x) == sizeof (long double) ? gl_isfinitel (x) : \ | ||
376 | sizeof (x) == sizeof (double) ? gl_isfinited (x) : \ | ||
377 | gl_isfinitef (x)) | ||
378 | # endif | ||
379 | #elif defined GNULIB_POSIXCHECK | ||
380 | /* How to override a macro? */ | ||
381 | #endif | ||
382 | |||
383 | |||
384 | #if 0 | ||
385 | # if 0 | ||
386 | # undef signbit | ||
387 | /* GCC 4.0 and newer provides three built-ins for signbit. */ | ||
388 | # define signbit(x) \ | ||
389 | (sizeof (x) == sizeof (long double) ? __builtin_signbitl (x) : \ | ||
390 | sizeof (x) == sizeof (double) ? __builtin_signbit (x) : \ | ||
391 | __builtin_signbitf (x)) | ||
392 | # endif | ||
393 | # if 0 | ||
394 | # undef signbit | ||
395 | extern int gl_signbitf (float arg); | ||
396 | extern int gl_signbitd (double arg); | ||
397 | extern int gl_signbitl (long double arg); | ||
398 | # if __GNUC__ >= 2 && !__STRICT_ANSI__ | ||
399 | # if defined FLT_SIGNBIT_WORD && defined FLT_SIGNBIT_BIT | ||
400 | # define gl_signbitf(arg) \ | ||
401 | ({ union { float _value; \ | ||
402 | unsigned int _word[(sizeof (float) + sizeof (unsigned int) - 1) / sizeof (unsigned int)]; \ | ||
403 | } _m; \ | ||
404 | _m._value = (arg); \ | ||
405 | (_m._word[FLT_SIGNBIT_WORD] >> FLT_SIGNBIT_BIT) & 1; \ | ||
406 | }) | ||
407 | # endif | ||
408 | # if defined DBL_SIGNBIT_WORD && defined DBL_SIGNBIT_BIT | ||
409 | # define gl_signbitd(arg) \ | ||
410 | ({ union { double _value; \ | ||
411 | unsigned int _word[(sizeof (double) + sizeof (unsigned int) - 1) / sizeof (unsigned int)]; \ | ||
412 | } _m; \ | ||
413 | _m._value = (arg); \ | ||
414 | (_m._word[DBL_SIGNBIT_WORD] >> DBL_SIGNBIT_BIT) & 1; \ | ||
415 | }) | ||
416 | # endif | ||
417 | # if defined LDBL_SIGNBIT_WORD && defined LDBL_SIGNBIT_BIT | ||
418 | # define gl_signbitl(arg) \ | ||
419 | ({ union { long double _value; \ | ||
420 | unsigned int _word[(sizeof (long double) + sizeof (unsigned int) - 1) / sizeof (unsigned int)]; \ | ||
421 | } _m; \ | ||
422 | _m._value = (arg); \ | ||
423 | (_m._word[LDBL_SIGNBIT_WORD] >> LDBL_SIGNBIT_BIT) & 1; \ | ||
424 | }) | ||
425 | # endif | ||
426 | # endif | ||
427 | # define signbit(x) \ | ||
428 | (sizeof (x) == sizeof (long double) ? gl_signbitl (x) : \ | ||
429 | sizeof (x) == sizeof (double) ? gl_signbitd (x) : \ | ||
430 | gl_signbitf (x)) | ||
431 | # endif | ||
432 | #elif defined GNULIB_POSIXCHECK | ||
433 | /* How to override a macro? */ | ||
434 | #endif | ||
435 | |||
436 | |||
437 | #ifdef __cplusplus | ||
438 | } | ||
439 | #endif | ||
440 | |||
441 | #endif /* _GL_MATH_H */ | ||
442 | #endif /* _GL_MATH_H */ | ||
diff --git a/gl/math.in.h b/gl/math.in.h new file mode 100644 index 0000000..c3515d7 --- /dev/null +++ b/gl/math.in.h | |||
@@ -0,0 +1,413 @@ | |||
1 | /* A GNU-like <math.h>. | ||
2 | |||
3 | Copyright (C) 2002-2003, 2007 Free Software Foundation, Inc. | ||
4 | |||
5 | This program is free software: you can redistribute it and/or modify | ||
6 | it under the terms of the GNU General Public License as published by | ||
7 | the Free Software Foundation; either version 3 of the License, or | ||
8 | (at your option) any later version. | ||
9 | |||
10 | This program is distributed in the hope that it will be useful, | ||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | GNU General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU General Public License | ||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ | ||
17 | |||
18 | #ifndef _GL_MATH_H | ||
19 | |||
20 | /* The include_next requires a split double-inclusion guard. */ | ||
21 | #@INCLUDE_NEXT@ @NEXT_MATH_H@ | ||
22 | |||
23 | #ifndef _GL_MATH_H | ||
24 | #define _GL_MATH_H | ||
25 | |||
26 | |||
27 | /* The definition of GL_LINK_WARNING is copied here. */ | ||
28 | |||
29 | |||
30 | #ifdef __cplusplus | ||
31 | extern "C" { | ||
32 | #endif | ||
33 | |||
34 | |||
35 | /* Write x as | ||
36 | x = mantissa * 2^exp | ||
37 | where | ||
38 | If x finite and nonzero: 0.5 <= |mantissa| < 1.0. | ||
39 | If x is zero: mantissa = x, exp = 0. | ||
40 | If x is infinite or NaN: mantissa = x, exp unspecified. | ||
41 | Store exp in *EXPPTR and return mantissa. */ | ||
42 | #if @GNULIB_FREXP@ | ||
43 | # if @REPLACE_FREXP@ | ||
44 | # define frexp rpl_frexp | ||
45 | extern double frexp (double x, int *expptr); | ||
46 | # endif | ||
47 | #elif defined GNULIB_POSIXCHECK | ||
48 | # undef frexp | ||
49 | # define frexp(x,e) \ | ||
50 | (GL_LINK_WARNING ("frexp is unportable - " \ | ||
51 | "use gnulib module frexp for portability"), \ | ||
52 | frexp (x, e)) | ||
53 | #endif | ||
54 | |||
55 | |||
56 | #if @GNULIB_MATHL@ || !@HAVE_DECL_ACOSL@ | ||
57 | extern long double acosl (long double x); | ||
58 | #endif | ||
59 | #if !@GNULIB_MATHL@ && defined GNULIB_POSIXCHECK | ||
60 | # undef acosl | ||
61 | # define acosl(x) \ | ||
62 | (GL_LINK_WARNING ("acosl is unportable - " \ | ||
63 | "use gnulib module mathl for portability"), \ | ||
64 | acosl (x)) | ||
65 | #endif | ||
66 | |||
67 | |||
68 | #if @GNULIB_MATHL@ || !@HAVE_DECL_ASINL@ | ||
69 | extern long double asinl (long double x); | ||
70 | #endif | ||
71 | #if !@GNULIB_MATHL@ && defined GNULIB_POSIXCHECK | ||
72 | # undef asinl | ||
73 | # define asinl(x) \ | ||
74 | (GL_LINK_WARNING ("asinl is unportable - " \ | ||
75 | "use gnulib module mathl for portability"), \ | ||
76 | asinl (x)) | ||
77 | #endif | ||
78 | |||
79 | |||
80 | #if @GNULIB_MATHL@ || !@HAVE_DECL_ATANL@ | ||
81 | extern long double atanl (long double x); | ||
82 | #endif | ||
83 | #if !@GNULIB_MATHL@ && defined GNULIB_POSIXCHECK | ||
84 | # undef atanl | ||
85 | # define atanl(x) \ | ||
86 | (GL_LINK_WARNING ("atanl is unportable - " \ | ||
87 | "use gnulib module mathl for portability"), \ | ||
88 | atanl (x)) | ||
89 | #endif | ||
90 | |||
91 | |||
92 | #if @GNULIB_CEILF@ | ||
93 | # if @REPLACE_CEILF@ | ||
94 | # define ceilf rpl_ceilf | ||
95 | extern float ceilf (float x); | ||
96 | # endif | ||
97 | #elif defined GNULIB_POSIXCHECK | ||
98 | # undef ceilf | ||
99 | # define ceilf(x) \ | ||
100 | (GL_LINK_WARNING ("ceilf is unportable - " \ | ||
101 | "use gnulib module ceilf for portability"), \ | ||
102 | ceilf (x)) | ||
103 | #endif | ||
104 | |||
105 | #if @GNULIB_CEILL@ | ||
106 | # if @REPLACE_CEILL@ | ||
107 | # define ceill rpl_ceill | ||
108 | extern long double ceill (long double x); | ||
109 | # endif | ||
110 | #elif defined GNULIB_POSIXCHECK | ||
111 | # undef ceill | ||
112 | # define ceill(x) \ | ||
113 | (GL_LINK_WARNING ("ceill is unportable - " \ | ||
114 | "use gnulib module ceill for portability"), \ | ||
115 | ceill (x)) | ||
116 | #endif | ||
117 | |||
118 | |||
119 | #if @GNULIB_MATHL@ || !@HAVE_DECL_COSL@ | ||
120 | extern long double cosl (long double x); | ||
121 | #endif | ||
122 | #if !@GNULIB_MATHL@ && defined GNULIB_POSIXCHECK | ||
123 | # undef cosl | ||
124 | # define cosl(x) \ | ||
125 | (GL_LINK_WARNING ("cosl is unportable - " \ | ||
126 | "use gnulib module mathl for portability"), \ | ||
127 | cosl (x)) | ||
128 | #endif | ||
129 | |||
130 | |||
131 | #if @GNULIB_MATHL@ || !@HAVE_DECL_EXPL@ | ||
132 | extern long double expl (long double x); | ||
133 | #endif | ||
134 | #if !@GNULIB_MATHL@ && defined GNULIB_POSIXCHECK | ||
135 | # undef expl | ||
136 | # define expl(x) \ | ||
137 | (GL_LINK_WARNING ("expl is unportable - " \ | ||
138 | "use gnulib module mathl for portability"), \ | ||
139 | expl (x)) | ||
140 | #endif | ||
141 | |||
142 | |||
143 | #if @GNULIB_FLOORF@ | ||
144 | # if @REPLACE_FLOORF@ | ||
145 | # define floorf rpl_floorf | ||
146 | extern float floorf (float x); | ||
147 | # endif | ||
148 | #elif defined GNULIB_POSIXCHECK | ||
149 | # undef floorf | ||
150 | # define floorf(x) \ | ||
151 | (GL_LINK_WARNING ("floorf is unportable - " \ | ||
152 | "use gnulib module floorf for portability"), \ | ||
153 | floorf (x)) | ||
154 | #endif | ||
155 | |||
156 | #if @GNULIB_FLOORL@ | ||
157 | # if @REPLACE_FLOORL@ | ||
158 | # define floorl rpl_floorl | ||
159 | extern long double floorl (long double x); | ||
160 | # endif | ||
161 | #elif defined GNULIB_POSIXCHECK | ||
162 | # undef floorl | ||
163 | # define floorl(x) \ | ||
164 | (GL_LINK_WARNING ("floorl is unportable - " \ | ||
165 | "use gnulib module floorl for portability"), \ | ||
166 | floorl (x)) | ||
167 | #endif | ||
168 | |||
169 | |||
170 | /* Write x as | ||
171 | x = mantissa * 2^exp | ||
172 | where | ||
173 | If x finite and nonzero: 0.5 <= |mantissa| < 1.0. | ||
174 | If x is zero: mantissa = x, exp = 0. | ||
175 | If x is infinite or NaN: mantissa = x, exp unspecified. | ||
176 | Store exp in *EXPPTR and return mantissa. */ | ||
177 | #if @GNULIB_FREXPL@ && @REPLACE_FREXPL@ | ||
178 | # define frexpl rpl_frexpl | ||
179 | #endif | ||
180 | #if (@GNULIB_FREXPL@ && @REPLACE_FREXPL@) || !@HAVE_DECL_FREXPL@ | ||
181 | extern long double frexpl (long double x, int *expptr); | ||
182 | #endif | ||
183 | #if !@GNULIB_FREXPL@ && defined GNULIB_POSIXCHECK | ||
184 | # undef frexpl | ||
185 | # define frexpl(x,e) \ | ||
186 | (GL_LINK_WARNING ("frexpl is unportable - " \ | ||
187 | "use gnulib module frexpl for portability"), \ | ||
188 | frexpl (x, e)) | ||
189 | #endif | ||
190 | |||
191 | |||
192 | /* Return x * 2^exp. */ | ||
193 | #if @GNULIB_LDEXPL@ && @REPLACE_LDEXPL@ | ||
194 | # define ldexpl rpl_ldexpl | ||
195 | #endif | ||
196 | #if (@GNULIB_LDEXPL@ && @REPLACE_LDEXPL@) || !@HAVE_DECL_LDEXPL@ | ||
197 | extern long double ldexpl (long double x, int exp); | ||
198 | #endif | ||
199 | #if !@GNULIB_LDEXPL@ && defined GNULIB_POSIXCHECK | ||
200 | # undef ldexpl | ||
201 | # define ldexpl(x,e) \ | ||
202 | (GL_LINK_WARNING ("ldexpl is unportable - " \ | ||
203 | "use gnulib module ldexpl for portability"), \ | ||
204 | ldexpl (x, e)) | ||
205 | #endif | ||
206 | |||
207 | |||
208 | #if @GNULIB_MATHL@ || !@HAVE_DECL_LOGL@ | ||
209 | extern long double logl (long double x); | ||
210 | #endif | ||
211 | #if !@GNULIB_MATHL@ && defined GNULIB_POSIXCHECK | ||
212 | # undef logl | ||
213 | # define logl(x) \ | ||
214 | (GL_LINK_WARNING ("logl is unportable - " \ | ||
215 | "use gnulib module mathl for portability"), \ | ||
216 | logl (x)) | ||
217 | #endif | ||
218 | |||
219 | |||
220 | #if @GNULIB_ROUNDF@ | ||
221 | # if @REPLACE_ROUNDF@ | ||
222 | # undef roundf | ||
223 | # define roundf rpl_roundf | ||
224 | extern float roundf (float x); | ||
225 | # endif | ||
226 | #elif defined GNULIB_POSIXCHECK | ||
227 | # undef roundf | ||
228 | # define roundf(x) \ | ||
229 | (GL_LINK_WARNING ("roundf is unportable - " \ | ||
230 | "use gnulib module roundf for portability"), \ | ||
231 | roundf (x)) | ||
232 | #endif | ||
233 | |||
234 | #if @GNULIB_ROUND@ | ||
235 | # if @REPLACE_ROUND@ | ||
236 | # undef round | ||
237 | # define round rpl_round | ||
238 | extern double round (double x); | ||
239 | # endif | ||
240 | #elif defined GNULIB_POSIXCHECK | ||
241 | # undef round | ||
242 | # define round(x) \ | ||
243 | (GL_LINK_WARNING ("round is unportable - " \ | ||
244 | "use gnulib module round for portability"), \ | ||
245 | round (x)) | ||
246 | #endif | ||
247 | |||
248 | #if @GNULIB_ROUNDL@ | ||
249 | # if @REPLACE_ROUNDL@ | ||
250 | # undef roundl | ||
251 | # define roundl rpl_roundl | ||
252 | extern long double roundl (long double x); | ||
253 | # endif | ||
254 | #elif defined GNULIB_POSIXCHECK | ||
255 | # undef roundl | ||
256 | # define roundl(x) \ | ||
257 | (GL_LINK_WARNING ("roundl is unportable - " \ | ||
258 | "use gnulib module roundl for portability"), \ | ||
259 | roundl (x)) | ||
260 | #endif | ||
261 | |||
262 | |||
263 | #if @GNULIB_MATHL@ || !@HAVE_DECL_SINL@ | ||
264 | extern long double sinl (long double x); | ||
265 | #endif | ||
266 | #if !@GNULIB_MATHL@ && defined GNULIB_POSIXCHECK | ||
267 | # undef sinl | ||
268 | # define sinl(x) \ | ||
269 | (GL_LINK_WARNING ("sinl is unportable - " \ | ||
270 | "use gnulib module mathl for portability"), \ | ||
271 | sinl (x)) | ||
272 | #endif | ||
273 | |||
274 | |||
275 | #if @GNULIB_MATHL@ || !@HAVE_DECL_SQRTL@ | ||
276 | extern long double sqrtl (long double x); | ||
277 | #endif | ||
278 | #if !@GNULIB_MATHL@ && defined GNULIB_POSIXCHECK | ||
279 | # undef sqrtl | ||
280 | # define sqrtl(x) \ | ||
281 | (GL_LINK_WARNING ("sqrtl is unportable - " \ | ||
282 | "use gnulib module mathl for portability"), \ | ||
283 | sqrtl (x)) | ||
284 | #endif | ||
285 | |||
286 | |||
287 | #if @GNULIB_MATHL@ || !@HAVE_DECL_TANL@ | ||
288 | extern long double tanl (long double x); | ||
289 | #endif | ||
290 | #if !@GNULIB_MATHL@ && defined GNULIB_POSIXCHECK | ||
291 | # undef tanl | ||
292 | # define tanl(x) \ | ||
293 | (GL_LINK_WARNING ("tanl is unportable - " \ | ||
294 | "use gnulib module mathl for portability"), \ | ||
295 | tanl (x)) | ||
296 | #endif | ||
297 | |||
298 | |||
299 | #if @GNULIB_TRUNCF@ | ||
300 | # if !@HAVE_DECL_TRUNCF@ | ||
301 | # define truncf rpl_truncf | ||
302 | extern float truncf (float x); | ||
303 | # endif | ||
304 | #elif defined GNULIB_POSIXCHECK | ||
305 | # undef truncf | ||
306 | # define truncf(x) \ | ||
307 | (GL_LINK_WARNING ("truncf is unportable - " \ | ||
308 | "use gnulib module truncf for portability"), \ | ||
309 | truncf (x)) | ||
310 | #endif | ||
311 | |||
312 | #if @GNULIB_TRUNC@ | ||
313 | # if !@HAVE_DECL_TRUNC@ | ||
314 | # define trunc rpl_trunc | ||
315 | extern double trunc (double x); | ||
316 | # endif | ||
317 | #elif defined GNULIB_POSIXCHECK | ||
318 | # undef trunc | ||
319 | # define trunc(x) \ | ||
320 | (GL_LINK_WARNING ("trunc is unportable - " \ | ||
321 | "use gnulib module trunc for portability"), \ | ||
322 | trunc (x)) | ||
323 | #endif | ||
324 | |||
325 | #if @GNULIB_TRUNCL@ | ||
326 | # if !@HAVE_DECL_TRUNCL@ | ||
327 | # define truncl rpl_truncl | ||
328 | extern long double truncl (long double x); | ||
329 | # endif | ||
330 | #elif defined GNULIB_POSIXCHECK | ||
331 | # undef truncl | ||
332 | # define truncl(x) \ | ||
333 | (GL_LINK_WARNING ("truncl is unportable - " \ | ||
334 | "use gnulib module truncl for portability"), \ | ||
335 | truncl (x)) | ||
336 | #endif | ||
337 | |||
338 | |||
339 | #if @GNULIB_ISFINITE@ | ||
340 | # if @REPLACE_ISFINITE@ | ||
341 | extern int gl_isfinitef (float x); | ||
342 | extern int gl_isfinited (double x); | ||
343 | extern int gl_isfinitel (long double x); | ||
344 | # undef isfinite | ||
345 | # define isfinite(x) \ | ||
346 | (sizeof (x) == sizeof (long double) ? gl_isfinitel (x) : \ | ||
347 | sizeof (x) == sizeof (double) ? gl_isfinited (x) : \ | ||
348 | gl_isfinitef (x)) | ||
349 | # endif | ||
350 | #elif defined GNULIB_POSIXCHECK | ||
351 | /* How to override a macro? */ | ||
352 | #endif | ||
353 | |||
354 | |||
355 | #if @GNULIB_SIGNBIT@ | ||
356 | # if @REPLACE_SIGNBIT_USING_GCC@ | ||
357 | # undef signbit | ||
358 | /* GCC 4.0 and newer provides three built-ins for signbit. */ | ||
359 | # define signbit(x) \ | ||
360 | (sizeof (x) == sizeof (long double) ? __builtin_signbitl (x) : \ | ||
361 | sizeof (x) == sizeof (double) ? __builtin_signbit (x) : \ | ||
362 | __builtin_signbitf (x)) | ||
363 | # endif | ||
364 | # if @REPLACE_SIGNBIT@ | ||
365 | # undef signbit | ||
366 | extern int gl_signbitf (float arg); | ||
367 | extern int gl_signbitd (double arg); | ||
368 | extern int gl_signbitl (long double arg); | ||
369 | # if __GNUC__ >= 2 && !__STRICT_ANSI__ | ||
370 | # if defined FLT_SIGNBIT_WORD && defined FLT_SIGNBIT_BIT | ||
371 | # define gl_signbitf(arg) \ | ||
372 | ({ union { float _value; \ | ||
373 | unsigned int _word[(sizeof (float) + sizeof (unsigned int) - 1) / sizeof (unsigned int)]; \ | ||
374 | } _m; \ | ||
375 | _m._value = (arg); \ | ||
376 | (_m._word[FLT_SIGNBIT_WORD] >> FLT_SIGNBIT_BIT) & 1; \ | ||
377 | }) | ||
378 | # endif | ||
379 | # if defined DBL_SIGNBIT_WORD && defined DBL_SIGNBIT_BIT | ||
380 | # define gl_signbitd(arg) \ | ||
381 | ({ union { double _value; \ | ||
382 | unsigned int _word[(sizeof (double) + sizeof (unsigned int) - 1) / sizeof (unsigned int)]; \ | ||
383 | } _m; \ | ||
384 | _m._value = (arg); \ | ||
385 | (_m._word[DBL_SIGNBIT_WORD] >> DBL_SIGNBIT_BIT) & 1; \ | ||
386 | }) | ||
387 | # endif | ||
388 | # if defined LDBL_SIGNBIT_WORD && defined LDBL_SIGNBIT_BIT | ||
389 | # define gl_signbitl(arg) \ | ||
390 | ({ union { long double _value; \ | ||
391 | unsigned int _word[(sizeof (long double) + sizeof (unsigned int) - 1) / sizeof (unsigned int)]; \ | ||
392 | } _m; \ | ||
393 | _m._value = (arg); \ | ||
394 | (_m._word[LDBL_SIGNBIT_WORD] >> LDBL_SIGNBIT_BIT) & 1; \ | ||
395 | }) | ||
396 | # endif | ||
397 | # endif | ||
398 | # define signbit(x) \ | ||
399 | (sizeof (x) == sizeof (long double) ? gl_signbitl (x) : \ | ||
400 | sizeof (x) == sizeof (double) ? gl_signbitd (x) : \ | ||
401 | gl_signbitf (x)) | ||
402 | # endif | ||
403 | #elif defined GNULIB_POSIXCHECK | ||
404 | /* How to override a macro? */ | ||
405 | #endif | ||
406 | |||
407 | |||
408 | #ifdef __cplusplus | ||
409 | } | ||
410 | #endif | ||
411 | |||
412 | #endif /* _GL_MATH_H */ | ||
413 | #endif /* _GL_MATH_H */ | ||
diff --git a/gl/ref-add.sed b/gl/ref-add.sed new file mode 100644 index 0000000..3ac991f --- /dev/null +++ b/gl/ref-add.sed | |||
@@ -0,0 +1,10 @@ | |||
1 | /^# Packages using this file: / { | ||
2 | s/# Packages using this file:// | ||
3 | ta | ||
4 | :a | ||
5 | s/ nagios-plugins / nagios-plugins / | ||
6 | tb | ||
7 | s/ $/ nagios-plugins / | ||
8 | :b | ||
9 | s/^/# Packages using this file:/ | ||
10 | } | ||
diff --git a/gl/ref-del.sed b/gl/ref-del.sed new file mode 100644 index 0000000..a48fdb7 --- /dev/null +++ b/gl/ref-del.sed | |||
@@ -0,0 +1,5 @@ | |||
1 | /^# Packages using this file: / { | ||
2 | s/# Packages using this file:// | ||
3 | s/ nagios-plugins / / | ||
4 | s/^/# Packages using this file:/ | ||
5 | } | ||
diff --git a/gl/stdio.h b/gl/stdio.h new file mode 100644 index 0000000..f09ee83 --- /dev/null +++ b/gl/stdio.h | |||
@@ -0,0 +1,411 @@ | |||
1 | /* DO NOT EDIT! GENERATED AUTOMATICALLY! */ | ||
2 | /* A GNU-like <stdio.h>. | ||
3 | |||
4 | Copyright (C) 2004, 2007-2008 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, write to the Free Software Foundation, | ||
18 | Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ | ||
19 | |||
20 | #if defined __need_FILE || defined __need___FILE | ||
21 | /* Special invocation convention inside glibc header files. */ | ||
22 | |||
23 | #include_next <stdio.h> | ||
24 | |||
25 | #else | ||
26 | /* Normal invocation convention. */ | ||
27 | |||
28 | #ifndef _GL_STDIO_H | ||
29 | |||
30 | /* The include_next requires a split double-inclusion guard. */ | ||
31 | #include_next <stdio.h> | ||
32 | |||
33 | #ifndef _GL_STDIO_H | ||
34 | #define _GL_STDIO_H | ||
35 | |||
36 | #include <stdarg.h> | ||
37 | #include <stddef.h> | ||
38 | |||
39 | #if (0 && 0) \ | ||
40 | || (0 && 0) \ | ||
41 | || (0 && !1) \ | ||
42 | || (0 && (!1 || 0)) | ||
43 | /* Get off_t and ssize_t. */ | ||
44 | # include <sys/types.h> | ||
45 | #endif | ||
46 | |||
47 | #ifndef __attribute__ | ||
48 | /* This feature is available in gcc versions 2.5 and later. */ | ||
49 | # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) | ||
50 | # define __attribute__(Spec) /* empty */ | ||
51 | # endif | ||
52 | /* The __-protected variants of `format' and `printf' attributes | ||
53 | are accepted by gcc versions 2.6.4 (effectively 2.7) and later. */ | ||
54 | # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7) | ||
55 | # define __format__ format | ||
56 | # define __printf__ printf | ||
57 | # endif | ||
58 | #endif | ||
59 | |||
60 | |||
61 | /* The definition of GL_LINK_WARNING is copied here. */ | ||
62 | /* GL_LINK_WARNING("literal string") arranges to emit the literal string as | ||
63 | a linker warning on most glibc systems. | ||
64 | We use a linker warning rather than a preprocessor warning, because | ||
65 | #warning cannot be used inside macros. */ | ||
66 | #ifndef GL_LINK_WARNING | ||
67 | /* This works on platforms with GNU ld and ELF object format. | ||
68 | Testing __GLIBC__ is sufficient for asserting that GNU ld is in use. | ||
69 | Testing __ELF__ guarantees the ELF object format. | ||
70 | Testing __GNUC__ is necessary for the compound expression syntax. */ | ||
71 | # if defined __GLIBC__ && defined __ELF__ && defined __GNUC__ | ||
72 | # define GL_LINK_WARNING(message) \ | ||
73 | GL_LINK_WARNING1 (__FILE__, __LINE__, message) | ||
74 | # define GL_LINK_WARNING1(file, line, message) \ | ||
75 | GL_LINK_WARNING2 (file, line, message) /* macroexpand file and line */ | ||
76 | # define GL_LINK_WARNING2(file, line, message) \ | ||
77 | GL_LINK_WARNING3 (file ":" #line ": warning: " message) | ||
78 | # define GL_LINK_WARNING3(message) \ | ||
79 | ({ static const char warning[sizeof (message)] \ | ||
80 | __attribute__ ((__unused__, \ | ||
81 | __section__ (".gnu.warning"), \ | ||
82 | __aligned__ (1))) \ | ||
83 | = message "\n"; \ | ||
84 | (void)0; \ | ||
85 | }) | ||
86 | # else | ||
87 | # define GL_LINK_WARNING(message) ((void) 0) | ||
88 | # endif | ||
89 | #endif | ||
90 | |||
91 | |||
92 | #ifdef __cplusplus | ||
93 | extern "C" { | ||
94 | #endif | ||
95 | |||
96 | |||
97 | #if 0 | ||
98 | # if 0 | ||
99 | # define fprintf rpl_fprintf | ||
100 | extern int fprintf (FILE *fp, const char *format, ...) | ||
101 | __attribute__ ((__format__ (__printf__, 2, 3))); | ||
102 | # endif | ||
103 | #elif defined GNULIB_POSIXCHECK | ||
104 | # undef fprintf | ||
105 | # define fprintf \ | ||
106 | (GL_LINK_WARNING ("fprintf is not always POSIX compliant - " \ | ||
107 | "use gnulib module fprintf-posix for portable " \ | ||
108 | "POSIX compliance"), \ | ||
109 | fprintf) | ||
110 | #endif | ||
111 | |||
112 | #if 0 | ||
113 | # if 0 | ||
114 | # define vfprintf rpl_vfprintf | ||
115 | extern int vfprintf (FILE *fp, const char *format, va_list args) | ||
116 | __attribute__ ((__format__ (__printf__, 2, 0))); | ||
117 | # endif | ||
118 | #elif defined GNULIB_POSIXCHECK | ||
119 | # undef vfprintf | ||
120 | # define vfprintf(s,f,a) \ | ||
121 | (GL_LINK_WARNING ("vfprintf is not always POSIX compliant - " \ | ||
122 | "use gnulib module vfprintf-posix for portable " \ | ||
123 | "POSIX compliance"), \ | ||
124 | vfprintf (s, f, a)) | ||
125 | #endif | ||
126 | |||
127 | #if 0 | ||
128 | # if 0 | ||
129 | /* Don't break __attribute__((format(printf,M,N))). */ | ||
130 | # define printf __printf__ | ||
131 | extern int printf (const char *format, ...) | ||
132 | __attribute__ ((__format__ (__printf__, 1, 2))); | ||
133 | # endif | ||
134 | #elif defined GNULIB_POSIXCHECK | ||
135 | # undef printf | ||
136 | # define printf \ | ||
137 | (GL_LINK_WARNING ("printf is not always POSIX compliant - " \ | ||
138 | "use gnulib module printf-posix for portable " \ | ||
139 | "POSIX compliance"), \ | ||
140 | printf) | ||
141 | /* Don't break __attribute__((format(printf,M,N))). */ | ||
142 | # define format(kind,m,n) format (__##kind##__, m, n) | ||
143 | # define __format__(kind,m,n) __format__ (__##kind##__, m, n) | ||
144 | # define ____printf____ __printf__ | ||
145 | # define ____scanf____ __scanf__ | ||
146 | # define ____strftime____ __strftime__ | ||
147 | # define ____strfmon____ __strfmon__ | ||
148 | #endif | ||
149 | |||
150 | #if 0 | ||
151 | # if 0 | ||
152 | # define vprintf rpl_vprintf | ||
153 | extern int vprintf (const char *format, va_list args) | ||
154 | __attribute__ ((__format__ (__printf__, 1, 0))); | ||
155 | # endif | ||
156 | #elif defined GNULIB_POSIXCHECK | ||
157 | # undef vprintf | ||
158 | # define vprintf(f,a) \ | ||
159 | (GL_LINK_WARNING ("vprintf is not always POSIX compliant - " \ | ||
160 | "use gnulib module vprintf-posix for portable " \ | ||
161 | "POSIX compliance"), \ | ||
162 | vprintf (f, a)) | ||
163 | #endif | ||
164 | |||
165 | #if 1 | ||
166 | # if 0 | ||
167 | # define snprintf rpl_snprintf | ||
168 | # endif | ||
169 | # if 0 || !1 | ||
170 | extern int snprintf (char *str, size_t size, const char *format, ...) | ||
171 | __attribute__ ((__format__ (__printf__, 3, 4))); | ||
172 | # endif | ||
173 | #elif defined GNULIB_POSIXCHECK | ||
174 | # undef snprintf | ||
175 | # define snprintf \ | ||
176 | (GL_LINK_WARNING ("snprintf is unportable - " \ | ||
177 | "use gnulib module snprintf for portability"), \ | ||
178 | snprintf) | ||
179 | #endif | ||
180 | |||
181 | #if 1 | ||
182 | # if 0 | ||
183 | # define vsnprintf rpl_vsnprintf | ||
184 | # endif | ||
185 | # if 0 || !1 | ||
186 | extern int vsnprintf (char *str, size_t size, const char *format, va_list args) | ||
187 | __attribute__ ((__format__ (__printf__, 3, 0))); | ||
188 | # endif | ||
189 | #elif defined GNULIB_POSIXCHECK | ||
190 | # undef vsnprintf | ||
191 | # define vsnprintf(b,s,f,a) \ | ||
192 | (GL_LINK_WARNING ("vsnprintf is unportable - " \ | ||
193 | "use gnulib module vsnprintf for portability"), \ | ||
194 | vsnprintf (b, s, f, a)) | ||
195 | #endif | ||
196 | |||
197 | #if 0 | ||
198 | # if 0 | ||
199 | # define sprintf rpl_sprintf | ||
200 | extern int sprintf (char *str, const char *format, ...) | ||
201 | __attribute__ ((__format__ (__printf__, 2, 3))); | ||
202 | # endif | ||
203 | #elif defined GNULIB_POSIXCHECK | ||
204 | # undef sprintf | ||
205 | # define sprintf \ | ||
206 | (GL_LINK_WARNING ("sprintf is not always POSIX compliant - " \ | ||
207 | "use gnulib module sprintf-posix for portable " \ | ||
208 | "POSIX compliance"), \ | ||
209 | sprintf) | ||
210 | #endif | ||
211 | |||
212 | #if 0 | ||
213 | # if 0 | ||
214 | # define vsprintf rpl_vsprintf | ||
215 | extern int vsprintf (char *str, const char *format, va_list args) | ||
216 | __attribute__ ((__format__ (__printf__, 2, 0))); | ||
217 | # endif | ||
218 | #elif defined GNULIB_POSIXCHECK | ||
219 | # undef vsprintf | ||
220 | # define vsprintf(b,f,a) \ | ||
221 | (GL_LINK_WARNING ("vsprintf is not always POSIX compliant - " \ | ||
222 | "use gnulib module vsprintf-posix for portable " \ | ||
223 | "POSIX compliance"), \ | ||
224 | vsprintf (b, f, a)) | ||
225 | #endif | ||
226 | |||
227 | #if 1 | ||
228 | # if 0 | ||
229 | # define asprintf rpl_asprintf | ||
230 | # define vasprintf rpl_vasprintf | ||
231 | # endif | ||
232 | # if 0 || !1 | ||
233 | /* Write formatted output to a string dynamically allocated with malloc(). | ||
234 | If the memory allocation succeeds, store the address of the string in | ||
235 | *RESULT and return the number of resulting bytes, excluding the trailing | ||
236 | NUL. Upon memory allocation error, or some other error, return -1. */ | ||
237 | extern int asprintf (char **result, const char *format, ...) | ||
238 | __attribute__ ((__format__ (__printf__, 2, 3))); | ||
239 | extern int vasprintf (char **result, const char *format, va_list args) | ||
240 | __attribute__ ((__format__ (__printf__, 2, 0))); | ||
241 | # endif | ||
242 | #endif | ||
243 | |||
244 | #if 0 | ||
245 | # if 0 | ||
246 | # define fopen rpl_fopen | ||
247 | extern FILE * fopen (const char *filename, const char *mode); | ||
248 | # endif | ||
249 | #elif defined GNULIB_POSIXCHECK | ||
250 | # undef fopen | ||
251 | # define fopen(f,m) \ | ||
252 | (GL_LINK_WARNING ("fopen on Win32 platforms is not POSIX compatible - " \ | ||
253 | "use gnulib module fopen for portability"), \ | ||
254 | fopen (f, m)) | ||
255 | #endif | ||
256 | |||
257 | #if 0 | ||
258 | # if 0 | ||
259 | # define freopen rpl_freopen | ||
260 | extern FILE * freopen (const char *filename, const char *mode, FILE *stream); | ||
261 | # endif | ||
262 | #elif defined GNULIB_POSIXCHECK | ||
263 | # undef freopen | ||
264 | # define freopen(f,m,s) \ | ||
265 | (GL_LINK_WARNING ("freopen on Win32 platforms is not POSIX compatible - " \ | ||
266 | "use gnulib module freopen for portability"), \ | ||
267 | freopen (f, m, s)) | ||
268 | #endif | ||
269 | |||
270 | #if 0 | ||
271 | # if 0 | ||
272 | /* Provide fseek, fseeko functions that are aware of a preceding | ||
273 | fflush(), and which detect pipes. */ | ||
274 | # define fseeko rpl_fseeko | ||
275 | extern int fseeko (FILE *fp, off_t offset, int whence); | ||
276 | # define fseek(fp, offset, whence) fseeko (fp, (off_t)(offset), whence) | ||
277 | # endif | ||
278 | #elif defined GNULIB_POSIXCHECK | ||
279 | # undef fseeko | ||
280 | # define fseeko(f,o,w) \ | ||
281 | (GL_LINK_WARNING ("fseeko is unportable - " \ | ||
282 | "use gnulib module fseeko for portability"), \ | ||
283 | fseeko (f, o, w)) | ||
284 | #endif | ||
285 | |||
286 | #if 0 && 0 | ||
287 | extern int rpl_fseek (FILE *fp, long offset, int whence); | ||
288 | # undef fseek | ||
289 | # if defined GNULIB_POSIXCHECK | ||
290 | # define fseek(f,o,w) \ | ||
291 | (GL_LINK_WARNING ("fseek cannot handle files larger than 4 GB " \ | ||
292 | "on 32-bit platforms - " \ | ||
293 | "use fseeko function for handling of large files"), \ | ||
294 | rpl_fseek (f, o, w)) | ||
295 | # else | ||
296 | # define fseek rpl_fseek | ||
297 | # endif | ||
298 | #elif defined GNULIB_POSIXCHECK | ||
299 | # ifndef fseek | ||
300 | # define fseek(f,o,w) \ | ||
301 | (GL_LINK_WARNING ("fseek cannot handle files larger than 4 GB " \ | ||
302 | "on 32-bit platforms - " \ | ||
303 | "use fseeko function for handling of large files"), \ | ||
304 | fseek (f, o, w)) | ||
305 | # endif | ||
306 | #endif | ||
307 | |||
308 | #if 0 | ||
309 | # if 0 | ||
310 | # define ftello rpl_ftello | ||
311 | extern off_t ftello (FILE *fp); | ||
312 | # define ftell(fp) ftello (fp) | ||
313 | # endif | ||
314 | #elif defined GNULIB_POSIXCHECK | ||
315 | # undef ftello | ||
316 | # define ftello(f) \ | ||
317 | (GL_LINK_WARNING ("ftello is unportable - " \ | ||
318 | "use gnulib module ftello for portability"), \ | ||
319 | ftello (f)) | ||
320 | #endif | ||
321 | |||
322 | #if 0 && 0 | ||
323 | extern long rpl_ftell (FILE *fp); | ||
324 | # undef ftell | ||
325 | # if GNULIB_POSIXCHECK | ||
326 | # define ftell(f) \ | ||
327 | (GL_LINK_WARNING ("ftell cannot handle files larger than 4 GB " \ | ||
328 | "on 32-bit platforms - " \ | ||
329 | "use ftello function for handling of large files"), \ | ||
330 | rpl_ftell (f)) | ||
331 | # else | ||
332 | # define ftell rpl_ftell | ||
333 | # endif | ||
334 | #elif defined GNULIB_POSIXCHECK | ||
335 | # ifndef ftell | ||
336 | # define ftell(f) \ | ||
337 | (GL_LINK_WARNING ("ftell cannot handle files larger than 4 GB " \ | ||
338 | "on 32-bit platforms - " \ | ||
339 | "use ftello function for handling of large files"), \ | ||
340 | ftell (f)) | ||
341 | # endif | ||
342 | #endif | ||
343 | |||
344 | #if 0 | ||
345 | # if 0 | ||
346 | # define fflush rpl_fflush | ||
347 | /* Flush all pending data on STREAM according to POSIX rules. Both | ||
348 | output and seekable input streams are supported. | ||
349 | Note! LOSS OF DATA can occur if fflush is applied on an input stream | ||
350 | that is _not_seekable_ or on an update stream that is _not_seekable_ | ||
351 | and in which the most recent operation was input. Seekability can | ||
352 | be tested with lseek(fileno(fp),0,SEEK_CUR). */ | ||
353 | extern int fflush (FILE *gl_stream); | ||
354 | # endif | ||
355 | #elif defined GNULIB_POSIXCHECK | ||
356 | # undef fflush | ||
357 | # define fflush(f) \ | ||
358 | (GL_LINK_WARNING ("fflush is not always POSIX compliant - " \ | ||
359 | "use gnulib module fflush for portable " \ | ||
360 | "POSIX compliance"), \ | ||
361 | fflush (f)) | ||
362 | #endif | ||
363 | |||
364 | #if 0 | ||
365 | # if !1 | ||
366 | /* Read input, up to (and including) the next occurrence of DELIMITER, from | ||
367 | STREAM, store it in *LINEPTR (and NUL-terminate it). | ||
368 | *LINEPTR is a pointer returned from malloc (or NULL), pointing to *LINESIZE | ||
369 | bytes of space. It is realloc'd as necessary. | ||
370 | Return the number of bytes read and stored at *LINEPTR (not including the | ||
371 | NUL terminator), or -1 on error or EOF. */ | ||
372 | extern ssize_t getdelim (char **lineptr, size_t *linesize, int delimiter, | ||
373 | FILE *stream); | ||
374 | # endif | ||
375 | #elif defined GNULIB_POSIXCHECK | ||
376 | # undef getdelim | ||
377 | # define getdelim(l, s, d, f) \ | ||
378 | (GL_LINK_WARNING ("getdelim is unportable - " \ | ||
379 | "use gnulib module getdelim for portability"), \ | ||
380 | getdelim (l, s, d, f)) | ||
381 | #endif | ||
382 | |||
383 | #if 0 | ||
384 | # if 0 | ||
385 | # undef getline | ||
386 | # define getline rpl_getline | ||
387 | # endif | ||
388 | # if !1 || 0 | ||
389 | /* Read a line, up to (and including) the next newline, from STREAM, store it | ||
390 | in *LINEPTR (and NUL-terminate it). | ||
391 | *LINEPTR is a pointer returned from malloc (or NULL), pointing to *LINESIZE | ||
392 | bytes of space. It is realloc'd as necessary. | ||
393 | Return the number of bytes read and stored at *LINEPTR (not including the | ||
394 | NUL terminator), or -1 on error or EOF. */ | ||
395 | extern ssize_t getline (char **lineptr, size_t *linesize, FILE *stream); | ||
396 | # endif | ||
397 | #elif defined GNULIB_POSIXCHECK | ||
398 | # undef getline | ||
399 | # define getline(l, s, f) \ | ||
400 | (GL_LINK_WARNING ("getline is unportable - " \ | ||
401 | "use gnulib module getline for portability"), \ | ||
402 | getline (l, s, f)) | ||
403 | #endif | ||
404 | |||
405 | #ifdef __cplusplus | ||
406 | } | ||
407 | #endif | ||
408 | |||
409 | #endif /* _GL_STDIO_H */ | ||
410 | #endif /* _GL_STDIO_H */ | ||
411 | #endif | ||
diff --git a/gl/stdlib.h b/gl/stdlib.h new file mode 100644 index 0000000..86da899 --- /dev/null +++ b/gl/stdlib.h | |||
@@ -0,0 +1,237 @@ | |||
1 | /* DO NOT EDIT! GENERATED AUTOMATICALLY! */ | ||
2 | /* A GNU-like <stdlib.h>. | ||
3 | |||
4 | Copyright (C) 1995, 2001-2004, 2006-2007 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 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 | ||
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 | #if defined __need_malloc_and_calloc | ||
20 | /* Special invocation convention inside glibc header files. */ | ||
21 | |||
22 | #include_next <stdlib.h> | ||
23 | |||
24 | #else | ||
25 | /* Normal invocation convention. */ | ||
26 | |||
27 | #ifndef _GL_STDLIB_H | ||
28 | |||
29 | /* The include_next requires a split double-inclusion guard. */ | ||
30 | #include_next <stdlib.h> | ||
31 | |||
32 | #ifndef _GL_STDLIB_H | ||
33 | #define _GL_STDLIB_H | ||
34 | |||
35 | |||
36 | /* The definition of GL_LINK_WARNING is copied here. */ | ||
37 | /* GL_LINK_WARNING("literal string") arranges to emit the literal string as | ||
38 | a linker warning on most glibc systems. | ||
39 | We use a linker warning rather than a preprocessor warning, because | ||
40 | #warning cannot be used inside macros. */ | ||
41 | #ifndef GL_LINK_WARNING | ||
42 | /* This works on platforms with GNU ld and ELF object format. | ||
43 | Testing __GLIBC__ is sufficient for asserting that GNU ld is in use. | ||
44 | Testing __ELF__ guarantees the ELF object format. | ||
45 | Testing __GNUC__ is necessary for the compound expression syntax. */ | ||
46 | # if defined __GLIBC__ && defined __ELF__ && defined __GNUC__ | ||
47 | # define GL_LINK_WARNING(message) \ | ||
48 | GL_LINK_WARNING1 (__FILE__, __LINE__, message) | ||
49 | # define GL_LINK_WARNING1(file, line, message) \ | ||
50 | GL_LINK_WARNING2 (file, line, message) /* macroexpand file and line */ | ||
51 | # define GL_LINK_WARNING2(file, line, message) \ | ||
52 | GL_LINK_WARNING3 (file ":" #line ": warning: " message) | ||
53 | # define GL_LINK_WARNING3(message) \ | ||
54 | ({ static const char warning[sizeof (message)] \ | ||
55 | __attribute__ ((__unused__, \ | ||
56 | __section__ (".gnu.warning"), \ | ||
57 | __aligned__ (1))) \ | ||
58 | = message "\n"; \ | ||
59 | (void)0; \ | ||
60 | }) | ||
61 | # else | ||
62 | # define GL_LINK_WARNING(message) ((void) 0) | ||
63 | # endif | ||
64 | #endif | ||
65 | |||
66 | |||
67 | /* Some systems do not define EXIT_*, despite otherwise supporting C89. */ | ||
68 | #ifndef EXIT_SUCCESS | ||
69 | # define EXIT_SUCCESS 0 | ||
70 | #endif | ||
71 | /* Tandem/NSK and other platforms that define EXIT_FAILURE as -1 interfere | ||
72 | with proper operation of xargs. */ | ||
73 | #ifndef EXIT_FAILURE | ||
74 | # define EXIT_FAILURE 1 | ||
75 | #elif EXIT_FAILURE != 1 | ||
76 | # undef EXIT_FAILURE | ||
77 | # define EXIT_FAILURE 1 | ||
78 | #endif | ||
79 | |||
80 | |||
81 | #ifdef __cplusplus | ||
82 | extern "C" { | ||
83 | #endif | ||
84 | |||
85 | |||
86 | #if 1 | ||
87 | # if !1 | ||
88 | # undef malloc | ||
89 | # define malloc rpl_malloc | ||
90 | extern void * malloc (size_t size); | ||
91 | # endif | ||
92 | #elif defined GNULIB_POSIXCHECK | ||
93 | # undef malloc | ||
94 | # define malloc(s) \ | ||
95 | (GL_LINK_WARNING ("malloc is not POSIX compliant everywhere - " \ | ||
96 | "use gnulib module malloc-posix for portability"), \ | ||
97 | malloc (s)) | ||
98 | #endif | ||
99 | |||
100 | |||
101 | #if 0 | ||
102 | # if !1 | ||
103 | # undef realloc | ||
104 | # define realloc rpl_realloc | ||
105 | extern void * realloc (void *ptr, size_t size); | ||
106 | # endif | ||
107 | #elif defined GNULIB_POSIXCHECK | ||
108 | # undef realloc | ||
109 | # define realloc(p,s) \ | ||
110 | (GL_LINK_WARNING ("realloc is not POSIX compliant everywhere - " \ | ||
111 | "use gnulib module realloc-posix for portability"), \ | ||
112 | realloc (p, s)) | ||
113 | #endif | ||
114 | |||
115 | |||
116 | #if 0 | ||
117 | # if !1 | ||
118 | # undef calloc | ||
119 | # define calloc rpl_calloc | ||
120 | extern void * calloc (size_t nmemb, size_t size); | ||
121 | # endif | ||
122 | #elif defined GNULIB_POSIXCHECK | ||
123 | # undef calloc | ||
124 | # define calloc(n,s) \ | ||
125 | (GL_LINK_WARNING ("calloc is not POSIX compliant everywhere - " \ | ||
126 | "use gnulib module calloc-posix for portability"), \ | ||
127 | calloc (n, s)) | ||
128 | #endif | ||
129 | |||
130 | |||
131 | #if 0 | ||
132 | /* Assuming *OPTIONP is a comma separated list of elements of the form | ||
133 | "token" or "token=value", getsubopt parses the first of these elements. | ||
134 | If the first element refers to a "token" that is member of the given | ||
135 | NULL-terminated array of tokens: | ||
136 | - It replaces the comma with a NUL byte, updates *OPTIONP to point past | ||
137 | the first option and the comma, sets *VALUEP to the value of the | ||
138 | element (or NULL if it doesn't contain an "=" sign), | ||
139 | - It returns the index of the "token" in the given array of tokens. | ||
140 | Otherwise it returns -1, and *OPTIONP and *VALUEP are undefined. | ||
141 | For more details see the POSIX:2001 specification. | ||
142 | http://www.opengroup.org/susv3xsh/getsubopt.html */ | ||
143 | # if !1 | ||
144 | extern int getsubopt (char **optionp, char *const *tokens, char **valuep); | ||
145 | # endif | ||
146 | #elif defined GNULIB_POSIXCHECK | ||
147 | # undef getsubopt | ||
148 | # define getsubopt(o,t,v) \ | ||
149 | (GL_LINK_WARNING ("getsubopt is unportable - " \ | ||
150 | "use gnulib module getsubopt for portability"), \ | ||
151 | getsubopt (o, t, v)) | ||
152 | #endif | ||
153 | |||
154 | |||
155 | #if 0 | ||
156 | # if !1 | ||
157 | /* Create a unique temporary directory from TEMPLATE. | ||
158 | The last six characters of TEMPLATE must be "XXXXXX"; | ||
159 | they are replaced with a string that makes the directory name unique. | ||
160 | Returns TEMPLATE, or a null pointer if it cannot get a unique name. | ||
161 | The directory is created mode 700. */ | ||
162 | extern char * mkdtemp (char * /*template*/); | ||
163 | # endif | ||
164 | #elif defined GNULIB_POSIXCHECK | ||
165 | # undef mkdtemp | ||
166 | # define mkdtemp(t) \ | ||
167 | (GL_LINK_WARNING ("mkdtemp is unportable - " \ | ||
168 | "use gnulib module mkdtemp for portability"), \ | ||
169 | mkdtemp (t)) | ||
170 | #endif | ||
171 | |||
172 | |||
173 | #if 0 | ||
174 | # if 0 | ||
175 | /* Create a unique temporary file from TEMPLATE. | ||
176 | The last six characters of TEMPLATE must be "XXXXXX"; | ||
177 | they are replaced with a string that makes the file name unique. | ||
178 | The file is then created, ensuring it didn't exist before. | ||
179 | The file is created read-write (mask at least 0600 & ~umask), but it may be | ||
180 | world-readable and world-writable (mask 0666 & ~umask), depending on the | ||
181 | implementation. | ||
182 | Returns the open file descriptor if successful, otherwise -1 and errno | ||
183 | set. */ | ||
184 | # define mkstemp rpl_mkstemp | ||
185 | extern int mkstemp (char * /*template*/); | ||
186 | # else | ||
187 | /* On MacOS X 10.3, only <unistd.h> declares mkstemp. */ | ||
188 | # include <unistd.h> | ||
189 | # endif | ||
190 | #elif defined GNULIB_POSIXCHECK | ||
191 | # undef mkstemp | ||
192 | # define mkstemp(t) \ | ||
193 | (GL_LINK_WARNING ("mkstemp is unportable - " \ | ||
194 | "use gnulib module mkstemp for portability"), \ | ||
195 | mkstemp (t)) | ||
196 | #endif | ||
197 | |||
198 | |||
199 | #if 0 | ||
200 | # if 0 | ||
201 | # undef putenv | ||
202 | # define putenv rpl_putenv | ||
203 | extern int putenv (char *string); | ||
204 | # endif | ||
205 | #endif | ||
206 | |||
207 | |||
208 | #if 0 | ||
209 | # if !1 | ||
210 | /* Set NAME to VALUE in the environment. | ||
211 | If REPLACE is nonzero, overwrite an existing value. */ | ||
212 | extern int setenv (const char *name, const char *value, int replace); | ||
213 | # endif | ||
214 | #endif | ||
215 | |||
216 | |||
217 | #if 0 | ||
218 | # if 1 | ||
219 | # if 0 | ||
220 | /* On some systems, unsetenv() returns void. | ||
221 | This is the case for MacOS X 10.3, FreeBSD 4.8, NetBSD 1.6, OpenBSD 3.4. */ | ||
222 | # define unsetenv(name) ((unsetenv)(name), 0) | ||
223 | # endif | ||
224 | # else | ||
225 | /* Remove the variable NAME from the environment. */ | ||
226 | extern int unsetenv (const char *name); | ||
227 | # endif | ||
228 | #endif | ||
229 | |||
230 | |||
231 | #ifdef __cplusplus | ||
232 | } | ||
233 | #endif | ||
234 | |||
235 | #endif /* _GL_STDLIB_H */ | ||
236 | #endif /* _GL_STDLIB_H */ | ||
237 | #endif | ||
diff --git a/gl/string.h b/gl/string.h new file mode 100644 index 0000000..e5bcef5 --- /dev/null +++ b/gl/string.h | |||
@@ -0,0 +1,598 @@ | |||
1 | /* DO NOT EDIT! GENERATED AUTOMATICALLY! */ | ||
2 | /* A GNU-like <string.h>. | ||
3 | |||
4 | Copyright (C) 1995-1996, 2001-2008 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, write to the Free Software Foundation, | ||
18 | Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ | ||
19 | |||
20 | #ifndef _GL_STRING_H | ||
21 | |||
22 | /* The include_next requires a split double-inclusion guard. */ | ||
23 | #include_next <string.h> | ||
24 | |||
25 | #ifndef _GL_STRING_H | ||
26 | #define _GL_STRING_H | ||
27 | |||
28 | |||
29 | #ifndef __attribute__ | ||
30 | /* This feature is available in gcc versions 2.5 and later. */ | ||
31 | # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) | ||
32 | # define __attribute__(Spec) /* empty */ | ||
33 | # endif | ||
34 | /* The attribute __pure__ was added in gcc 2.96. */ | ||
35 | # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 96) | ||
36 | # define __pure__ /* empty */ | ||
37 | # endif | ||
38 | #endif | ||
39 | |||
40 | |||
41 | /* The definition of GL_LINK_WARNING is copied here. */ | ||
42 | /* GL_LINK_WARNING("literal string") arranges to emit the literal string as | ||
43 | a linker warning on most glibc systems. | ||
44 | We use a linker warning rather than a preprocessor warning, because | ||
45 | #warning cannot be used inside macros. */ | ||
46 | #ifndef GL_LINK_WARNING | ||
47 | /* This works on platforms with GNU ld and ELF object format. | ||
48 | Testing __GLIBC__ is sufficient for asserting that GNU ld is in use. | ||
49 | Testing __ELF__ guarantees the ELF object format. | ||
50 | Testing __GNUC__ is necessary for the compound expression syntax. */ | ||
51 | # if defined __GLIBC__ && defined __ELF__ && defined __GNUC__ | ||
52 | # define GL_LINK_WARNING(message) \ | ||
53 | GL_LINK_WARNING1 (__FILE__, __LINE__, message) | ||
54 | # define GL_LINK_WARNING1(file, line, message) \ | ||
55 | GL_LINK_WARNING2 (file, line, message) /* macroexpand file and line */ | ||
56 | # define GL_LINK_WARNING2(file, line, message) \ | ||
57 | GL_LINK_WARNING3 (file ":" #line ": warning: " message) | ||
58 | # define GL_LINK_WARNING3(message) \ | ||
59 | ({ static const char warning[sizeof (message)] \ | ||
60 | __attribute__ ((__unused__, \ | ||
61 | __section__ (".gnu.warning"), \ | ||
62 | __aligned__ (1))) \ | ||
63 | = message "\n"; \ | ||
64 | (void)0; \ | ||
65 | }) | ||
66 | # else | ||
67 | # define GL_LINK_WARNING(message) ((void) 0) | ||
68 | # endif | ||
69 | #endif | ||
70 | |||
71 | |||
72 | #ifdef __cplusplus | ||
73 | extern "C" { | ||
74 | #endif | ||
75 | |||
76 | |||
77 | /* Return the first occurrence of NEEDLE in HAYSTACK. */ | ||
78 | #if 0 | ||
79 | # if 0 | ||
80 | # define memmem rpl_memmem | ||
81 | # endif | ||
82 | # if ! 1 || 0 | ||
83 | extern void *memmem (void const *__haystack, size_t __haystack_len, | ||
84 | void const *__needle, size_t __needle_len) | ||
85 | __attribute__ ((__pure__)); | ||
86 | # endif | ||
87 | #elif defined GNULIB_POSIXCHECK | ||
88 | # undef memmem | ||
89 | # define memmem(a,al,b,bl) \ | ||
90 | (GL_LINK_WARNING ("memmem is unportable and often quadratic - " \ | ||
91 | "use gnulib module memmem-simple for portability, " \ | ||
92 | "and module memmem for speed" ), \ | ||
93 | memmem (a, al, b, bl)) | ||
94 | #endif | ||
95 | |||
96 | /* Copy N bytes of SRC to DEST, return pointer to bytes after the | ||
97 | last written byte. */ | ||
98 | #if 0 | ||
99 | # if ! 1 | ||
100 | extern void *mempcpy (void *restrict __dest, void const *restrict __src, | ||
101 | size_t __n); | ||
102 | # endif | ||
103 | #elif defined GNULIB_POSIXCHECK | ||
104 | # undef mempcpy | ||
105 | # define mempcpy(a,b,n) \ | ||
106 | (GL_LINK_WARNING ("mempcpy is unportable - " \ | ||
107 | "use gnulib module mempcpy for portability"), \ | ||
108 | mempcpy (a, b, n)) | ||
109 | #endif | ||
110 | |||
111 | /* Search backwards through a block for a byte (specified as an int). */ | ||
112 | #if 0 | ||
113 | # if ! 1 | ||
114 | extern void *memrchr (void const *, int, size_t) | ||
115 | __attribute__ ((__pure__)); | ||
116 | # endif | ||
117 | #elif defined GNULIB_POSIXCHECK | ||
118 | # undef memrchr | ||
119 | # define memrchr(a,b,c) \ | ||
120 | (GL_LINK_WARNING ("memrchr is unportable - " \ | ||
121 | "use gnulib module memrchr for portability"), \ | ||
122 | memrchr (a, b, c)) | ||
123 | #endif | ||
124 | |||
125 | /* Copy SRC to DST, returning the address of the terminating '\0' in DST. */ | ||
126 | #if 0 | ||
127 | # if ! 1 | ||
128 | extern char *stpcpy (char *restrict __dst, char const *restrict __src); | ||
129 | # endif | ||
130 | #elif defined GNULIB_POSIXCHECK | ||
131 | # undef stpcpy | ||
132 | # define stpcpy(a,b) \ | ||
133 | (GL_LINK_WARNING ("stpcpy is unportable - " \ | ||
134 | "use gnulib module stpcpy for portability"), \ | ||
135 | stpcpy (a, b)) | ||
136 | #endif | ||
137 | |||
138 | /* Copy no more than N bytes of SRC to DST, returning a pointer past the | ||
139 | last non-NUL byte written into DST. */ | ||
140 | #if 0 | ||
141 | # if ! 1 | ||
142 | # define stpncpy gnu_stpncpy | ||
143 | extern char *stpncpy (char *restrict __dst, char const *restrict __src, | ||
144 | size_t __n); | ||
145 | # endif | ||
146 | #elif defined GNULIB_POSIXCHECK | ||
147 | # undef stpncpy | ||
148 | # define stpncpy(a,b,n) \ | ||
149 | (GL_LINK_WARNING ("stpncpy is unportable - " \ | ||
150 | "use gnulib module stpncpy for portability"), \ | ||
151 | stpncpy (a, b, n)) | ||
152 | #endif | ||
153 | |||
154 | #if defined GNULIB_POSIXCHECK | ||
155 | /* strchr() does not work with multibyte strings if the locale encoding is | ||
156 | GB18030 and the character to be searched is a digit. */ | ||
157 | # undef strchr | ||
158 | # define strchr(s,c) \ | ||
159 | (GL_LINK_WARNING ("strchr cannot work correctly on character strings " \ | ||
160 | "in some multibyte locales - " \ | ||
161 | "use mbschr if you care about internationalization"), \ | ||
162 | strchr (s, c)) | ||
163 | #endif | ||
164 | |||
165 | /* Find the first occurrence of C in S or the final NUL byte. */ | ||
166 | #if 0 | ||
167 | # if ! 1 | ||
168 | extern char *strchrnul (char const *__s, int __c_in) | ||
169 | __attribute__ ((__pure__)); | ||
170 | # endif | ||
171 | #elif defined GNULIB_POSIXCHECK | ||
172 | # undef strchrnul | ||
173 | # define strchrnul(a,b) \ | ||
174 | (GL_LINK_WARNING ("strchrnul is unportable - " \ | ||
175 | "use gnulib module strchrnul for portability"), \ | ||
176 | strchrnul (a, b)) | ||
177 | #endif | ||
178 | |||
179 | /* Duplicate S, returning an identical malloc'd string. */ | ||
180 | #if 1 | ||
181 | # if ! 1 && ! defined strdup | ||
182 | extern char *strdup (char const *__s); | ||
183 | # endif | ||
184 | #elif defined GNULIB_POSIXCHECK | ||
185 | # undef strdup | ||
186 | # define strdup(a) \ | ||
187 | (GL_LINK_WARNING ("strdup is unportable - " \ | ||
188 | "use gnulib module strdup for portability"), \ | ||
189 | strdup (a)) | ||
190 | #endif | ||
191 | |||
192 | /* Return a newly allocated copy of at most N bytes of STRING. */ | ||
193 | #if 1 | ||
194 | # if ! 1 | ||
195 | # undef strndup | ||
196 | # define strndup rpl_strndup | ||
197 | # endif | ||
198 | # if ! 1 || ! 1 | ||
199 | extern char *strndup (char const *__string, size_t __n); | ||
200 | # endif | ||
201 | #elif defined GNULIB_POSIXCHECK | ||
202 | # undef strndup | ||
203 | # define strndup(a,n) \ | ||
204 | (GL_LINK_WARNING ("strndup is unportable - " \ | ||
205 | "use gnulib module strndup for portability"), \ | ||
206 | strndup (a, n)) | ||
207 | #endif | ||
208 | |||
209 | /* Find the length (number of bytes) of STRING, but scan at most | ||
210 | MAXLEN bytes. If no '\0' terminator is found in that many bytes, | ||
211 | return MAXLEN. */ | ||
212 | #if 1 | ||
213 | # if ! 1 | ||
214 | extern size_t strnlen (char const *__string, size_t __maxlen) | ||
215 | __attribute__ ((__pure__)); | ||
216 | # endif | ||
217 | #elif defined GNULIB_POSIXCHECK | ||
218 | # undef strnlen | ||
219 | # define strnlen(a,n) \ | ||
220 | (GL_LINK_WARNING ("strnlen is unportable - " \ | ||
221 | "use gnulib module strnlen for portability"), \ | ||
222 | strnlen (a, n)) | ||
223 | #endif | ||
224 | |||
225 | #if defined GNULIB_POSIXCHECK | ||
226 | /* strcspn() assumes the second argument is a list of single-byte characters. | ||
227 | Even in this simple case, it does not work with multibyte strings if the | ||
228 | locale encoding is GB18030 and one of the characters to be searched is a | ||
229 | digit. */ | ||
230 | # undef strcspn | ||
231 | # define strcspn(s,a) \ | ||
232 | (GL_LINK_WARNING ("strcspn cannot work correctly on character strings " \ | ||
233 | "in multibyte locales - " \ | ||
234 | "use mbscspn if you care about internationalization"), \ | ||
235 | strcspn (s, a)) | ||
236 | #endif | ||
237 | |||
238 | /* Find the first occurrence in S of any character in ACCEPT. */ | ||
239 | #if 0 | ||
240 | # if ! 1 | ||
241 | extern char *strpbrk (char const *__s, char const *__accept) | ||
242 | __attribute__ ((__pure__)); | ||
243 | # endif | ||
244 | # if defined GNULIB_POSIXCHECK | ||
245 | /* strpbrk() assumes the second argument is a list of single-byte characters. | ||
246 | Even in this simple case, it does not work with multibyte strings if the | ||
247 | locale encoding is GB18030 and one of the characters to be searched is a | ||
248 | digit. */ | ||
249 | # undef strpbrk | ||
250 | # define strpbrk(s,a) \ | ||
251 | (GL_LINK_WARNING ("strpbrk cannot work correctly on character strings " \ | ||
252 | "in multibyte locales - " \ | ||
253 | "use mbspbrk if you care about internationalization"), \ | ||
254 | strpbrk (s, a)) | ||
255 | # endif | ||
256 | #elif defined GNULIB_POSIXCHECK | ||
257 | # undef strpbrk | ||
258 | # define strpbrk(s,a) \ | ||
259 | (GL_LINK_WARNING ("strpbrk is unportable - " \ | ||
260 | "use gnulib module strpbrk for portability"), \ | ||
261 | strpbrk (s, a)) | ||
262 | #endif | ||
263 | |||
264 | #if defined GNULIB_POSIXCHECK | ||
265 | /* strspn() assumes the second argument is a list of single-byte characters. | ||
266 | Even in this simple case, it cannot work with multibyte strings. */ | ||
267 | # undef strspn | ||
268 | # define strspn(s,a) \ | ||
269 | (GL_LINK_WARNING ("strspn cannot work correctly on character strings " \ | ||
270 | "in multibyte locales - " \ | ||
271 | "use mbsspn if you care about internationalization"), \ | ||
272 | strspn (s, a)) | ||
273 | #endif | ||
274 | |||
275 | #if defined GNULIB_POSIXCHECK | ||
276 | /* strrchr() does not work with multibyte strings if the locale encoding is | ||
277 | GB18030 and the character to be searched is a digit. */ | ||
278 | # undef strrchr | ||
279 | # define strrchr(s,c) \ | ||
280 | (GL_LINK_WARNING ("strrchr cannot work correctly on character strings " \ | ||
281 | "in some multibyte locales - " \ | ||
282 | "use mbsrchr if you care about internationalization"), \ | ||
283 | strrchr (s, c)) | ||
284 | #endif | ||
285 | |||
286 | /* Search the next delimiter (char listed in DELIM) starting at *STRINGP. | ||
287 | If one is found, overwrite it with a NUL, and advance *STRINGP | ||
288 | to point to the next char after it. Otherwise, set *STRINGP to NULL. | ||
289 | If *STRINGP was already NULL, nothing happens. | ||
290 | Return the old value of *STRINGP. | ||
291 | |||
292 | This is a variant of strtok() that is multithread-safe and supports | ||
293 | empty fields. | ||
294 | |||
295 | Caveat: It modifies the original string. | ||
296 | Caveat: These functions cannot be used on constant strings. | ||
297 | Caveat: The identity of the delimiting character is lost. | ||
298 | Caveat: It doesn't work with multibyte strings unless all of the delimiter | ||
299 | characters are ASCII characters < 0x30. | ||
300 | |||
301 | See also strtok_r(). */ | ||
302 | #if 0 | ||
303 | # if ! 1 | ||
304 | extern char *strsep (char **restrict __stringp, char const *restrict __delim); | ||
305 | # endif | ||
306 | # if defined GNULIB_POSIXCHECK | ||
307 | # undef strsep | ||
308 | # define strsep(s,d) \ | ||
309 | (GL_LINK_WARNING ("strsep cannot work correctly on character strings " \ | ||
310 | "in multibyte locales - " \ | ||
311 | "use mbssep if you care about internationalization"), \ | ||
312 | strsep (s, d)) | ||
313 | # endif | ||
314 | #elif defined GNULIB_POSIXCHECK | ||
315 | # undef strsep | ||
316 | # define strsep(s,d) \ | ||
317 | (GL_LINK_WARNING ("strsep is unportable - " \ | ||
318 | "use gnulib module strsep for portability"), \ | ||
319 | strsep (s, d)) | ||
320 | #endif | ||
321 | |||
322 | #if 0 | ||
323 | # if 0 | ||
324 | # define strstr rpl_strstr | ||
325 | char *strstr (const char *haystack, const char *needle) | ||
326 | __attribute__ ((__pure__)); | ||
327 | # endif | ||
328 | #elif defined GNULIB_POSIXCHECK | ||
329 | /* strstr() does not work with multibyte strings if the locale encoding is | ||
330 | different from UTF-8: | ||
331 | POSIX says that it operates on "strings", and "string" in POSIX is defined | ||
332 | as a sequence of bytes, not of characters. */ | ||
333 | # undef strstr | ||
334 | # define strstr(a,b) \ | ||
335 | (GL_LINK_WARNING ("strstr is quadratic on many systems, and cannot " \ | ||
336 | "work correctly on character strings in most " \ | ||
337 | "multibyte locales - " \ | ||
338 | "use mbsstr if you care about internationalization, " \ | ||
339 | "or use strstr if you care about speed"), \ | ||
340 | strstr (a, b)) | ||
341 | #endif | ||
342 | |||
343 | /* Find the first occurrence of NEEDLE in HAYSTACK, using case-insensitive | ||
344 | comparison. */ | ||
345 | #if 0 | ||
346 | # if 0 | ||
347 | # define strcasestr rpl_strcasestr | ||
348 | # endif | ||
349 | # if ! 1 || 0 | ||
350 | extern char *strcasestr (const char *haystack, const char *needle) | ||
351 | __attribute__ ((__pure__)); | ||
352 | # endif | ||
353 | #elif defined GNULIB_POSIXCHECK | ||
354 | /* strcasestr() does not work with multibyte strings: | ||
355 | It is a glibc extension, and glibc implements it only for unibyte | ||
356 | locales. */ | ||
357 | # undef strcasestr | ||
358 | # define strcasestr(a,b) \ | ||
359 | (GL_LINK_WARNING ("strcasestr does work correctly on character strings " \ | ||
360 | "in multibyte locales - " \ | ||
361 | "use mbscasestr if you care about " \ | ||
362 | "internationalization, or use c-strcasestr if you want " \ | ||
363 | "a locale independent function"), \ | ||
364 | strcasestr (a, b)) | ||
365 | #endif | ||
366 | |||
367 | /* Parse S into tokens separated by characters in DELIM. | ||
368 | If S is NULL, the saved pointer in SAVE_PTR is used as | ||
369 | the next starting point. For example: | ||
370 | char s[] = "-abc-=-def"; | ||
371 | char *sp; | ||
372 | x = strtok_r(s, "-", &sp); // x = "abc", sp = "=-def" | ||
373 | x = strtok_r(NULL, "-=", &sp); // x = "def", sp = NULL | ||
374 | x = strtok_r(NULL, "=", &sp); // x = NULL | ||
375 | // s = "abc\0-def\0" | ||
376 | |||
377 | This is a variant of strtok() that is multithread-safe. | ||
378 | |||
379 | For the POSIX documentation for this function, see: | ||
380 | http://www.opengroup.org/susv3xsh/strtok.html | ||
381 | |||
382 | Caveat: It modifies the original string. | ||
383 | Caveat: These functions cannot be used on constant strings. | ||
384 | Caveat: The identity of the delimiting character is lost. | ||
385 | Caveat: It doesn't work with multibyte strings unless all of the delimiter | ||
386 | characters are ASCII characters < 0x30. | ||
387 | |||
388 | See also strsep(). */ | ||
389 | #if 0 | ||
390 | # if ! 1 | ||
391 | extern char *strtok_r (char *restrict s, char const *restrict delim, | ||
392 | char **restrict save_ptr); | ||
393 | # endif | ||
394 | # if defined GNULIB_POSIXCHECK | ||
395 | # undef strtok_r | ||
396 | # define strtok_r(s,d,p) \ | ||
397 | (GL_LINK_WARNING ("strtok_r cannot work correctly on character strings " \ | ||
398 | "in multibyte locales - " \ | ||
399 | "use mbstok_r if you care about internationalization"), \ | ||
400 | strtok_r (s, d, p)) | ||
401 | # endif | ||
402 | #elif defined GNULIB_POSIXCHECK | ||
403 | # undef strtok_r | ||
404 | # define strtok_r(s,d,p) \ | ||
405 | (GL_LINK_WARNING ("strtok_r is unportable - " \ | ||
406 | "use gnulib module strtok_r for portability"), \ | ||
407 | strtok_r (s, d, p)) | ||
408 | #endif | ||
409 | |||
410 | |||
411 | /* The following functions are not specified by POSIX. They are gnulib | ||
412 | extensions. */ | ||
413 | |||
414 | #if 0 | ||
415 | /* Return the number of multibyte characters in the character string STRING. | ||
416 | This considers multibyte characters, unlike strlen, which counts bytes. */ | ||
417 | extern size_t mbslen (const char *string); | ||
418 | #endif | ||
419 | |||
420 | #if 0 | ||
421 | /* Return the number of multibyte characters in the character string starting | ||
422 | at STRING and ending at STRING + LEN. */ | ||
423 | extern size_t mbsnlen (const char *string, size_t len); | ||
424 | #endif | ||
425 | |||
426 | #if 0 | ||
427 | /* Locate the first single-byte character C in the character string STRING, | ||
428 | and return a pointer to it. Return NULL if C is not found in STRING. | ||
429 | Unlike strchr(), this function works correctly in multibyte locales with | ||
430 | encodings such as GB18030. */ | ||
431 | # define mbschr rpl_mbschr /* avoid collision with HP-UX function */ | ||
432 | extern char * mbschr (const char *string, int c); | ||
433 | #endif | ||
434 | |||
435 | #if 0 | ||
436 | /* Locate the last single-byte character C in the character string STRING, | ||
437 | and return a pointer to it. Return NULL if C is not found in STRING. | ||
438 | Unlike strrchr(), this function works correctly in multibyte locales with | ||
439 | encodings such as GB18030. */ | ||
440 | # define mbsrchr rpl_mbsrchr /* avoid collision with HP-UX function */ | ||
441 | extern char * mbsrchr (const char *string, int c); | ||
442 | #endif | ||
443 | |||
444 | #if 0 | ||
445 | /* Find the first occurrence of the character string NEEDLE in the character | ||
446 | string HAYSTACK. Return NULL if NEEDLE is not found in HAYSTACK. | ||
447 | Unlike strstr(), this function works correctly in multibyte locales with | ||
448 | encodings different from UTF-8. */ | ||
449 | extern char * mbsstr (const char *haystack, const char *needle); | ||
450 | #endif | ||
451 | |||
452 | #if 0 | ||
453 | /* Compare the character strings S1 and S2, ignoring case, returning less than, | ||
454 | equal to or greater than zero if S1 is lexicographically less than, equal to | ||
455 | or greater than S2. | ||
456 | Note: This function may, in multibyte locales, return 0 for strings of | ||
457 | different lengths! | ||
458 | Unlike strcasecmp(), this function works correctly in multibyte locales. */ | ||
459 | extern int mbscasecmp (const char *s1, const char *s2); | ||
460 | #endif | ||
461 | |||
462 | #if 0 | ||
463 | /* Compare the initial segment of the character string S1 consisting of at most | ||
464 | N characters with the initial segment of the character string S2 consisting | ||
465 | of at most N characters, ignoring case, returning less than, equal to or | ||
466 | greater than zero if the initial segment of S1 is lexicographically less | ||
467 | than, equal to or greater than the initial segment of S2. | ||
468 | Note: This function may, in multibyte locales, return 0 for initial segments | ||
469 | of different lengths! | ||
470 | Unlike strncasecmp(), this function works correctly in multibyte locales. | ||
471 | But beware that N is not a byte count but a character count! */ | ||
472 | extern int mbsncasecmp (const char *s1, const char *s2, size_t n); | ||
473 | #endif | ||
474 | |||
475 | #if 0 | ||
476 | /* Compare the initial segment of the character string STRING consisting of | ||
477 | at most mbslen (PREFIX) characters with the character string PREFIX, | ||
478 | ignoring case, returning less than, equal to or greater than zero if this | ||
479 | initial segment is lexicographically less than, equal to or greater than | ||
480 | PREFIX. | ||
481 | Note: This function may, in multibyte locales, return 0 if STRING is of | ||
482 | smaller length than PREFIX! | ||
483 | Unlike strncasecmp(), this function works correctly in multibyte | ||
484 | locales. */ | ||
485 | extern char * mbspcasecmp (const char *string, const char *prefix); | ||
486 | #endif | ||
487 | |||
488 | #if 0 | ||
489 | /* Find the first occurrence of the character string NEEDLE in the character | ||
490 | string HAYSTACK, using case-insensitive comparison. | ||
491 | Note: This function may, in multibyte locales, return success even if | ||
492 | strlen (haystack) < strlen (needle) ! | ||
493 | Unlike strcasestr(), this function works correctly in multibyte locales. */ | ||
494 | extern char * mbscasestr (const char *haystack, const char *needle); | ||
495 | #endif | ||
496 | |||
497 | #if 0 | ||
498 | /* Find the first occurrence in the character string STRING of any character | ||
499 | in the character string ACCEPT. Return the number of bytes from the | ||
500 | beginning of the string to this occurrence, or to the end of the string | ||
501 | if none exists. | ||
502 | Unlike strcspn(), this function works correctly in multibyte locales. */ | ||
503 | extern size_t mbscspn (const char *string, const char *accept); | ||
504 | #endif | ||
505 | |||
506 | #if 0 | ||
507 | /* Find the first occurrence in the character string STRING of any character | ||
508 | in the character string ACCEPT. Return the pointer to it, or NULL if none | ||
509 | exists. | ||
510 | Unlike strpbrk(), this function works correctly in multibyte locales. */ | ||
511 | # define mbspbrk rpl_mbspbrk /* avoid collision with HP-UX function */ | ||
512 | extern char * mbspbrk (const char *string, const char *accept); | ||
513 | #endif | ||
514 | |||
515 | #if 0 | ||
516 | /* Find the first occurrence in the character string STRING of any character | ||
517 | not in the character string REJECT. Return the number of bytes from the | ||
518 | beginning of the string to this occurrence, or to the end of the string | ||
519 | if none exists. | ||
520 | Unlike strspn(), this function works correctly in multibyte locales. */ | ||
521 | extern size_t mbsspn (const char *string, const char *reject); | ||
522 | #endif | ||
523 | |||
524 | #if 0 | ||
525 | /* Search the next delimiter (multibyte character listed in the character | ||
526 | string DELIM) starting at the character string *STRINGP. | ||
527 | If one is found, overwrite it with a NUL, and advance *STRINGP to point | ||
528 | to the next multibyte character after it. Otherwise, set *STRINGP to NULL. | ||
529 | If *STRINGP was already NULL, nothing happens. | ||
530 | Return the old value of *STRINGP. | ||
531 | |||
532 | This is a variant of mbstok_r() that supports empty fields. | ||
533 | |||
534 | Caveat: It modifies the original string. | ||
535 | Caveat: These functions cannot be used on constant strings. | ||
536 | Caveat: The identity of the delimiting character is lost. | ||
537 | |||
538 | See also mbstok_r(). */ | ||
539 | extern char * mbssep (char **stringp, const char *delim); | ||
540 | #endif | ||
541 | |||
542 | #if 0 | ||
543 | /* Parse the character string STRING into tokens separated by characters in | ||
544 | the character string DELIM. | ||
545 | If STRING is NULL, the saved pointer in SAVE_PTR is used as | ||
546 | the next starting point. For example: | ||
547 | char s[] = "-abc-=-def"; | ||
548 | char *sp; | ||
549 | x = mbstok_r(s, "-", &sp); // x = "abc", sp = "=-def" | ||
550 | x = mbstok_r(NULL, "-=", &sp); // x = "def", sp = NULL | ||
551 | x = mbstok_r(NULL, "=", &sp); // x = NULL | ||
552 | // s = "abc\0-def\0" | ||
553 | |||
554 | Caveat: It modifies the original string. | ||
555 | Caveat: These functions cannot be used on constant strings. | ||
556 | Caveat: The identity of the delimiting character is lost. | ||
557 | |||
558 | See also mbssep(). */ | ||
559 | extern char * mbstok_r (char *string, const char *delim, char **save_ptr); | ||
560 | #endif | ||
561 | |||
562 | /* Map any int, typically from errno, into an error message. */ | ||
563 | #if 1 | ||
564 | # if 0 | ||
565 | # undef strerror | ||
566 | # define strerror rpl_strerror | ||
567 | extern char *strerror (int); | ||
568 | # endif | ||
569 | #elif defined GNULIB_POSIXCHECK | ||
570 | # undef strerror | ||
571 | # define strerror(e) \ | ||
572 | (GL_LINK_WARNING ("strerror is unportable - " \ | ||
573 | "use gnulib module strerror to guarantee non-NULL result"), \ | ||
574 | strerror (e)) | ||
575 | #endif | ||
576 | |||
577 | #if 0 | ||
578 | # if 0 | ||
579 | # define strsignal rpl_strsignal | ||
580 | # endif | ||
581 | # if ! 1 || 0 | ||
582 | extern char *strsignal (int __sig); | ||
583 | # endif | ||
584 | #elif defined GNULIB_POSIXCHECK | ||
585 | # undef strsignal | ||
586 | # define strsignal(a) \ | ||
587 | (GL_LINK_WARNING ("strsignal is unportable - " \ | ||
588 | "use gnulib module strsignal for portability"), \ | ||
589 | strsignal (a)) | ||
590 | #endif | ||
591 | |||
592 | |||
593 | #ifdef __cplusplus | ||
594 | } | ||
595 | #endif | ||
596 | |||
597 | #endif /* _GL_STRING_H */ | ||
598 | #endif /* _GL_STRING_H */ | ||
diff --git a/gl/unistd.h b/gl/unistd.h new file mode 100644 index 0000000..e72a5d9 --- /dev/null +++ b/gl/unistd.h | |||
@@ -0,0 +1,321 @@ | |||
1 | /* DO NOT EDIT! GENERATED AUTOMATICALLY! */ | ||
2 | /* Substitute for and wrapper around <unistd.h>. | ||
3 | Copyright (C) 2004-2007 Free Software Foundation, Inc. | ||
4 | |||
5 | This program is free software; you can redistribute it and/or modify | ||
6 | it under the terms of the GNU General Public License as published by | ||
7 | the Free Software Foundation; either version 3, or (at your option) | ||
8 | any later version. | ||
9 | |||
10 | This program is distributed in the hope that it will be useful, | ||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | GNU General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU General Public License | ||
16 | along with this program; if not, write to the Free Software Foundation, | ||
17 | Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ | ||
18 | |||
19 | #ifndef _GL_UNISTD_H | ||
20 | |||
21 | /* The include_next requires a split double-inclusion guard. */ | ||
22 | #if 1 | ||
23 | # include_next <unistd.h> | ||
24 | #endif | ||
25 | |||
26 | #ifndef _GL_UNISTD_H | ||
27 | #define _GL_UNISTD_H | ||
28 | |||
29 | /* mingw doesn't define the SEEK_* macros in <unistd.h>. */ | ||
30 | #if !(defined SEEK_CUR && defined SEEK_END && defined SEEK_SET) | ||
31 | # include <stdio.h> | ||
32 | #endif | ||
33 | |||
34 | /* mingw fails to declare _exit in <unistd.h>. */ | ||
35 | #include <stdlib.h> | ||
36 | |||
37 | /* The definition of GL_LINK_WARNING is copied here. */ | ||
38 | |||
39 | |||
40 | /* Declare overridden functions. */ | ||
41 | |||
42 | #ifdef __cplusplus | ||
43 | extern "C" { | ||
44 | #endif | ||
45 | |||
46 | |||
47 | #if 0 | ||
48 | # if 0 | ||
49 | # ifndef REPLACE_CHOWN | ||
50 | # define REPLACE_CHOWN 1 | ||
51 | # endif | ||
52 | # if REPLACE_CHOWN | ||
53 | /* Change the owner of FILE to UID (if UID is not -1) and the group of FILE | ||
54 | to GID (if GID is not -1). Follow symbolic links. | ||
55 | Return 0 if successful, otherwise -1 and errno set. | ||
56 | See the POSIX:2001 specification | ||
57 | <http://www.opengroup.org/susv3xsh/chown.html>. */ | ||
58 | # define chown rpl_chown | ||
59 | extern int chown (const char *file, uid_t uid, gid_t gid); | ||
60 | # endif | ||
61 | # endif | ||
62 | #elif defined GNULIB_POSIXCHECK | ||
63 | # undef chown | ||
64 | # define chown(f,u,g) \ | ||
65 | (GL_LINK_WARNING ("chown fails to follow symlinks on some systems and " \ | ||
66 | "doesn't treat a uid or gid of -1 on some systems - " \ | ||
67 | "use gnulib module chown for portability"), \ | ||
68 | chown (f, u, g)) | ||
69 | #endif | ||
70 | |||
71 | |||
72 | #if 0 | ||
73 | # if !1 | ||
74 | /* Copy the file descriptor OLDFD into file descriptor NEWFD. Do nothing if | ||
75 | NEWFD = OLDFD, otherwise close NEWFD first if it is open. | ||
76 | Return 0 if successful, otherwise -1 and errno set. | ||
77 | See the POSIX:2001 specification | ||
78 | <http://www.opengroup.org/susv3xsh/dup2.html>. */ | ||
79 | extern int dup2 (int oldfd, int newfd); | ||
80 | # endif | ||
81 | #elif defined GNULIB_POSIXCHECK | ||
82 | # undef dup2 | ||
83 | # define dup2(o,n) \ | ||
84 | (GL_LINK_WARNING ("dup2 is unportable - " \ | ||
85 | "use gnulib module dup2 for portability"), \ | ||
86 | dup2 (o, n)) | ||
87 | #endif | ||
88 | |||
89 | |||
90 | #if 0 | ||
91 | # if 0 | ||
92 | |||
93 | /* Change the process' current working directory to the directory on which | ||
94 | the given file descriptor is open. | ||
95 | Return 0 if successful, otherwise -1 and errno set. | ||
96 | See the POSIX:2001 specification | ||
97 | <http://www.opengroup.org/susv3xsh/fchdir.html>. */ | ||
98 | extern int fchdir (int /*fd*/); | ||
99 | |||
100 | # define close rpl_close | ||
101 | extern int close (int); | ||
102 | # define dup rpl_dup | ||
103 | extern int dup (int); | ||
104 | # define dup2 rpl_dup2 | ||
105 | extern int dup2 (int, int); | ||
106 | |||
107 | # endif | ||
108 | #elif defined GNULIB_POSIXCHECK | ||
109 | # undef fchdir | ||
110 | # define fchdir(f) \ | ||
111 | (GL_LINK_WARNING ("fchdir is unportable - " \ | ||
112 | "use gnulib module fchdir for portability"), \ | ||
113 | fchdir (f)) | ||
114 | #endif | ||
115 | |||
116 | |||
117 | #if 0 | ||
118 | # if !1 | ||
119 | /* Change the size of the file to which FD is opened to become equal to LENGTH. | ||
120 | Return 0 if successful, otherwise -1 and errno set. | ||
121 | See the POSIX:2001 specification | ||
122 | <http://www.opengroup.org/susv3xsh/ftruncate.html>. */ | ||
123 | extern int ftruncate (int fd, off_t length); | ||
124 | # endif | ||
125 | #elif defined GNULIB_POSIXCHECK | ||
126 | # undef ftruncate | ||
127 | # define ftruncate(f,l) \ | ||
128 | (GL_LINK_WARNING ("ftruncate is unportable - " \ | ||
129 | "use gnulib module ftruncate for portability"), \ | ||
130 | ftruncate (f, l)) | ||
131 | #endif | ||
132 | |||
133 | |||
134 | #if 0 | ||
135 | /* Include the headers that might declare getcwd so that they will not | ||
136 | cause confusion if included after this file. */ | ||
137 | # include <stdlib.h> | ||
138 | # if 0 | ||
139 | /* Get the name of the current working directory, and put it in SIZE bytes | ||
140 | of BUF. | ||
141 | Return BUF if successful, or NULL if the directory couldn't be determined | ||
142 | or SIZE was too small. | ||
143 | See the POSIX:2001 specification | ||
144 | <http://www.opengroup.org/susv3xsh/getcwd.html>. | ||
145 | Additionally, the gnulib module 'getcwd' guarantees the following GNU | ||
146 | extension: If BUF is NULL, an array is allocated with 'malloc'; the array | ||
147 | is SIZE bytes long, unless SIZE == 0, in which case it is as big as | ||
148 | necessary. */ | ||
149 | # define getcwd rpl_getcwd | ||
150 | extern char * getcwd (char *buf, size_t size); | ||
151 | # endif | ||
152 | #elif defined GNULIB_POSIXCHECK | ||
153 | # undef getcwd | ||
154 | # define getcwd(b,s) \ | ||
155 | (GL_LINK_WARNING ("getcwd is unportable - " \ | ||
156 | "use gnulib module getcwd for portability"), \ | ||
157 | getcwd (b, s)) | ||
158 | #endif | ||
159 | |||
160 | |||
161 | #if 0 | ||
162 | /* Copies the user's login name to NAME. | ||
163 | The array pointed to by NAME has room for SIZE bytes. | ||
164 | |||
165 | Returns 0 if successful. Upon error, an error number is returned, or -1 in | ||
166 | the case that the login name cannot be found but no specific error is | ||
167 | provided (this case is hopefully rare but is left open by the POSIX spec). | ||
168 | |||
169 | See <http://www.opengroup.org/susv3xsh/getlogin.html>. | ||
170 | */ | ||
171 | # if !1 | ||
172 | # include <stddef.h> | ||
173 | extern int getlogin_r (char *name, size_t size); | ||
174 | # endif | ||
175 | #elif defined GNULIB_POSIXCHECK | ||
176 | # undef getlogin_r | ||
177 | # define getlogin_r(n,s) \ | ||
178 | (GL_LINK_WARNING ("getlogin_r is unportable - " \ | ||
179 | "use gnulib module getlogin_r for portability"), \ | ||
180 | getlogin_r (n, s)) | ||
181 | #endif | ||
182 | |||
183 | |||
184 | #if 0 | ||
185 | # if 0 | ||
186 | # define getpagesize rpl_getpagesize | ||
187 | extern int getpagesize (void); | ||
188 | # elif !1 | ||
189 | /* This is for POSIX systems. */ | ||
190 | # if !defined getpagesize && defined _SC_PAGESIZE | ||
191 | # if ! (defined __VMS && __VMS_VER < 70000000) | ||
192 | # define getpagesize() sysconf (_SC_PAGESIZE) | ||
193 | # endif | ||
194 | # endif | ||
195 | /* This is for older VMS. */ | ||
196 | # if !defined getpagesize && defined __VMS | ||
197 | # ifdef __ALPHA | ||
198 | # define getpagesize() 8192 | ||
199 | # else | ||
200 | # define getpagesize() 512 | ||
201 | # endif | ||
202 | # endif | ||
203 | /* This is for BeOS. */ | ||
204 | # if !defined getpagesize && 0 | ||
205 | # include <OS.h> | ||
206 | # if defined B_PAGE_SIZE | ||
207 | # define getpagesize() B_PAGE_SIZE | ||
208 | # endif | ||
209 | # endif | ||
210 | /* This is for AmigaOS4.0. */ | ||
211 | # if !defined getpagesize && defined __amigaos4__ | ||
212 | # define getpagesize() 2048 | ||
213 | # endif | ||
214 | /* This is for older Unix systems. */ | ||
215 | # if !defined getpagesize && 0 | ||
216 | # include <sys/param.h> | ||
217 | # ifdef EXEC_PAGESIZE | ||
218 | # define getpagesize() EXEC_PAGESIZE | ||
219 | # else | ||
220 | # ifdef NBPG | ||
221 | # ifndef CLSIZE | ||
222 | # define CLSIZE 1 | ||
223 | # endif | ||
224 | # define getpagesize() (NBPG * CLSIZE) | ||
225 | # else | ||
226 | # ifdef NBPC | ||
227 | # define getpagesize() NBPC | ||
228 | # endif | ||
229 | # endif | ||
230 | # endif | ||
231 | # endif | ||
232 | # endif | ||
233 | #elif defined GNULIB_POSIXCHECK | ||
234 | # undef getpagesize | ||
235 | # define getpagesize() \ | ||
236 | (GL_LINK_WARNING ("getpagesize is unportable - " \ | ||
237 | "use gnulib module getpagesize for portability"), \ | ||
238 | getpagesize ()) | ||
239 | #endif | ||
240 | |||
241 | |||
242 | #if 0 | ||
243 | # if 0 | ||
244 | /* Change the owner of FILE to UID (if UID is not -1) and the group of FILE | ||
245 | to GID (if GID is not -1). Do not follow symbolic links. | ||
246 | Return 0 if successful, otherwise -1 and errno set. | ||
247 | See the POSIX:2001 specification | ||
248 | <http://www.opengroup.org/susv3xsh/lchown.html>. */ | ||
249 | # define lchown rpl_lchown | ||
250 | extern int lchown (char const *file, uid_t owner, gid_t group); | ||
251 | # endif | ||
252 | #elif defined GNULIB_POSIXCHECK | ||
253 | # undef lchown | ||
254 | # define lchown(f,u,g) \ | ||
255 | (GL_LINK_WARNING ("lchown is unportable to pre-POSIX.1-2001 " \ | ||
256 | "systems - use gnulib module lchown for portability"), \ | ||
257 | lchown (f, u, g)) | ||
258 | #endif | ||
259 | |||
260 | |||
261 | #if 0 | ||
262 | # if 0 | ||
263 | /* Set the offset of FD relative to SEEK_SET, SEEK_CUR, or SEEK_END. | ||
264 | Return the new offset if successful, otherwise -1 and errno set. | ||
265 | See the POSIX:2001 specification | ||
266 | <http://www.opengroup.org/susv3xsh/lseek.html>. */ | ||
267 | # define lseek rpl_lseek | ||
268 | extern off_t lseek (int fd, off_t offset, int whence); | ||
269 | # endif | ||
270 | #elif defined GNULIB_POSIXCHECK | ||
271 | # undef lseek | ||
272 | # define lseek(f,o,w) \ | ||
273 | (GL_LINK_WARNING ("lseek does not fail with ESPIPE on pipes on some " \ | ||
274 | "systems - use gnulib module lseek for portability"), \ | ||
275 | lseek (f, o, w)) | ||
276 | #endif | ||
277 | |||
278 | |||
279 | #if 0 | ||
280 | /* Read the contents of the symbolic link FILE and place the first BUFSIZE | ||
281 | bytes of it into BUF. Return the number of bytes placed into BUF if | ||
282 | successful, otherwise -1 and errno set. | ||
283 | See the POSIX:2001 specification | ||
284 | <http://www.opengroup.org/susv3xsh/readlink.html>. */ | ||
285 | # if !1 | ||
286 | # include <stddef.h> | ||
287 | extern int readlink (const char *file, char *buf, size_t bufsize); | ||
288 | # endif | ||
289 | #elif defined GNULIB_POSIXCHECK | ||
290 | # undef readlink | ||
291 | # define readlink(f,b,s) \ | ||
292 | (GL_LINK_WARNING ("readlink is unportable - " \ | ||
293 | "use gnulib module readlink for portability"), \ | ||
294 | readlink (f, b, s)) | ||
295 | #endif | ||
296 | |||
297 | |||
298 | #if 0 | ||
299 | /* Pause the execution of the current thread for N seconds. | ||
300 | Returns the number of seconds left to sleep. | ||
301 | See the POSIX:2001 specification | ||
302 | <http://www.opengroup.org/susv3xsh/sleep.html>. */ | ||
303 | # if !1 | ||
304 | extern unsigned int sleep (unsigned int n); | ||
305 | # endif | ||
306 | #elif defined GNULIB_POSIXCHECK | ||
307 | # undef sleep | ||
308 | # define sleep(n) \ | ||
309 | (GL_LINK_WARNING ("sleep is unportable - " \ | ||
310 | "use gnulib module sleep for portability"), \ | ||
311 | sleep (n)) | ||
312 | #endif | ||
313 | |||
314 | |||
315 | #ifdef __cplusplus | ||
316 | } | ||
317 | #endif | ||
318 | |||
319 | |||
320 | #endif /* _GL_UNISTD_H */ | ||
321 | #endif /* _GL_UNISTD_H */ | ||