aboutsummaryrefslogtreecommitdiff
path: root/stdlib
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib')
-rw-r--r--stdlib/Makefile7
-rw-r--r--stdlib/bits/monetary-ldbl.h60
-rw-r--r--stdlib/bits/stdlib-ldbl.h42
-rw-r--r--stdlib/monetary.h7
-rw-r--r--stdlib/stdlib.h7
-rw-r--r--stdlib/strfmon.c8
-rw-r--r--stdlib/strfmon_l.c43
-rw-r--r--stdlib/strtod.c15
-rw-r--r--stdlib/strtod_l.c29
-rw-r--r--stdlib/strtold.c36
10 files changed, 205 insertions, 49 deletions
diff --git a/stdlib/Makefile b/stdlib/Makefile
index f44c66b..bc97d70 100644
--- a/stdlib/Makefile
+++ b/stdlib/Makefile
@@ -1,4 +1,4 @@
-# Copyright (C) 1991-2002, 2003, 2004, 2005 Free Software Foundation, Inc.
+# Copyright (C) 1991-2002,2003,2004,2005,2006 Free Software Foundation, Inc.
# This file is part of the GNU C Library.
# The GNU C Library is free software; you can redistribute it and/or
@@ -21,9 +21,10 @@
#
subdir := stdlib
-headers := stdlib.h alloca.h monetary.h fmtmsg.h ucontext.h sys/ucontext.h \
+headers := stdlib.h bits/stdlib.h bits/stdlib-ldbl.h \
+ monetary.h bits/monetary-ldbl.h \
inttypes.h stdint.h bits/wordsize.h \
- errno.h sys/errno.h bits/errno.h bits/stdlib.h
+ errno.h sys/errno.h bits/errno.h
routines := \
atof atoi atol atoll \
diff --git a/stdlib/bits/monetary-ldbl.h b/stdlib/bits/monetary-ldbl.h
new file mode 100644
index 0000000..2c0cff1
--- /dev/null
+++ b/stdlib/bits/monetary-ldbl.h
@@ -0,0 +1,60 @@
+/* -mlong-double-64 compatibility mode for monetary functions.
+ Copyright (C) 2006 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _MONETARY_H
+# error "Never include <bits/monetary-ldbl.h> directly; use <monetary.h> instead."
+#endif
+
+#if defined __LDBL_COMPAT && defined __GNUC__ && __GNUC__ >= 2
+
+# define __LDBL_REDIR_WCHAR(name) \
+ extern __typeof (name) name __asm (__ASMNAME (__nldbl_##name))
+
+# if defined __USE_ISOC99 || defined __USE_UNIX98
+__BEGIN_NAMESPACE_C99
+__LDBL_REDIR_WCHAR (fwprintf);
+__LDBL_REDIR_WCHAR (wprintf);
+__LDBL_REDIR_WCHAR (swprintf);
+__LDBL_REDIR_WCHAR (vfwprintf);
+__LDBL_REDIR_WCHAR (vwprintf);
+__LDBL_REDIR_WCHAR (vswprintf);
+__LDBL_REDIR_WCHAR (fwscanf);
+__LDBL_REDIR_WCHAR (wscanf);
+__LDBL_REDIR_WCHAR (swscanf);
+__END_NAMESPACE_C99
+# endif
+
+# ifdef __USE_ISOC99
+__BEGIN_NAMESPACE_C99
+__LDBL_REDIR_WCHAR (vfwscanf);
+__LDBL_REDIR_WCHAR (vwscanf);
+__LDBL_REDIR_WCHAR (vswscanf);
+__END_NAMESPACE_C99
+# endif
+
+#if __USE_FORTIFY_LEVEL > 0 && !defined __cplusplus
+__LDBL_REDIR_DECL (__swprintf_chk)
+__LDBL_REDIR_DECL (__vswprintf_chk)
+# if __USE_FORTIFY_LEVEL > 1
+__LDBL_REDIR_DECL (__fwprintf_chk)
+__LDBL_REDIR_DECL (__wprintf_chk)
+__LDBL_REDIR_DECL (__vfwprintf_chk)
+__LDBL_REDIR_DECL (__vwprintf_chk)
+# endif
+#endif
diff --git a/stdlib/bits/stdlib-ldbl.h b/stdlib/bits/stdlib-ldbl.h
new file mode 100644
index 0000000..7c11a49
--- /dev/null
+++ b/stdlib/bits/stdlib-ldbl.h
@@ -0,0 +1,42 @@
+/* -mlong-double-64 compatibility mode for <stdlib.h> functions.
+ Copyright (C) 2006 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _STDLIB_H
+# error "Never include <bits/stdlib-ldbl.h> directly; use <stdlib.h> instead."
+#endif
+
+#ifdef __USE_ISOC99
+__BEGIN_NAMESPACE_C99
+__LDBL_REDIR_DECL (strtold)
+__END_NAMESPACE_C99
+#endif
+
+#ifdef __USE_GNU
+__LDBL_REDIR_DECL (strtold_l)
+#endif
+
+__LDBL_REDIR_DECL (__strtold_internal)
+
+#ifdef __USE_MISC
+__LDBL_REDIR_DECL (qecvt)
+__LDBL_REDIR_DECL (qfcvt)
+__LDBL_REDIR_DECL (qgcvt)
+__LDBL_REDIR_DECL (qecvt_r)
+__LDBL_REDIR_DECL (qfcvt_r)
+#endif
diff --git a/stdlib/monetary.h b/stdlib/monetary.h
index 4c8a4cd..d9234ca 100644
--- a/stdlib/monetary.h
+++ b/stdlib/monetary.h
@@ -1,5 +1,6 @@
/* Header file for monetary value formatting functions.
- Copyright (C) 1996,97,98,99,2000,02 Free Software Foundation, Inc.
+ Copyright (C) 1996,1997,1998,1999,2000,2002,2006
+ Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -50,6 +51,10 @@ extern ssize_t strfmon_l (char *__restrict __s, size_t __maxsize,
__THROW __attribute_format_strfmon__ (4, 5);
#endif
+#ifdef __LDBL_COMPAT
+# include <bits/monetary-ldbl.h>
+#endif
+
__END_DECLS
#endif /* monetary.h */
diff --git a/stdlib/stdlib.h b/stdlib/stdlib.h
index 085130c..c3fc145 100644
--- a/stdlib/stdlib.h
+++ b/stdlib/stdlib.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991-2003, 2004, 2005 Free Software Foundation, Inc.
+/* Copyright (C) 1991-2003,2004,2005,2006 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -350,11 +350,13 @@ __NTH (strtof (__const char *__restrict __nptr, char **__restrict __endptr))
{
return __strtof_internal (__nptr, __endptr, 0);
}
+# ifndef __LDBL_COMPAT
extern __inline long double
__NTH (strtold (__const char *__restrict __nptr, char **__restrict __endptr))
{
return __strtold_internal (__nptr, __endptr, 0);
}
+# endif
__END_NAMESPACE_C99
# endif
@@ -966,6 +968,9 @@ extern int getloadavg (double __loadavg[], int __nelem)
#if __USE_FORTIFY_LEVEL > 0 && !defined __cplusplus
# include <bits/stdlib.h>
#endif
+#ifdef __LDBL_COMPAT
+# include <bits/stdlib-ldbl.h>
+#endif
#endif /* don't just need malloc and calloc */
#undef __need_malloc_and_calloc
diff --git a/stdlib/strfmon.c b/stdlib/strfmon.c
index b11f95c..11ae931 100644
--- a/stdlib/strfmon.c
+++ b/stdlib/strfmon.c
@@ -1,5 +1,6 @@
/* Formatting a monetary value according to the current locale.
- Copyright (C) 1996-2001, 2002, 2003, 2004 Free Software Foundation, Inc.
+ Copyright (C) 1996-2001, 2002, 2003, 2004, 2006
+ Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>
and Jochen Hein <Jochen.Hein@informatik.TU-Clausthal.de>, 1996.
@@ -22,10 +23,10 @@
#include <monetary.h>
#include <stdarg.h>
#include <locale/localeinfo.h>
-
+#include <math_ldbl_opt.h>
ssize_t
-strfmon (char *s, size_t maxsize, const char *format, ...)
+__strfmon (char *s, size_t maxsize, const char *format, ...)
{
va_list ap;
@@ -37,3 +38,4 @@ strfmon (char *s, size_t maxsize, const char *format, ...)
return res;
}
+ldbl_strong_alias (__strfmon, strfmon)
diff --git a/stdlib/strfmon_l.c b/stdlib/strfmon_l.c
index 58dab34..f6d52e0 100644
--- a/stdlib/strfmon_l.c
+++ b/stdlib/strfmon_l.c
@@ -1,5 +1,5 @@
/* Formatting a monetary value according to the given locale.
- Copyright (C) 1996, 1997, 2002, 2004 Free Software Foundation, Inc.
+ Copyright (C) 1996, 1997, 2002, 2004, 2006 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
@@ -23,10 +23,8 @@
#include <langinfo.h>
#include <locale.h>
#include <monetary.h>
-#ifdef USE_IN_LIBIO
-# include "../libio/libioP.h"
-# include "../libio/strfile.h"
-#endif
+#include "../libio/libioP.h"
+#include "../libio/strfile.h"
#include <printf.h>
#include <stdarg.h>
#include <stdio.h>
@@ -91,13 +89,9 @@ __vstrfmon_l (char *s, size_t maxsize, __locale_t loc, const char *format,
va_list ap)
{
struct locale_data *current = loc->__locales[LC_MONETARY];
-#ifdef USE_IN_LIBIO
_IO_strfile f;
-# ifdef _IO_MTSAFE_IO
+#ifdef _IO_MTSAFE_IO
_IO_lock_t lock;
-# endif
-#else
- FILE f;
#endif
struct printf_info info;
char *dest; /* Pointer so copy the output. */
@@ -278,7 +272,8 @@ __vstrfmon_l (char *s, size_t maxsize, __locale_t loc, const char *format,
if (*fmt == 'L')
{
++fmt;
- is_long_double = 1;
+ if (!__ldbl_is_dbl)
+ is_long_double = 1;
}
/* Handle format specifier. */
@@ -515,30 +510,13 @@ __vstrfmon_l (char *s, size_t maxsize, __locale_t loc, const char *format,
out_string (sign_string);
/* Print the number. */
-#ifdef USE_IN_LIBIO
-# ifdef _IO_MTSAFE_IO
+#ifdef _IO_MTSAFE_IO
f._sbf._f._lock = &lock;
-# endif
+#endif
INTUSE(_IO_init) ((_IO_FILE *) &f, 0);
_IO_JUMPS ((struct _IO_FILE_plus *) &f) = &_IO_str_jumps;
INTUSE(_IO_str_init_static) ((_IO_strfile *) &f, dest,
(s + maxsize) - dest, dest);
-#else
- memset ((void *) &f, 0, sizeof (f));
- f.__magic = _IOMAGIC;
- f.__mode.__write = 1;
- /* The buffer size is one less than MAXLEN
- so we have space for the null terminator. */
- f.__bufp = f.__buffer = (char *) dest;
- f.__bufsize = (s + maxsize) - dest;
- f.__put_limit = f.__buffer + f.__bufsize;
- f.__get_limit = f.__buffer;
- /* After the buffer is full (MAXLEN characters have been written),
- any more characters written will go to the bit bucket. */
- f.__room_funcs = __default_room_functions;
- f.__io_funcs.__write = NULL;
- f.__seen = 1;
-#endif
/* We clear the last available byte so we can find out whether
the numeric representation is too long. */
s[maxsize - 1] = '\0';
@@ -633,7 +611,7 @@ __vstrfmon_l (char *s, size_t maxsize, __locale_t loc, const char *format,
}
ssize_t
-__strfmon_l (char *s, size_t maxsize, __locale_t loc, const char *format, ...)
+___strfmon_l (char *s, size_t maxsize, __locale_t loc, const char *format, ...)
{
va_list ap;
@@ -645,4 +623,5 @@ __strfmon_l (char *s, size_t maxsize, __locale_t loc, const char *format, ...)
return res;
}
-weak_alias (__strfmon_l, strfmon_l)
+ldbl_strong_alias (___strfmon_l, __strfmon_l)
+ldbl_weak_alias (___strfmon_l, strfmon_l)
diff --git a/stdlib/strtod.c b/stdlib/strtod.c
index 1d4e4a4..d124bcd 100644
--- a/stdlib/strtod.c
+++ b/stdlib/strtod.c
@@ -1,6 +1,6 @@
/* Read decimal floating point numbers.
This file is part of the GNU C Library.
- Copyright (C) 1995-2002, 2003, 2004 Free Software Foundation, Inc.
+ Copyright (C) 1995-2002, 2003, 2004, 2006 Free Software Foundation, Inc.
Contributed by Ulrich Drepper <drepper@gnu.org>, 1995.
The GNU C Library is free software; you can redistribute it and/or
@@ -24,6 +24,7 @@
#ifndef FLOAT
+# include <math_ldbl_opt.h>
# define FLOAT double
# ifdef USE_WIDE_CHAR
# define STRTOF wcstod
@@ -68,3 +69,15 @@ STRTOF (nptr, endptr)
{
return INTERNAL(STRTOF_L) (nptr, endptr, 0, _NL_CURRENT_LOCALE);
}
+
+#ifdef LONG_DOUBLE_COMPAT
+# if LONG_DOUBLE_COMPAT(libc, GLIBC_2_0)
+# ifdef USE_WIDE_CHAR
+compat_symbol (libc, wcstod, wcstold, GLIBC_2_0);
+compat_symbol (libc, __wcstod_internal, __wcstold_internal, GLIBC_2_0);
+# else
+compat_symbol (libc, strtod, strtold, GLIBC_2_0);
+compat_symbol (libc, __strtod_internal, __strtold_internal, GLIBC_2_0);
+# endif
+# endif
+#endif
diff --git a/stdlib/strtod_l.c b/stdlib/strtod_l.c
index 5743ee4..e13f108 100644
--- a/stdlib/strtod_l.c
+++ b/stdlib/strtod_l.c
@@ -1,5 +1,5 @@
/* Convert string representing a number to float value, using given locale.
- Copyright (C) 1997,98,2002,2004,2005 Free Software Foundation, Inc.
+ Copyright (C) 1997,1998,2002,2004,2005,2006 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
@@ -28,6 +28,7 @@ extern unsigned long long int ____strtoull_l_internal (const char *, char **,
`strtof.c', `wcstod.c', `wcstold.c', and `wcstof.c' to produce the
`long double' and `float' versions of the reader. */
#ifndef FLOAT
+# include <math_ldbl_opt.h>
# define FLOAT double
# define FLT DBL
# ifdef USE_WIDE_CHAR
@@ -406,6 +407,9 @@ __mpn_lshift_1 (mp_limb_t *ptr, mp_size_t size, unsigned int count,
#define INTERNAL(x) INTERNAL1(x)
#define INTERNAL1(x) __##x##_internal
+#ifndef ____STRTOF_INTERNAL
+# define ____STRTOF_INTERNAL INTERNAL (__STRTOF)
+#endif
/* This file defines a function to check for correct grouping. */
#include "grouping.h"
@@ -417,7 +421,7 @@ __mpn_lshift_1 (mp_limb_t *ptr, mp_size_t size, unsigned int count,
return 0.0. If the number is too big to be represented, set `errno' to
ERANGE and return HUGE_VAL with the appropriate sign. */
FLOAT
-INTERNAL (__STRTOF) (nptr, endptr, group, loc)
+____STRTOF_INTERNAL (nptr, endptr, group, loc)
const STRING_TYPE *nptr;
STRING_TYPE **endptr;
int group;
@@ -1557,7 +1561,7 @@ INTERNAL (__STRTOF) (nptr, endptr, group, loc)
/* NOTREACHED */
}
#if defined _LIBC && !defined USE_WIDE_CHAR
-libc_hidden_def (INTERNAL (__STRTOF))
+libc_hidden_def (____STRTOF_INTERNAL)
#endif
/* External user entry point. */
@@ -1571,6 +1575,23 @@ __STRTOF (nptr, endptr, loc)
STRING_TYPE **endptr;
__locale_t loc;
{
- return INTERNAL (__STRTOF) (nptr, endptr, 0, loc);
+ return ____STRTOF_INTERNAL (nptr, endptr, 0, loc);
}
weak_alias (__STRTOF, STRTOF)
+
+#ifdef LONG_DOUBLE_COMPAT
+# if LONG_DOUBLE_COMPAT(libc, GLIBC_2_1)
+# ifdef USE_WIDE_CHAR
+compat_symbol (libc, __wcstod_l, __wcstold_l, GLIBC_2_1);
+# else
+compat_symbol (libc, __strtod_l, __strtold_l, GLIBC_2_1);
+# endif
+# endif
+# if LONG_DOUBLE_COMPAT(libc, GLIBC_2_3)
+# ifdef USE_WIDE_CHAR
+compat_symbol (libc, wcstod_l, wcstold_l, GLIBC_2_3);
+# else
+compat_symbol (libc, strtod_l, strtold_l, GLIBC_2_3);
+# endif
+# endif
+#endif
diff --git a/stdlib/strtold.c b/stdlib/strtold.c
index 0bb227a..1f56dea 100644
--- a/stdlib/strtold.c
+++ b/stdlib/strtold.c
@@ -1,6 +1,6 @@
/* Read decimal floating point numbers.
This file is part of the GNU C Library.
- Copyright (C) 1995-2002, 2003, 2004 Free Software Foundation, Inc.
+ Copyright (C) 1995-2002, 2003, 2004, 2006 Free Software Foundation, Inc.
Contributed by Ulrich Drepper <drepper@gnu.org>, 1995.
The GNU C Library is free software; you can redistribute it and/or
@@ -21,15 +21,43 @@
/* The actual implementation for all floating point sizes is in strtod.c.
These macros tell it to produce the `float' version, `strtof'. */
+#include <bits/wordsize.h>
+
+#ifdef __LONG_DOUBLE_MATH_OPTIONAL
+# include <wchar.h>
+# define NEW(x) NEW1(x)
+# define NEW1(x) __new_##x
+long double ____new_strtold_internal (const char *, char **, int);
+long double __new_strtold (const char *, char **);
+long double ____new_wcstold_internal (const wchar_t *, wchar_t **, int);
+long double __new_wcstold (const wchar_t *, wchar_t **);
+libc_hidden_proto (____new_strtold_internal)
+libc_hidden_proto (____new_wcstold_internal)
+#else
+# define NEW(x) x
+#endif
+
#define FLOAT long double
#define FLT LDBL
#ifdef USE_WIDE_CHAR
-# define STRTOF wcstold
+# define STRTOF NEW (wcstold)
# define STRTOF_L __wcstold_l
#else
-# define STRTOF strtold
+# define STRTOF NEW (strtold)
# define STRTOF_L __strtold_l
#endif
-
#include "strtod.c"
+
+#ifdef __LONG_DOUBLE_MATH_OPTIONAL
+# include <math_ldbl_opt.h>
+# ifdef USE_WIDE_CHAR
+long_double_symbol (libc, __new_wcstold, wcstold);
+long_double_symbol (libc, ____new_wcstold_internal, __wcstold_internal);
+libc_hidden_ver (____new_wcstold_internal, __wcstold_internal)
+# else
+long_double_symbol (libc, __new_strtold, strtold);
+long_double_symbol (libc, ____new_strtold_internal, __strtold_internal);
+libc_hidden_ver (____new_strtold_internal, __strtold_internal)
+# endif
+#endif