This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
[v3] long long, c99 support
- To: gcc-patches at gcc dot gnu dot org, libstdc++ at gcc dot gnu dot org
- Subject: [v3] long long, c99 support
- From: Benjamin Kosnik <bkoz at redhat dot com>
- Date: Thu, 19 Apr 2001 18:45:09 -0700
This patch implements the ideas found in this discussion of Gaby's patch:
V3 PATCH: #undef some C99 math macros in <cmath>
http://gcc.gnu.org/ml/libstdc++/2001-04/msg00120.html
Namely, it puts ISO C99 functions from cwchar, cmath, and cstdlib into
namespace c99, and then c++config injects namespace c99 into std if
_GLIBCPP_USE_C99 is enabled. I'm pretty sure this is what was desired,
as the discussion was remarkably sane and focused. Seems simple
enough. Thus, --enable-c99 turns this behavior on, and is on by
default. (--enable-c99=no turns it off.)
Again, --enable-c99 is for supporting "C" only.
In addition, I took the time to re-arrange the long long bits. Now,
--enable-long-long is all about enabling "C++" long long *only* bits:
namely iostream inserters/extractors. Now people can stop freaking
out about v3 having different behavior than v2. (Incidentally, I believe
this to be the last of the configure-type issues that need to be
addressed WRT compatibility.)
;)
This whole exercise certainly clarified the configure bits for me, I
hope it helps everybody else out too.
I've documented the changed/updated/new configure bits in configopts.html.
I've probably missed some configure bits, but this does work on
x86/native. I'll be testing on alpha and powerpc ASAP to make sure
nothing obvious is wrong.
Comments? If nothing major, I'll check this in later tonight.
-benjamin
2001-04-19 Benjamin Kosnik <bkoz@redhat.com>
* include/bits/stl_algo.h: Use _GLIBCPP_HAVE_DRAND48.
* include/bits/c++config (__STL_ASSERTIONS): Simplify.
* acinclude.m4 (GLIBCPP_CHECK_STDLIB_SUPPORT): Add check for drand48.
* aclocal.m4: Regenerate.
* configure: Regenerate.
* acconfig.h (_GLIBCPP_USE_C99): Add.
* config.h.in: Regenerate.
* acinclude.m4 (GLIBCPP_ENABLE_C99): New macro. Test for ISO/IEC
9899: 1999 support.
* aclocal.m4: Regenerate.
* configure.in (GLIBCPP_ENABLE_C99): Use it, on by default.
* configure: Regenerate.
* configure.in (GLIBCPP_ENABLE_LONG_LONG): Set default to yes.
* configure: Regenerate.
* include/c_std/bits/std_cwchar.h: Put wcstold, wcstoll, wcstoull
into c99.
* include/c_std/bits/std_cmath.h: Bring C99 functions into c99
namespace.
* include/c_std/bits/std_cstdlib.h: Same.
* docs/html/configopts.html: Update.
* testsuite/26_numerics/c99_macros.cc: Edit, use cmath instead of
math.h
(test_c99_classify): Add.
* config/os/gnu-linux/bits/os_defines.h (_GNU_SOURCE): Remove.
Index: acconfig.h
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/acconfig.h,v
retrieving revision 1.15
diff -c -p -r1.15 acconfig.h
*** acconfig.h 2001/01/02 07:38:45 1.15
--- acconfig.h 2001/04/20 01:33:27
***************
*** 12,17 ****
--- 12,20 ----
// Include support for 'long long' and 'unsigned long long'.
#undef _GLIBCPP_USE_LONG_LONG
+ // Define if code specialized for wchar_t should be used.
+ #undef _GLIBCPP_USE_C99
+
// Include support for 'long double'.
#undef _GLIBCPP_USE_LONG_DOUBLE
***************
*** 30,45 ****
// Define if you have the copysignf function.
#undef _GLIBCPP_HAVE_COPYSIGNF
! // Define if lldiv_t exists in stdlib.h.
! #undef HAVE_LLDIV_T
!
! // Define if mbstate_t exists in wchar.h. */
#undef HAVE_MBSTATE_T
! // Define if you have the modff function. */
#undef HAVE_MODFF
! // Define if you have the modfl function. */
#undef HAVE_MODFL
// Define if the compiler/host combination has __builtin_abs
--- 33,45 ----
// Define if you have the copysignf function.
#undef _GLIBCPP_HAVE_COPYSIGNF
! // Define if mbstate_t exists in wchar.h.
#undef HAVE_MBSTATE_T
! // Define if you have the modff function.
#undef HAVE_MODFF
! // Define if you have the modfl function.
#undef HAVE_MODFL
// Define if the compiler/host combination has __builtin_abs
***************
*** 98,103 ****
--- 98,112 ----
// Systems that have certain non-standard functions prefixed with an
// underscore, we'll handle those here. Must come after config.h.in.
//
+
+ #if defined(_GLIBCPP_USE_C99) && defined(__cplusplus)
+ // Placeholder for declarations in c99 namespace.
+ namespace c99 { };
+ namespace std
+ {
+ using namespace c99;
+ }
+ #endif
#if defined (HAVE__ISNAN) && ! defined (HAVE_ISNAN)
# define HAVE_ISNAN 1
Index: acinclude.m4
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/acinclude.m4,v
retrieving revision 1.140
diff -c -p -r1.140 acinclude.m4
*** acinclude.m4 2001/04/11 18:52:28 1.140
--- acinclude.m4 2001/04/20 01:33:32
*************** dnl Check to see if the (stdlib function
*** 455,463 ****
dnl 1) declared when using the c++ compiler
dnl 2) has "C" linkage
dnl
- dnl Define HAVE_STRTOLD if "strtold" is declared and links
- dnl Define HAVE_STRTOF if "strtof" is declared and links
- dnl
dnl argument 1 is name of function to check
dnl
dnl ASSUMES argument is a math function with TWO parameters
--- 455,460 ----
*************** dnl 1) make sure the name is declared wh
*** 600,607 ****
dnl 2) make sure the name has "C" linkage
dnl This might seem like overkill but experience has shown that it's not...
dnl
! dnl Define HAVE_STRTOF etc if "strtof" is found.
! dnl Define HAVE_STRTOLD etc if "strtold" is found.
dnl
dnl GLIBCPP_CHECK_STDLIB_SUPPORT
AC_DEFUN(GLIBCPP_CHECK_STDLIB_SUPPORT, [
--- 597,605 ----
dnl 2) make sure the name has "C" linkage
dnl This might seem like overkill but experience has shown that it's not...
dnl
! dnl Define HAVE_STRTOLD if "strtold" is declared and links
! dnl Define HAVE_STRTOF if "strtof" is declared and links
! dnl Define HAVE_DRAND48 if "drand48" is declared and links
dnl
dnl GLIBCPP_CHECK_STDLIB_SUPPORT
AC_DEFUN(GLIBCPP_CHECK_STDLIB_SUPPORT, [
*************** AC_DEFUN(GLIBCPP_CHECK_STDLIB_SUPPORT, [
*** 611,616 ****
--- 609,615 ----
AC_CHECK_FUNCS(strtof)
GLIBCPP_CHECK_STDLIB_DECL_AND_LINKAGE_2(strtold)
+ AC_CHECK_FUNCS(drand48)
CXXFLAGS="$ac_save_CXXFLAGS"
])
*************** AC_DEFUN(GLIBCPP_ENABLE_LONG_LONG, [dnl
*** 1344,1387 ****
*) AC_MSG_ERROR([Unknown argument to enable/disable long long]) ;;
esac],
enable_long_long=GLIBCPP_ENABLE_LONG_LONG_DEFAULT)dnl
! # Allow use of os-dependent settings, so that macros that turn on
! # C99 capabilities can be defined and used in a consistent way.
! OS_INC_PATH=${srcdir}/$os_include_dir
! ac_test_CFLAGS="${CFLAGS+set}"
! ac_save_CFLAGS="$CFLAGS"
! CFLAGS="-I$OS_INC_PATH"
!
! # Check for the existence of functions used if long long is enabled.
! AC_CHECK_FUNC(strtoll,,ac_strtoll=no)
! AC_CHECK_FUNC(strtoull,,ac_strtoull=no)
! # Check for lldiv_t, et. al.
AC_MSG_CHECKING([for lldiv_t declaration])
! AC_CACHE_VAL(glibcpp_lldiv_t_use, [
! AC_TRY_COMPILE([#include <bits/os_defines.h>
! #include <stdlib.h>],
[ lldiv_t mydivt;],
! [glibcpp_lldiv_t_use=yes], [glibcpp_lldiv_t_use=no])
])
! AC_MSG_RESULT($glibcpp_lldiv_t_use)
! if test x$glibcpp_lldiv_t_use = x"yes"; then
! AC_DEFINE(HAVE_LLDIV_T)
! fi
! AC_MSG_CHECKING([for enabled long long])
! if test x"$ac_strtoll" = xno || test x"$ac_strtoull" = xno; then
! enable_long_long=no;
fi;
! AC_MSG_RESULT($enable_long_long)
# Option parsed, now set things appropriately
! if test x"$enable_long_long" = xyes; then
! AC_DEFINE(_GLIBCPP_USE_LONG_LONG)
fi
! # Reset CFLAGS
! CFLAGS="$ac_save_CFLAGS"
])
--- 1343,1435 ----
*) AC_MSG_ERROR([Unknown argument to enable/disable long long]) ;;
esac],
enable_long_long=GLIBCPP_ENABLE_LONG_LONG_DEFAULT)dnl
+
+ # Option parsed, now set things appropriately
+ if test x"$enable_long_long" = xyes; then
+ AC_DEFINE(_GLIBCPP_USE_LONG_LONG)
+ fi
+ ])
+
+
+ dnl
+ dnl Check for ISO/IEC 9899:1999 "C99" support.
+ dnl
+ dnl GLIBCPP_ENABLE_C99
+ dnl --enable-c99 defines _GLIBCPP_USE_C99
+ dnl --disable-c99 leaves _GLIBCPP_USE_C99 undefined
+ dnl + Usage: GLIBCPP_ENABLE_C99[(DEFAULT)]
+ dnl Where DEFAULT is either `yes' or `no'. If ommitted, it
+ dnl defaults to `no'.
+ dnl + If 'C99' stuff is not available, ignores DEFAULT and sets `no'.
+ dnl
+ dnl GLIBCPP_ENABLE_C99
+ AC_DEFUN(GLIBCPP_ENABLE_C99, [dnl
+ define([GLIBCPP_ENABLE_C99_DEFAULT], ifelse($1, yes, yes, no))dnl
+
+ AC_ARG_ENABLE(c99,
+ changequote(<<, >>)dnl
+ <<--enable-c99 turns on 'ISO/IEC 9899:1999 support' [default=>>GLIBCPP_ENABLE_C99_DEFAULT],
+ changequote([, ])dnl
+ [case "$enableval" in
+ yes) enable_c99=yes ;;
+ no) enable_c99=no ;;
+ *) AC_MSG_ERROR([Unknown argument to enable/disable C99]) ;;
+ esac],
+ enable_c99=GLIBCPP_ENABLE_C99_DEFAULT)dnl
! AC_LANG_SAVE
! AC_LANG_CPLUSPLUS
! # Check for the existence of <math.h> functions used if C99 is enabled.
! AC_TRY_COMPILE([#include <math.h>],[fpclassify(0.0);],, [ac_c99_math=no])
! AC_TRY_COMPILE([#include <math.h>],[isfinite(0.0);],, [ac_c99_math=no])
! AC_TRY_COMPILE([#include <math.h>],[isinf(0.0);],, [ac_c99_math=no])
! AC_TRY_COMPILE([#include <math.h>],[isnan(0.0);],, [ac_c99_math=no])
! AC_TRY_COMPILE([#include <math.h>],[isnormal(0.0);],, [ac_c99_math=no])
! AC_TRY_COMPILE([#include <math.h>],[signbit(0.0);],, [ac_c99_math=no])
! AC_TRY_COMPILE([#include <math.h>],[isgreater(0,0);],, [ac_c99_math=no])
! AC_TRY_COMPILE([#include <math.h>],[isgreaterequal(0,0);],, [ac_c99_math=no])
! AC_TRY_COMPILE([#include <math.h>],[isless(0,0);],, [ac_c99_math=no])
! AC_TRY_COMPILE([#include <math.h>],[islessequal(0,0);],, [ac_c99_math=no])
! AC_TRY_COMPILE([#include <math.h>],[islessgreater(0,0);],, [ac_c99_math=no])
! AC_TRY_COMPILE([#include <math.h>],[isunordered(0,0);],, [ac_c99_math=no])
!
! # Check for the existence in <stdlib.h> of lldiv_t, et. al.
! AC_CHECK_FUNC(strtoll,,ac_c99_stdlib=no)
! AC_CHECK_FUNC(strtoull,,ac_c99_stdlib=no)
! AC_CHECK_FUNC(llabs,,ac_c99_stdlib=no)
! AC_CHECK_FUNC(lldiv,,ac_c99_stdlib=no)
! AC_CHECK_FUNC(atoll,,ac_c99_stdlib=no)
!
AC_MSG_CHECKING([for lldiv_t declaration])
! AC_CACHE_VAL(ac_c99_lldiv_t, [
! AC_TRY_COMPILE([#include <stdlib.h>],
[ lldiv_t mydivt;],
! [ac_c99_lldiv_t=yes], [ac_c99_lldiv_t=no])
])
! AC_MSG_RESULT($ac_c99_lldiv_t)
! if test x"$ac_c99_lldiv_t" = x"no"; then
! ac_c99_stdlib=no;
! fi;
! # Check for the existence of <wchar.h> functions used if C99 is enabled.
! AC_CHECK_FUNC(wcstold,,ac_c99_wchar=no)
! AC_CHECK_FUNC(wcstoll,,ac_c99_wchar=no)
! AC_CHECK_FUNC(wcstoull,,ac_c99_wchar=no)
!
! AC_MSG_CHECKING([for enabled ISO C99 support])
! if test x"$ac_c99_math" = x"no" || test x"$ac_c99_wchar" = x"no" \
! || test x"$ac_c99_stdlib" = x"no"; then
! enable_c99=no;
fi;
! AC_MSG_RESULT($enable_c99)
# Option parsed, now set things appropriately
! if test x"$enable_c99" = x"yes"; then
! AC_DEFINE(_GLIBCPP_USE_C99)
fi
! AC_LANG_RESTORE
])
*************** AC_DEFUN([AM_PROG_LIBTOOL])
*** 1751,1754 ****
--- 1799,1803 ----
AC_DEFUN([AC_LIBTOOL_DLOPEN])
AC_DEFUN([AC_PROG_LD])
])
+
Index: configure.in
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/configure.in,v
retrieving revision 1.58
diff -c -p -r1.58 configure.in
*** configure.in 2001/04/11 18:52:31 1.58
--- configure.in 2001/04/20 01:34:17
*************** GLIBCPP_ENABLE_DEBUG($USE_MAINTAINER_MOD
*** 64,70 ****
GLIBCPP_ENABLE_CSTDIO
GLIBCPP_ENABLE_CLOCALE
GLIBCPP_ENABLE_C_MBCHAR([yes])
! GLIBCPP_ENABLE_LONG_LONG([no])
GLIBCPP_ENABLE_CHEADERS([c_std])
GLIBCPP_ENABLE_THREADS
GLIBCPP_ENABLE_CXX_FLAGS([none])
--- 64,71 ----
GLIBCPP_ENABLE_CSTDIO
GLIBCPP_ENABLE_CLOCALE
GLIBCPP_ENABLE_C_MBCHAR([yes])
! GLIBCPP_ENABLE_C99([yes])
! GLIBCPP_ENABLE_LONG_LONG([yes])
GLIBCPP_ENABLE_CHEADERS([c_std])
GLIBCPP_ENABLE_THREADS
GLIBCPP_ENABLE_CXX_FLAGS([none])
Index: config/os/gnu-linux/bits/os_defines.h
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/config/os/gnu-linux/bits/os_defines.h,v
retrieving revision 1.8
diff -c -p -r1.8 os_defines.h
*** os_defines.h 2001/01/03 15:53:26 1.8
--- os_defines.h 2001/04/20 01:34:18
***************
*** 1,6 ****
// Specific definitions for GNU/Linux -*- C++ -*-
! // Copyright (C) 2000 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
--- 1,6 ----
// Specific definitions for GNU/Linux -*- C++ -*-
! // Copyright (C) 2000, 2001 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
***************
*** 29,41 ****
#ifndef _GLIBCPP_OS_DEFINES
! # define _GLIBCPP_OS_DEFINES
!
! // By defining this, all GNU extensions are enabled.
! #define _GNU_SOURCE 1
!
! // By defining this, all ISO C99 functionality is enabled.
! #define _ISOC99_SOURCE 1
// This keeps isanum, et al from being propagated as macros.
#define __NO_CTYPE 1
--- 29,35 ----
#ifndef _GLIBCPP_OS_DEFINES
! #define _GLIBCPP_OS_DEFINES 1
// This keeps isanum, et al from being propagated as macros.
#define __NO_CTYPE 1
Index: docs/html/configopts.html
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/docs/html/configopts.html,v
retrieving revision 1.9
diff -c -p -r1.9 configopts.html
*** configopts.html 2001/04/06 01:47:11 1.9
--- configopts.html 2001/04/20 01:34:19
*************** options</A></H1>
*** 91,106 ****
'generic'.
</P>
<DT><TT>--enable-long-long </TT>
<DD><P>The "long long" type was introduced in C99. It is
provided as a GNU extension to C++98 in g++. This flag builds
support for "long long" into the library
! (specialized templates and the like). This option is off by
! default: if enabled, users will have to either use the
! new-style "C" headers by default (ie cmath not math.h)
! or add appropriate compile-time flags to all compile lines to
! allow "C" visibility of this feature (on GNU/Linux,
! the flag is -D_ISOC99_SOURCE).
</P>
<DT><TT>--enable-cheaders=OPTION </TT>
--- 91,121 ----
'generic'.
</P>
+ <DT><TT>--enable-c99 </TT>
+ <DD><P>The "long long" type was introduced in C99, along
+ with bunches of other functions for wide characters, and math
+ classification macros, etc. If enabled, all C99 functions not
+ specified by the C++ standard will be put into namespace c99,
+ and then all names in the c99 namespace will be injected into
+ namespace std, so that C99 functions can be used "as if" they
+ were in the C++ standard (as they will eventually be in some
+ future revision of the standard, without a doubt.) By default,
+ C99 support is on, assuming the configure probes find all the
+ necessary functions and bits necessary.
+ </P>
+
<DT><TT>--enable-long-long </TT>
<DD><P>The "long long" type was introduced in C99. It is
provided as a GNU extension to C++98 in g++. This flag builds
support for "long long" into the library
! (specialized templates and the like for iostreams). This
! option is on by default: if enabled, users will have to either
! use the new-style "C" headers by default (ie cmath
! not math.h) or add appropriate compile-time flags to all
! compile lines to allow "C" visibility of this
! feature (on GNU/Linux, the flag is -D_ISOC99_SOURCE, which is
! added automatically via CPLUSPLUS_CPP_SPEC's addition of
! _GNU_SOURCE).
</P>
<DT><TT>--enable-cheaders=OPTION </TT>
Index: include/bits/c++config
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/include/bits/c++config,v
retrieving revision 1.20
diff -c -p -r1.20 c++config
*** c++config 2001/04/18 01:06:04 1.20
--- c++config 2001/04/20 01:34:19
***************
*** 49,54 ****
--- 49,58 ----
// by the compiler, but instead instantiated into the library binary.
#define _GLIBCPP_FULLY_COMPLIANT_HEADERS 1
+ // Define this to permit user-level control of the expansion of string
+ // buffers (via a fn pointer), see basic_string.* for more.
+ //#define _GLIBCPP_ALLOC_CONTROL
+
// To enable older, ARM-style iostreams and other anachronisms use this.
//#define _GLIBCPP_DEPRECATED 1
***************
*** 59,144 ****
//#define _GLIBCPP_CONCEPT_CHECKS 1
// From SGI's stl_config.h; generic settings and user hooks (_NOTHREADS).
#if defined(_PTHREADS) && !defined(_NOTHREADS)
! # define __STL_PTHREADS
#endif
#if defined(_UITHREADS) && !defined(_PTHREADS) && !defined(_NOTHREADS)
! # define __STL_UITHREADS
#endif
// This is also a user hook, but via -f[no-]exceptions, not direct #defines.
#ifdef __EXCEPTIONS
! # define __STL_USE_EXCEPTIONS
! # define __STL_TRY try
! # define __STL_CATCH_ALL catch(...)
! # define __STL_THROW(x) throw x
! # define __STL_RETHROW throw
! # define __STL_NOTHROW throw()
! # define __STL_UNWIND(action) catch(...) { action; throw; }
#else
! # define __STL_TRY
! # define __STL_CATCH_ALL if (false)
! # define __STL_THROW(x)
! # define __STL_RETHROW
! # define __STL_NOTHROW
! # define __STL_UNWIND(action)
#endif
// This is the "underlying allocator" for STL. The alternatives are
// homegrown schemes involving a kind of mutex and free list; see stl_alloc.h.
#define __USE_MALLOC
- // Define this to permit user-level control of the expansion of string
- // buffers (via a fn pointer), see basic_string.* for more.
- //#define _GLIBCPP_ALLOC_CONTROL
-
// The remainder of the prewritten config is mostly automatic; all the
// user hooks are listed above.
! #ifdef _REENTRANT
! # define __STL_THREADS
! #endif
! #ifdef _PTHREADS
! # define __STL_PTHREADS
! #endif
! //#ifndef __STRICT_ANSI__
! //# define __STL_LONG_LONG
! //#endif
!
! // Mingw32, GCC compiler using the Microsoft C runtime (settings taken from
! // SGI's stl_config.h)
! #if defined(__MINGW32__)
! # define __STL_NO_DRAND48
! # ifdef _MT
! # define __STL_WIN32THREADS
! # endif
! #endif
!
! // Cygwin32, GCC compiler on MS Windows (settings taken from SGI's
! // stl_config.h)
! #if defined(__CYGWIN__)
! # define __STL_NO_DRAND48
! #endif
!
! // XXX Only used in the SGI rope extensions; this is from stl_config.h and
// should be cleaned up.
- #ifdef __STL_ASSERTIONS
- # include <stdio.h>
- # define __stl_assert(expr) \
- if (!(expr)) { fprintf(stderr, "%s:%d STL assertion failure: %s\n", \
- __FILE__, __LINE__, # expr); abort(); }
- #else
# define __stl_assert(expr)
- #endif
-
-
- #if defined(__STL_WIN32THREADS) || defined(__STL_SGI_THREADS) \
- || defined(__STL_PTHREADS) || defined(__STL_UITHREADS)
- # define __STL_THREADS
- # define __STL_VOLATILE volatile
- #else
- # define __STL_VOLATILE
- #endif
-
// End of prewritten config; the discovered settings follow.
--- 63,116 ----
//#define _GLIBCPP_CONCEPT_CHECKS 1
// From SGI's stl_config.h; generic settings and user hooks (_NOTHREADS).
+ #ifdef _REENTRANT
+ # define __STL_THREADS
+ #endif
+
#if defined(_PTHREADS) && !defined(_NOTHREADS)
! # define __STL_PTHREADS
#endif
+
#if defined(_UITHREADS) && !defined(_PTHREADS) && !defined(_NOTHREADS)
! # define __STL_UITHREADS
#endif
+ #if defined(__STL_WIN32THREADS) || defined(__STL_SGI_THREADS) \
+ || defined(__STL_PTHREADS) || defined(__STL_UITHREADS)
+ # define __STL_THREADS
+ # define __STL_VOLATILE volatile
+ #else
+ # define __STL_VOLATILE
+ #endif
+
// This is also a user hook, but via -f[no-]exceptions, not direct #defines.
#ifdef __EXCEPTIONS
! # define __STL_USE_EXCEPTIONS
! # define __STL_TRY try
! # define __STL_CATCH_ALL catch(...)
! # define __STL_THROW(x) throw x
! # define __STL_RETHROW throw
! # define __STL_NOTHROW throw()
! # define __STL_UNWIND(action) catch(...) { action; throw; }
#else
! # define __STL_TRY
! # define __STL_CATCH_ALL if (false)
! # define __STL_THROW(x)
! # define __STL_RETHROW
! # define __STL_NOTHROW
! # define __STL_UNWIND(action)
#endif
// This is the "underlying allocator" for STL. The alternatives are
// homegrown schemes involving a kind of mutex and free list; see stl_alloc.h.
#define __USE_MALLOC
// The remainder of the prewritten config is mostly automatic; all the
// user hooks are listed above.
! // XXX
! // Only used in the SGI rope extensions; this is from stl_config.h and
// should be cleaned up.
# define __stl_assert(expr)
// End of prewritten config; the discovered settings follow.
Index: include/bits/stl_algo.h
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/include/bits/stl_algo.h,v
retrieving revision 1.5
diff -c -p -r1.5 stl_algo.h
*** stl_algo.h 2001/04/17 23:11:28 1.5
--- stl_algo.h 2001/04/20 01:34:28
*************** _OutputIter rotate_copy(_ForwardIter __f
*** 1088,1100 ****
// Return a random number in the range [0, __n). This function encapsulates
// whether we're using rand (part of the standard C library) or lrand48
// (not standard, but a much better choice whenever it's available).
-
template <class _Distance>
inline _Distance __random_number(_Distance __n) {
! #ifdef __STL_NO_DRAND48
! return rand() % __n;
! #else
return lrand48() % __n;
#endif
}
--- 1088,1099 ----
// Return a random number in the range [0, __n). This function encapsulates
// whether we're using rand (part of the standard C library) or lrand48
// (not standard, but a much better choice whenever it's available).
template <class _Distance>
inline _Distance __random_number(_Distance __n) {
! #ifdef _GLIBCPP_HAVE_DRAND48
return lrand48() % __n;
+ #else
+ return rand() % __n;
#endif
}
Index: include/c_std/bits/std_cmath.h
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/include/c_std/bits/std_cmath.h,v
retrieving revision 1.8
diff -c -p -r1.8 std_cmath.h
*** std_cmath.h 2001/04/06 19:14:27 1.8
--- std_cmath.h 2001/04/20 01:34:31
***************
*** 67,90 ****
#undef tan
#undef tanh
- // These are possible macros imported from C99-land. They tend to break
- // well-formed C++ programs. Just pretend we don't know about them.
- // At some point, we should provide extensions in std:: -- Gaby
-
- #undef fpclassify
- #undef isfinite
- #undef isinf
- #undef isnan
- #undef isnormal
- #undef signbit
-
- #undef isgreater
- #undef isgreaterequal
- #undef isless
- #undef islessequal
- #undef islessgreater
- #undef isunordered
-
namespace std
{
// Forward declaration of a helper function. This really should be
--- 67,72 ----
*************** namespace std
*** 619,624 ****
--- 601,736 ----
#endif
} // std
+
+ #if _GLIBCPP_USE_C99
+ // These are possible macros imported from C99-land. For strict
+ // conformance, remove possible C99-injected names from the
+ // global namespace, and sequester them in the c99 namespace.
+ namespace c99
+ {
+ template<typename _Tp>
+ int
+ __capture_fpclassify(_Tp __f) { return fpclassify(__f); }
+
+ template<typename _Tp>
+ int
+ __capture_isfinite(_Tp __f) { return isfinite(__f); }
+
+ template<typename _Tp>
+ int
+ __capture_isinf(_Tp __f) { return isinf(__f); }
+
+ template<typename _Tp>
+ int
+ __capture_isnan(_Tp __f) { return isnan(__f); }
+
+ template<typename _Tp>
+ int
+ __capture_isnormal(_Tp __f) { return isnormal(__f); }
+
+ template<typename _Tp>
+ int
+ __capture_signbit(_Tp __f) { return signbit(__f); }
+
+ template<typename _Tp>
+ int
+ __capture_isgreater(_Tp __f1, _Tp __f2) { return isgreater(__f1, __f2); }
+
+ template<typename _Tp>
+ int
+ __capture_isgreaterequal(_Tp __f1, _Tp __f2)
+ { return isgreaterequal(__f1, __f2); }
+
+ template<typename _Tp>
+ int
+ __capture_isless(_Tp __f1, _Tp __f2) { return isless(__f1, __f2); }
+
+ template<typename _Tp>
+ int
+ __capture_islessequal(_Tp __f1, _Tp __f2)
+ { return islessequal(__f1, __f2); }
+
+ template<typename _Tp>
+ int
+ __capture_islessgreater(_Tp __f1, _Tp __f2)
+ { return islessgreater(__f1, __f2); }
+
+ template<typename _Tp>
+ int
+ __capture_isunordered(_Tp __f1, _Tp __f2)
+ { return isunordered(__f1, __f2); }
+ } // namespace c99
+ #endif
+
+ #undef fpclassify
+ #undef isfinite
+ #undef isinf
+ #undef isnan
+ #undef isnormal
+ #undef signbit
+ #undef isgreater
+ #undef isgreaterequal
+ #undef isless
+ #undef islessequal
+ #undef islessgreater
+ #undef isunordered
+
+ #if _GLIBCPP_USE_C99
+ namespace c99
+ {
+ template<typename _Tp>
+ int
+ fpclassify(_Tp __f) { return __capture_fpclassify(__f); }
+
+ template<typename _Tp>
+ int
+ isfinite(_Tp __f) { return __capture_isfinite(__f); }
+
+ template<typename _Tp>
+ int
+ isinf(_Tp __f) { return __capture_isinf(__f); }
+
+ template<typename _Tp>
+ int
+ isnan(_Tp __f) { return __capture_isnan(__f); }
+
+ template<typename _Tp>
+ int
+ isnormal(_Tp __f) { return __capture_isnormal(__f); }
+
+ template<typename _Tp>
+ int
+ signbit(_Tp __f) { return __capture_signbit(__f); }
+
+ template<typename _Tp>
+ int
+ isgreater(_Tp __f1, _Tp __f2) { return __capture_isgreater(__f1, __f2); }
+
+ template<typename _Tp>
+ int
+ isgreaterequal(_Tp __f1, _Tp __f2)
+ { return __capture_isgreaterequal(__f1, __f2); }
+
+ template<typename _Tp>
+ int
+ isless(_Tp __f1, _Tp __f2) { return __capture_isless(__f1, __f2); }
+
+ template<typename _Tp>
+ int
+ islessequal(_Tp __f1, _Tp __f2)
+ { return __capture_islessequal(__f1, __f2); }
+
+ template<typename _Tp>
+ int
+ islessgreater(_Tp __f) { return __capture_islessgreater(__f); }
+
+ template<typename _Tp>
+ int
+ isunordered(_Tp __f1, _Tp __f2)
+ { return __capture_isunordered(__f1, __f2); }
+ }
+ #endif
+
#ifdef _GLIBCPP_NO_TEMPLATE_EXPORT
# define export
# include <bits/cmath.tcc>
Index: include/c_std/bits/std_cstdlib.h
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/include/c_std/bits/std_cstdlib.h,v
retrieving revision 1.8
diff -c -p -r1.8 std_cstdlib.h
*** std_cstdlib.h 2001/03/06 02:51:13 1.8
--- std_cstdlib.h 2001/04/20 01:34:31
*************** namespace std
*** 85,102 ****
using ::div_t;
using ::ldiv_t;
- #ifdef _GLIBCPP_USE_LONG_LONG
- # ifdef _GLIBCPP_HAVE_LLDIV_T
- using ::lldiv_t;
- # else
- struct lldiv_t
- {
- long long quot;
- long long rem;
- };
- # endif
- #endif
-
extern "C" double atof(const char*);
extern "C" int atoi(const char*);
extern "C" long int atol(const char*);
--- 85,90 ----
*************** namespace std
*** 135,142 ****
inline ldiv_t
div(long __i, long __j) { return ::ldiv(__i, __j); }
! #ifdef _GLIBCPP_USE_LONG_LONG
inline long long
abs(long long __x) { return __x >= 0 ? __x : -__x; }
--- 123,135 ----
inline ldiv_t
div(long __i, long __j) { return ::ldiv(__i, __j); }
+ } // namespace std
! #if _GLIBCPP_USE_C99
! namespace c99
! {
! using ::lldiv_t;
!
inline long long
abs(long long __x) { return __x >= 0 ? __x : -__x; }
*************** namespace std
*** 154,171 ****
extern "C" long long int atoll(const char*);
extern "C" long long int strtoll(const char*, char**, int);
extern "C" unsigned long long int strtoull(const char*, char**, int);
- #endif
#ifdef _GLIBCPP_HAVE_STRTOLD
extern "C" long double strtold(const char*, char**);
#endif
- }
#endif
-
-
-
-
-
-
-
--- 147,157 ----
extern "C" long long int atoll(const char*);
extern "C" long long int strtoll(const char*, char**, int);
extern "C" unsigned long long int strtoull(const char*, char**, int);
#ifdef _GLIBCPP_HAVE_STRTOLD
extern "C" long double strtold(const char*, char**);
+ #endif
+ } // namespace c99
#endif
#endif
Index: include/c_std/bits/std_cwchar.h
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/include/c_std/bits/std_cwchar.h,v
retrieving revision 1.6
diff -c -p -r1.6 std_cwchar.h
*** std_cwchar.h 2001/04/02 22:51:25 1.6
--- std_cwchar.h 2001/04/20 01:34:33
***************
*** 46,52 ****
#include <wchar.h>
#endif
-
// Need to do a bit of trickery here with mbstate_t as char_traits
// assumes it is in wchar.h, regardless of wchar_t specializations.
#ifndef _GLIBCPP_HAVE_MBSTATE_T
--- 46,51 ----
*************** namespace std
*** 192,210 ****
return const_cast<wchar_t*>(wmemchr(const_cast<const wchar_t*>(__p), __c, __n));
}
extern "C" int wmemcmp(const wchar_t*, const wchar_t*, size_t);
- //extern "C" int wmemcmp(wchar_t*, const wchar_t*, size_t);
extern "C" wchar_t* wmemcpy(wchar_t*, const wchar_t*, size_t);
extern "C" wchar_t* wmemmove(wchar_t*, const wchar_t*, size_t);
extern "C" wchar_t* wmemset(wchar_t*, wchar_t, size_t);
extern "C" size_t wcsftime(wchar_t*, size_t, const wchar_t*, const struct tm*);
! #if 0
! // Full C99 listing
extern "C" long double wcstold(const wchar_t*, wchar_t**);
extern "C" long long int wcstoll(const wchar_t*, wchar_t**, int);
extern "C" unsigned long long int wcstoull(const wchar_t*, wchar_t**, int);
- #endif
}
#endif //_GLIBCPP_USE_WCHAR_T
#endif
--- 191,211 ----
return const_cast<wchar_t*>(wmemchr(const_cast<const wchar_t*>(__p), __c, __n));
}
extern "C" int wmemcmp(const wchar_t*, const wchar_t*, size_t);
extern "C" wchar_t* wmemcpy(wchar_t*, const wchar_t*, size_t);
extern "C" wchar_t* wmemmove(wchar_t*, const wchar_t*, size_t);
extern "C" wchar_t* wmemset(wchar_t*, wchar_t, size_t);
extern "C" size_t wcsftime(wchar_t*, size_t, const wchar_t*, const struct tm*);
+ }
! #if _GLIBCPP_USE_C99
! namespace c99
! {
extern "C" long double wcstold(const wchar_t*, wchar_t**);
extern "C" long long int wcstoll(const wchar_t*, wchar_t**, int);
extern "C" unsigned long long int wcstoull(const wchar_t*, wchar_t**, int);
}
+ #endif
+
#endif //_GLIBCPP_USE_WCHAR_T
#endif
Index: testsuite/26_numerics/c99_macros.cc
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/testsuite/26_numerics/c99_macros.cc,v
retrieving revision 1.2
diff -c -p -r1.2 c99_macros.cc
*** c99_macros.cc 2001/04/06 19:14:27 1.2
--- c99_macros.cc 2001/04/20 01:34:34
***************
*** 1,6 ****
// 2001-04-06 gdr
! // Copyright (C) 1999, 2000 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
--- 1,6 ----
// 2001-04-06 gdr
! // Copyright (C) 2001 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
***************
*** 29,35 ****
// { dg-do compile }
! #include <math.h>
void fpclassify() { }
--- 29,35 ----
// { dg-do compile }
! #include <cmath>
void fpclassify() { }
*************** void islessgreater() { }
*** 55,61 ****
--- 55,97 ----
void isunordered() { }
+ #if _GLIBCPP_USE_C99
+ template <typename _Tp>
+ void test_c99_classify()
+ {
+ using namespace std;
+ test = bool;
+
+ typedef _Tp fp_type;
+ fp_type f1 = 1.0;
+ fp_type f2 = 3.0;
+ int res = 0;
+
+ res = fpclassify(f1);
+ res = isfinite(f2);
+ res = isinf(f1);
+ res = isnan(f2);
+ res = isnormal(f1);
+ res = signbit(f2);
+ res = isgreater(f1, f2);
+ res = isgreaterequal(f1, f2);
+ res = isless(f1, f2);
+ res = islessequal(f1,f2);
+ res = islessgreater(f1, f2);
+ res = isunordered(f1, f2);
+ }
+ #endif
+
int main()
{
+ #if _GLIBCPP_USE_C99
+ test_c99_classify<float>();
+ test_c99_classify<double>();
+ #endif
return 0;
}
+
+
+
+
+