aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorPaul Eggert2011-01-08 17:20:28 -0800
committerPaul Eggert2011-01-08 17:20:28 -0800
commita451f14b09368f4b9f96d61ddb2ee69ac048c414 (patch)
treed4076c67607428c2bd10d0d69bf763504c42ef06 /lib
parentfa2c4f5619481856c8cdf33be987d5785f51b750 (diff)
downloademacs-a451f14b09368f4b9f96d61ddb2ee69ac048c414.tar.gz
emacs-a451f14b09368f4b9f96d61ddb2ee69ac048c414.zip
Regenerate.
Diffstat (limited to 'lib')
-rw-r--r--lib/Makefile.in19
-rw-r--r--lib/dtoastr.c2
-rw-r--r--lib/dummy.c42
-rw-r--r--lib/ftoastr.c136
-rw-r--r--lib/ftoastr.h144
-rw-r--r--lib/gnulib.mk15
-rw-r--r--lib/intprops.h86
-rw-r--r--lib/ldtoastr.c2
8 files changed, 393 insertions, 53 deletions
diff --git a/lib/Makefile.in b/lib/Makefile.in
index 0fff5b2c813..d1d6e4f8417 100644
--- a/lib/Makefile.in
+++ b/lib/Makefile.in
@@ -24,7 +24,7 @@
24# the same distribution terms as the rest of that program. 24# the same distribution terms as the rest of that program.
25# 25#
26# Generated by gnulib-tool. 26# Generated by gnulib-tool.
27# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=. --makefile-name=gnulib.mk --no-libtool --macro-prefix=gl --no-vc-files dummy 27# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=. --makefile-name=gnulib.mk --no-libtool --macro-prefix=gl --no-vc-files ftoastr
28 28
29VPATH = @srcdir@ 29VPATH = @srcdir@
30pkgdatadir = $(datadir)/@PACKAGE@ 30pkgdatadir = $(datadir)/@PACKAGE@
@@ -49,8 +49,10 @@ DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \
49 $(srcdir)/gnulib.mk 49 $(srcdir)/gnulib.mk
50subdir = lib 50subdir = lib
51ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 51ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
52am__aclocal_m4_deps = $(top_srcdir)/m4/gnulib-comp.m4 \ 52am__aclocal_m4_deps = $(top_srcdir)/m4/00gnulib.m4 \
53 $(top_srcdir)/m4/getopt.m4 $(top_srcdir)/configure.in 53 $(top_srcdir)/m4/c-strtod.m4 $(top_srcdir)/m4/gnulib-common.m4 \
54 $(top_srcdir)/m4/gnulib-comp.m4 $(top_srcdir)/m4/getopt.m4 \
55 $(top_srcdir)/configure.in
54am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ 56am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
55 $(ACLOCAL_M4) 57 $(ACLOCAL_M4)
56mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs 58mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
@@ -62,7 +64,8 @@ AR = ar
62ARFLAGS = cru 64ARFLAGS = cru
63libgnu_a_AR = $(AR) $(ARFLAGS) 65libgnu_a_AR = $(AR) $(ARFLAGS)
64am__DEPENDENCIES_1 = 66am__DEPENDENCIES_1 =
65am_libgnu_a_OBJECTS = dummy.$(OBJEXT) 67am_libgnu_a_OBJECTS = ftoastr.$(OBJEXT) dtoastr.$(OBJEXT) \
68 ldtoastr.$(OBJEXT)
66libgnu_a_OBJECTS = $(am_libgnu_a_OBJECTS) 69libgnu_a_OBJECTS = $(am_libgnu_a_OBJECTS)
67depcomp = $(SHELL) $(top_srcdir)/depcomp 70depcomp = $(SHELL) $(top_srcdir)/depcomp
68am__depfiles_maybe = depfiles 71am__depfiles_maybe = depfiles
@@ -311,11 +314,11 @@ top_srcdir = @top_srcdir@
311version = @version@ 314version = @version@
312x_default_search_path = @x_default_search_path@ 315x_default_search_path = @x_default_search_path@
313BUILT_SOURCES = 316BUILT_SOURCES =
314EXTRA_DIST = 317EXTRA_DIST = intprops.h
315MOSTLYCLEANFILES = core *.stackdump 318MOSTLYCLEANFILES = core *.stackdump
316noinst_LIBRARIES = libgnu.a 319noinst_LIBRARIES = libgnu.a
317DEFAULT_INCLUDES = -I. -I../src -I$(top_srcdir)/src 320DEFAULT_INCLUDES = -I. -I../src -I$(top_srcdir)/src
318libgnu_a_SOURCES = dummy.c 321libgnu_a_SOURCES = ftoastr.h ftoastr.c dtoastr.c ldtoastr.c
319libgnu_a_LIBADD = $(gl_LIBOBJS) 322libgnu_a_LIBADD = $(gl_LIBOBJS)
320libgnu_a_DEPENDENCIES = $(gl_LIBOBJS) 323libgnu_a_DEPENDENCIES = $(gl_LIBOBJS)
321EXTRA_libgnu_a_SOURCES = 324EXTRA_libgnu_a_SOURCES =
@@ -368,7 +371,9 @@ mostlyclean-compile:
368distclean-compile: 371distclean-compile:
369 -rm -f *.tab.c 372 -rm -f *.tab.c
370 373
371@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dummy.Po@am__quote@ 374@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dtoastr.Po@am__quote@
375@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ftoastr.Po@am__quote@
376@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ldtoastr.Po@am__quote@
372 377
373.c.o: 378.c.o:
374@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< 379@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
diff --git a/lib/dtoastr.c b/lib/dtoastr.c
new file mode 100644
index 00000000000..aed181d66b1
--- /dev/null
+++ b/lib/dtoastr.c
@@ -0,0 +1,2 @@
1#define LENGTH 2
2#include "ftoastr.c"
diff --git a/lib/dummy.c b/lib/dummy.c
deleted file mode 100644
index c958ea05d86..00000000000
--- a/lib/dummy.c
+++ /dev/null
@@ -1,42 +0,0 @@
1/* A dummy file, to prevent empty libraries from breaking builds.
2 Copyright (C) 2004, 2007, 2009-2011 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/* Some systems, reportedly OpenBSD and Mac OS X, refuse to create
18 libraries without any object files. You might get an error like:
19
20 > ar cru .libs/libgl.a
21 > ar: no archive members specified
22
23 Compiling this file, and adding its object file to the library, will
24 prevent the library from being empty. */
25
26/* Some systems, such as Solaris with cc 5.0, refuse to work with libraries
27 that don't export any symbol. You might get an error like:
28
29 > cc ... libgnu.a
30 > ild: (bad file) garbled symbol table in archive ../gllib/libgnu.a
31
32 Compiling this file, and adding its object file to the library, will
33 prevent the library from exporting no symbols. */
34
35#ifdef __sun
36/* This declaration ensures that the library will export at least 1 symbol. */
37int gl_dummy_symbol;
38#else
39/* This declaration is solely to ensure that after preprocessing
40 this file is never empty. */
41typedef int dummy;
42#endif
diff --git a/lib/ftoastr.c b/lib/ftoastr.c
new file mode 100644
index 00000000000..ff3d87ce22d
--- /dev/null
+++ b/lib/ftoastr.c
@@ -0,0 +1,136 @@
1/* floating point to accurate string
2
3 Copyright (C) 2010-2011 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/* Written by Paul Eggert. */
19
20/* This code can misbehave on some buggy or older platforms, when
21 operating on arguments on floating types other than 'double', or
22 when given unusual combinations of options. Gnulib's
23 snprintf-posix module works around many of these problems.
24
25 This code relies on sprintf, strtod, etc. operating accurately;
26 otherwise, the resulting strings could be inaccurate or too long. */
27
28#include <config.h>
29
30#include "ftoastr.h"
31
32#include "intprops.h"
33#include <float.h>
34#include <stdio.h>
35#include <stdlib.h>
36
37#if LENGTH == 3
38# define FLOAT long double
39# define FLOAT_DIG LDBL_DIG
40# define FLOAT_MIN LDBL_MIN
41# define FLOAT_PREC_BOUND _GL_LDBL_PREC_BOUND
42# define FTOASTR ldtoastr
43# define STRTOF strtold
44#elif LENGTH == 2
45# define FLOAT double
46# define FLOAT_DIG DBL_DIG
47# define FLOAT_MIN DBL_MIN
48# define FLOAT_PREC_BOUND _GL_DBL_PREC_BOUND
49# define FTOASTR dtoastr
50# define STRTOF strtod
51#else
52# define LENGTH 1
53# define FLOAT float
54# define FLOAT_DIG FLT_DIG
55# define FLOAT_MIN FLT_MIN
56# define FLOAT_PREC_BOUND _GL_FLT_PREC_BOUND
57# define FTOASTR ftoastr
58# define STRTOF strtof
59#endif
60
61/* On pre-C99 hosts, approximate strtof and strtold with strtod. This
62 may generate one or two extra digits, but that's better than not
63 working at all. Assume that strtof works if strtold does. */
64#if LENGTH != 2 && ! HAVE_C99_STRTOLD
65# undef STRTOF
66# define STRTOF strtod
67#endif
68
69/* On hosts where it's not known that snprintf works, use sprintf to
70 implement the subset needed here. Typically BUFSIZE is big enough
71 and there's little or no performance hit. */
72#if ! GNULIB_SNPRINTF
73# undef snprintf
74# define snprintf ftoastr_snprintf
75static int
76ftoastr_snprintf (char *buf, size_t bufsize, char const *format,
77 int width, int prec, FLOAT x)
78{
79 char width_0_buffer[LENGTH == 1 ? FLT_BUFSIZE_BOUND
80 : LENGTH == 2 ? DBL_BUFSIZE_BOUND
81 : LDBL_BUFSIZE_BOUND];
82 int n = width;
83 if (bufsize < sizeof width_0_buffer)
84 {
85 n = sprintf (width_0_buffer, format, 0, prec, x);
86 if (n < 0)
87 return n;
88 if (n < width)
89 n = width;
90 }
91 if (n < bufsize)
92 n = sprintf (buf, format, width, prec, x);
93 return n;
94}
95#endif
96
97int
98FTOASTR (char *buf, size_t bufsize, int flags, int width, FLOAT x)
99{
100 /* The following method is simple but slow.
101 For ideas about speeding things up, please see:
102
103 Florian Loitsch, Printing floating-point numbers quickly and accurately
104 with integers. ACM SIGPLAN notices 46, 6 (June 2010), 233-243
105 <http://dx.doi.org/10.1145/1809028.1806623>; also see the
106 2010-03-21 draft <http://florian.loitsch.com/tmp/article.pdf>. */
107
108 char format[sizeof "%-+ 0*.*Lg"];
109 FLOAT abs_x = x < 0 ? -x : x;
110 int prec;
111
112 char *p = format;
113 *p++ = '%';
114
115 /* Support flags that generate output parsable by strtof. */
116 *p = '-'; p += (flags & FTOASTR_LEFT_JUSTIFY ) != 0;
117 *p = '+'; p += (flags & FTOASTR_ALWAYS_SIGNED ) != 0;
118 *p = ' '; p += (flags & FTOASTR_SPACE_POSITIVE) != 0;
119 *p = '0'; p += (flags & FTOASTR_ZERO_PAD ) != 0;
120
121 *p++ = '*';
122 *p++ = '.';
123 *p++ = '*';
124 *p = 'L'; p += 2 < LENGTH;
125 *p++ = flags & FTOASTR_UPPER_E ? 'G' : 'g';
126 *p = '\0';
127
128 for (prec = abs_x < FLOAT_MIN ? 1 : FLOAT_DIG; ; prec++)
129 {
130 int n = snprintf (buf, bufsize, format, width, prec, x);
131 if (n < 0
132 || FLOAT_PREC_BOUND <= prec
133 || (n < bufsize && STRTOF (buf, NULL) == x))
134 return n;
135 }
136}
diff --git a/lib/ftoastr.h b/lib/ftoastr.h
new file mode 100644
index 00000000000..6264952e8e9
--- /dev/null
+++ b/lib/ftoastr.h
@@ -0,0 +1,144 @@
1/* floating point to accurate string
2
3 Copyright (C) 2010-2011 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/* Written by Paul Eggert. */
19
20#ifndef _GL_FTOASTR_H
21
22#include "intprops.h"
23#include <float.h>
24#include <stddef.h>
25
26/* Store into BUF (of size BUFSIZE) an accurate minimal-precision
27 string representation of a floating point number. FLAGS affect the
28 formatting of the number. Pad the output string with spaces as
29 necessary to width WIDTH bytes, in the style of printf. WIDTH must
30 be nonnegative. X is the floating-point number to be converted.
31
32 Return the number of bytes stored into BUF, not counting the
33 terminating null. However, do not overrun BUF: if BUF is too
34 small, return a fairly tight (but not necessarily exact) upper
35 bound on the value that would have been returned if BUF had been
36 big enough. If SIZE is zero, BUF may be a null pointer. On error
37 (e.g., returned value would exceed INT_MAX), return -1 and set
38 errno.
39
40 Example:
41
42 char buf[DBL_BUFSIZE_BOUND];
43 int r = dtoastr (buf, sizeof buf, 0, 0, 0.1);
44
45 In the C locale, this sets R to 3 and stores "0.1" into BUF. */
46
47int ftoastr (char *buf, size_t bufsize, int flags, int width, float x);
48int dtoastr (char *buf, size_t bufsize, int flags, int width, double x);
49int ldtoastr (char *buf, size_t bufsize, int flags, int width, long double x);
50
51/* Flag values for ftoastr etc. These can be ORed together. */
52enum
53 {
54 /* Left justify within the width; the default is right justification. */
55 FTOASTR_LEFT_JUSTIFY = 1,
56
57 /* Output "+" before positive numbers; the default outputs nothing. */
58 FTOASTR_ALWAYS_SIGNED = 2,
59
60 /* Output " " before positive numbers; ignored if
61 FTOASTER_ALWAYS_SIGNED is also given. */
62 FTOASTR_SPACE_POSITIVE = 4,
63
64 /* Pad with zeros instead of spaces; ignored if FTOASTR_LEFT_JUSTIFY
65 is also given. */
66 FTOASTR_ZERO_PAD = 8,
67
68 /* Use 'E' instead of 'e' before the exponent. */
69 FTOASTR_UPPER_E = 16
70 };
71
72
73/* _GL_FLT_PREC_BOUND is an upper bound on the precision needed to
74 represent a float value without losing information. Likewise for
75 _GL_DBL_PREC_BOUND and double, and _GL_LDBL_PREC_BOUND and long double. */
76
77#if FLT_RADIX == 10 /* decimal floating point */
78 enum { _GL_FLT_PREC_BOUND = FLT_MANT_DIG };
79 enum { _GL_DBL_PREC_BOUND = DBL_MANT_DIG };
80 enum { _GL_LDBL_PREC_BOUND = LDBL_MANT_DIG };
81#else
82
83/* An upper bound on the number of bits needed to represent a single
84 digit in a floating-point fraction. */
85# if FLT_RADIX == 2 /* IEEE 754 floating point, VAX floating point, etc. */
86# define _GL_FLOAT_DIG_BITS_BOUND 1
87# elif FLT_RADIX <= 16 /* IBM hex floating point has FLT_RADIX == 16. */
88# define _GL_FLOAT_DIG_BITS_BOUND 4
89# else /* no machine is this bad, but let's be complete */
90# define _GL_FLOAT_DIG_BITS_BOUND (CHAR_BIT * (int) sizeof (int) - 1)
91# endif
92
93/* An upper bound on the number of decimal digits needed to represent
94 a floating point number accurately, assuming a fraction contains
95 DIG digits. For why the "+ 1" is needed, see "Binary to Decimal
96 Conversion" in David Goldberg's paper "What Every Computer
97 Scientist Should Know About Floating-Point Arithmetic"
98 <http://docs.sun.com/source/806-3568/ncg_goldberg.html>. */
99# define _GL_FLOAT_PREC_BOUND(dig) \
100 (INT_BITS_STRLEN_BOUND ((dig) * _GL_FLOAT_DIG_BITS_BOUND) + 1)
101
102 enum { _GL_FLT_PREC_BOUND = _GL_FLOAT_PREC_BOUND ( FLT_MANT_DIG) };
103 enum { _GL_DBL_PREC_BOUND = _GL_FLOAT_PREC_BOUND ( DBL_MANT_DIG) };
104 enum { _GL_LDBL_PREC_BOUND = _GL_FLOAT_PREC_BOUND (LDBL_MANT_DIG) };
105#endif
106
107
108/* Bound on the number of bytes printed for an exponent in the range
109 MIN..MAX, where MIN < 0 < MAX; printf always prints a sign and at
110 least 2 digits. Although the maximum known exponent is 4932 for
111 IEEE 754 binary128, support tight bounds for exponents up to a
112 million, just in case. */
113#define _GL_FLOAT_EXPONENT_STRLEN_BOUND(min, max) \
114 ( -100 < (min) && (max) < 100 ? 3 \
115 : -1000 < (min) && (max) < 1000 ? 4 \
116 : -10000 < (min) && (max) < 10000 ? 5 \
117 : -100000 < (min) && (max) < 100000 ? 6 \
118 : -1000000 < (min) && (max) < 1000000 ? 7 \
119 : INT_STRLEN_BOUND (int) /* not a tight bound */)
120
121/* A reasonably tight bound on the length of a type-T floating value
122 formatted with ftoastr etc. Room is needed for sign, fraction
123 digits, decimal point, "e", and exponent. POINTLEN should be a
124 reasonably tight bound on the string length of the decimal
125 point. */
126#define _GL_FLOAT_STRLEN_BOUND_L(t, pointlen) \
127 (1 + _GL_##t##_PREC_BOUND + pointlen + 1 \
128 + _GL_FLOAT_EXPONENT_STRLEN_BOUND (t##_MIN_10_EXP, t##_MAX_10_EXP))
129#define FLT_STRLEN_BOUND_L(pointlen) _GL_FLOAT_STRLEN_BOUND_L ( FLT, pointlen)
130#define DBL_STRLEN_BOUND_L(pointlen) _GL_FLOAT_STRLEN_BOUND_L ( DBL, pointlen)
131#define LDBL_STRLEN_BOUND_L(pointlen) _GL_FLOAT_STRLEN_BOUND_L (LDBL, pointlen)
132
133/* Looser bounds that are locale-independent and are integral constant
134 expressions. */
135#define FLT_STRLEN_BOUND FLT_STRLEN_BOUND_L (MB_LEN_MAX)
136#define DBL_STRLEN_BOUND DBL_STRLEN_BOUND_L (MB_LEN_MAX)
137#define LDBL_STRLEN_BOUND LDBL_STRLEN_BOUND_L (MB_LEN_MAX)
138
139/* Looser, locale-independent bounds that include the trailing null byte. */
140#define FLT_BUFSIZE_BOUND ( FLT_STRLEN_BOUND + 1)
141#define DBL_BUFSIZE_BOUND ( DBL_STRLEN_BOUND + 1)
142#define LDBL_BUFSIZE_BOUND (LDBL_STRLEN_BOUND + 1)
143
144#endif /* _GL_FTOASTR_H */
diff --git a/lib/gnulib.mk b/lib/gnulib.mk
index 1f5efc12e86..78d89d99281 100644
--- a/lib/gnulib.mk
+++ b/lib/gnulib.mk
@@ -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=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=. --makefile-name=gnulib.mk --no-libtool --macro-prefix=gl --no-vc-files dummy 12# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=. --makefile-name=gnulib.mk --no-libtool --macro-prefix=gl --no-vc-files ftoastr
13 13
14 14
15MOSTLYCLEANFILES += core *.stackdump 15MOSTLYCLEANFILES += core *.stackdump
@@ -21,11 +21,18 @@ libgnu_a_LIBADD = $(gl_LIBOBJS)
21libgnu_a_DEPENDENCIES = $(gl_LIBOBJS) 21libgnu_a_DEPENDENCIES = $(gl_LIBOBJS)
22EXTRA_libgnu_a_SOURCES = 22EXTRA_libgnu_a_SOURCES =
23 23
24## begin gnulib module dummy 24## begin gnulib module ftoastr
25 25
26libgnu_a_SOURCES += dummy.c 26libgnu_a_SOURCES += ftoastr.h ftoastr.c dtoastr.c ldtoastr.c
27 27
28## end gnulib module dummy 28## end gnulib module ftoastr
29
30## begin gnulib module intprops
31
32
33EXTRA_DIST += intprops.h
34
35## end gnulib module intprops
29 36
30 37
31mostlyclean-local: mostlyclean-generic 38mostlyclean-local: mostlyclean-generic
diff --git a/lib/intprops.h b/lib/intprops.h
new file mode 100644
index 00000000000..511a5aa9890
--- /dev/null
+++ b/lib/intprops.h
@@ -0,0 +1,86 @@
1/* intprops.h -- properties of integer types
2
3 Copyright (C) 2001-2005, 2009-2011 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/* Written by Paul Eggert. */
19
20#ifndef GL_INTPROPS_H
21# define GL_INTPROPS_H
22
23# include <limits.h>
24
25/* The extra casts in the following macros work around compiler bugs,
26 e.g., in Cray C 5.0.3.0. */
27
28/* True if the arithmetic type T is an integer type. bool counts as
29 an integer. */
30# define TYPE_IS_INTEGER(t) ((t) 1.5 == 1)
31
32/* True if negative values of the signed integer type T use two's
33 complement, ones' complement, or signed magnitude representation,
34 respectively. Much GNU code assumes two's complement, but some
35 people like to be portable to all possible C hosts. */
36# define TYPE_TWOS_COMPLEMENT(t) ((t) ~ (t) 0 == (t) -1)
37# define TYPE_ONES_COMPLEMENT(t) ((t) ~ (t) 0 == 0)
38# define TYPE_SIGNED_MAGNITUDE(t) ((t) ~ (t) 0 < (t) -1)
39
40/* True if the arithmetic type T is signed. */
41# define TYPE_SIGNED(t) (! ((t) 0 < (t) -1))
42
43/* The maximum and minimum values for the integer type T. These
44 macros have undefined behavior if T is signed and has padding bits.
45 If this is a problem for you, please let us know how to fix it for
46 your host. */
47# define TYPE_MINIMUM(t) \
48 ((t) (! TYPE_SIGNED (t) \
49 ? (t) 0 \
50 : TYPE_SIGNED_MAGNITUDE (t) \
51 ? ~ (t) 0 \
52 : ~ (t) 0 << (sizeof (t) * CHAR_BIT - 1)))
53# define TYPE_MAXIMUM(t) \
54 ((t) (! TYPE_SIGNED (t) \
55 ? (t) -1 \
56 : ~ (~ (t) 0 << (sizeof (t) * CHAR_BIT - 1))))
57
58/* Return zero if T can be determined to be an unsigned type.
59 Otherwise, return 1.
60 When compiling with GCC, INT_STRLEN_BOUND uses this macro to obtain a
61 tighter bound. Otherwise, it overestimates the true bound by one byte
62 when applied to unsigned types of size 2, 4, 16, ... bytes.
63 The symbol signed_type_or_expr__ is private to this header file. */
64# if __GNUC__ >= 2
65# define signed_type_or_expr__(t) TYPE_SIGNED (__typeof__ (t))
66# else
67# define signed_type_or_expr__(t) 1
68# endif
69
70/* Bound on length of the string representing an unsigned integer
71 value representable in B bits. log10 (2.0) < 146/485. The
72 smallest value of B where this bound is not tight is 2621. */
73# define INT_BITS_STRLEN_BOUND(b) (((b) * 146 + 484) / 485)
74
75/* Bound on length of the string representing an integer type or expression T.
76 Subtract 1 for the sign bit if T is signed, and then add 1 more for
77 a minus sign if needed. */
78# define INT_STRLEN_BOUND(t) \
79 (INT_BITS_STRLEN_BOUND (sizeof (t) * CHAR_BIT - signed_type_or_expr__ (t)) \
80 + signed_type_or_expr__ (t))
81
82/* Bound on buffer size needed to represent an integer type or expression T,
83 including the terminating null. */
84# define INT_BUFSIZE_BOUND(t) (INT_STRLEN_BOUND (t) + 1)
85
86#endif /* GL_INTPROPS_H */
diff --git a/lib/ldtoastr.c b/lib/ldtoastr.c
new file mode 100644
index 00000000000..bf54a3582e3
--- /dev/null
+++ b/lib/ldtoastr.c
@@ -0,0 +1,2 @@
1#define LENGTH 3
2#include "ftoastr.c"