PATCH (libstdc++-v3, mainline & 3.3): Remaining C99 header visibility
Loren James Rittle
rittle@latour.rsch.comm.mot.com
Fri Apr 18 10:11:00 GMT 2003
Here is the last of the visibility hooks required for the new C99
support in FreeBSD 5 and the fact that is it disabled under many
options and defines (no extra test cases, because 100s of test cases
fail without this patch). I will now look for PRs about other systems
that may profit. Please advise me via the libstdc++ list or a PR, if
you think your port may need this (usual symptom: program compiles
fine with no special options or defines but fails with -ansi, -posix,
-D_XOPEN_SOURCE, etc.). Or, better yet, attempt to follow the new
guidance in libstdc++/docs/html/17_intro/porting.texi. Port
maintainers for various OSes may just drop the new macros into
config/os/<target>/os_defines.h after you test it yourself.
Tested with full rebuild/check cycle in each case:
i686-unknown-freebsd4.8 (no C99 support, mainline)
alpha-unknown-freebsd5.0 (post C99 update, 3.3 branch)
i386-unknown-freebsd5.0 (post C99 update, mainline)
i386-unknown-freebsd4.8 (no C99 support, 3.3 branch)
A similar form of this patch has been on the aforementioned machines
for a week. It clones the work already done to cmath. Applied to
mainline and 3.3 branch (the root bug is that -ansi and many other
command line switches and defines may not be provided against programs
that use the standard C++ header). - Loren
* docs/html/17_intro/porting.texi (_GLIBCPP_USE_C99_CHECK): New macro.
(_GLIBCPP_USE_C99_DYNAMIC): New macro.
(_GLIBCPP_USE_C99_LONG_LONG_CHECK): New macro.
(_GLIBCPP_USE_C99_LONG_LONG_DYNAMIC): New macro.
* config/os/bsd/freebsd/os_defines.h (_GLIBCPP_USE_C99_CHECK):
New macro.
(_GLIBCPP_USE_C99_DYNAMIC): New macro.
(_GLIBCPP_USE_C99_LONG_LONG_CHECK): New macro.
(_GLIBCPP_USE_C99_LONG_LONG_DYNAMIC): New macro.
* include/c_std/std_cstdlib.h: Use new macros.
* include/c_std/std_cstdio.h: Use new macros.
* include/c_std/std_cwchar.h: Use new macros.
Index: docs/html/17_intro/porting.texi
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/docs/html/17_intro/porting.texi,v
retrieving revision 1.10
diff -c -r1.10 porting.texi
*** docs/html/17_intro/porting.texi 15 Apr 2003 07:27:54 -0000 1.10
--- docs/html/17_intro/porting.texi 18 Apr 2003 08:38:12 -0000
***************
*** 156,161 ****
--- 156,183 ----
useful since libio support isn't currently working and the g++ v3 ABI
invalidates the assumption that some ports don't use thunks).
+ @code{_GLIBCPP_USE_C99_CHECK} may be defined to 1 to check C99
+ function declarations (which are not covered by specialization below)
+ found in system headers against versions found in the library headers
+ derived from the standard.
+
+ @code{_GLIBCPP_USE_C99_DYNAMIC} may be defined to an expression that
+ yields 0 if and only if the system headers are exposing proper support
+ for C99 functions (which are not covered by specialization below). If
+ defined, it must be 0 while bootstrapping the compiler/rebuilding the
+ library.
+
+ @code{_GLIBCPP_USE_C99_LONG_LONG_CHECK} may be defined to 1 to check
+ the set of C99 long long function declarations found in system headers
+ against versions found in the library headers derived from the
+ standard.
+
+ @code{_GLIBCPP_USE_C99_LONG_LONG_DYNAMIC} may be defined to an
+ expression that yields 0 if and only if the system headers are
+ exposing proper support for the set of C99 long long functions. If
+ defined, it must be 0 while bootstrapping the compiler/rebuilding the
+ library.
+
@code{_GLIBCPP_USE_C99_FP_MACROS_DYNAMIC} may be defined to an
expression that yields 0 if and only if the system headers
are exposing proper support for the related set of macros. If defined,
Index: config/os/bsd/freebsd/os_defines.h
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/config/os/bsd/freebsd/os_defines.h,v
retrieving revision 1.3
diff -c -r1.3 os_defines.h
*** config/os/bsd/freebsd/os_defines.h 15 Apr 2003 07:27:54 -0000 1.3
--- config/os/bsd/freebsd/os_defines.h 18 Apr 2003 09:48:21 -0000
***************
*** 34,39 ****
--- 34,43 ----
// System-specific #define, typedefs, corrections, etc, go here. This
// file will come before all others.
+ #define _GLIBCPP_USE_C99_CHECK 1
+ #define _GLIBCPP_USE_C99_DYNAMIC (!(__ISO_C_VISIBLE >= 1999))
+ #define _GLIBCPP_USE_C99_LONG_LONG_CHECK 1
+ #define _GLIBCPP_USE_C99_LONG_LONG_DYNAMIC (_GLIBCPP_USE_C99_DYNAMIC || !defined __LONG_LONG_SUPPORTED)
#define _GLIBCPP_USE_C99_FLOAT_TRANSCENDENTALS_CHECK 1
#define _GLIBCPP_USE_C99_FLOAT_TRANSCENDENTALS_DYNAMIC defined _XOPEN_SOURCE
Index: include/c_std/std_cstdlib.h
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/include/c_std/std_cstdlib.h,v
retrieving revision 1.4
diff -c -r1.4 std_cstdlib.h
*** include/c_std/std_cstdlib.h 27 Mar 2002 04:29:32 -0000 1.4
--- include/c_std/std_cstdlib.h 18 Apr 2003 08:38:12 -0000
***************
*** 1,6 ****
// -*- C++ -*- forwarding header.
! // Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002
// Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
--- 1,6 ----
// -*- C++ -*- forwarding header.
! // Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003
// Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
***************
*** 135,142 ****
--- 135,149 ----
namespace __gnu_cxx
{
+ #if !_GLIBCPP_USE_C99_LONG_LONG_DYNAMIC
using ::lldiv_t;
+ #endif
+ #if _GLIBCPP_USE_C99_CHECK || _GLIBCPP_USE_C99_DYNAMIC
+ extern "C" void (_Exit)(int);
+ #endif
+ #if !_GLIBCPP_USE_C99_DYNAMIC
using ::_Exit;
+ #endif
inline long long
abs(long long __x) { return __x >= 0 ? __x : -__x; }
***************
*** 144,149 ****
--- 151,157 ----
inline long long
llabs(long long __x) { return __x >= 0 ? __x : -__x; }
+ #if !_GLIBCPP_USE_C99_LONG_LONG_DYNAMIC
inline lldiv_t
div(long long __n, long long __d)
{ lldiv_t __q; __q.quot = __n / __d; __q.rem = __n % __d; return __q; }
***************
*** 151,172 ****
inline lldiv_t
lldiv(long long __n, long long __d)
{ lldiv_t __q; __q.quot = __n / __d; __q.rem = __n % __d; return __q; }
using ::atoll;
- using ::strtof;
using ::strtoll;
using ::strtoull;
using ::strtold;
}
namespace std
{
using __gnu_cxx::lldiv_t;
using __gnu_cxx::_Exit;
using __gnu_cxx::abs;
using __gnu_cxx::llabs;
using __gnu_cxx::div;
using __gnu_cxx::lldiv;
using __gnu_cxx::atoll;
using __gnu_cxx::strtof;
using __gnu_cxx::strtoll;
--- 159,194 ----
inline lldiv_t
lldiv(long long __n, long long __d)
{ lldiv_t __q; __q.quot = __n / __d; __q.rem = __n % __d; return __q; }
+ #endif
+ #if _GLIBCPP_USE_C99_LONG_LONG_CHECK || _GLIBCPP_USE_C99_LONG_LONG_DYNAMIC
+ extern "C" long long int (atoll)(const char *);
+ extern "C" long long int
+ (strtoll)(const char * restrict, char ** restrict, int);
+ extern "C" unsigned long long int
+ (strtoull)(const char * restrict, char ** restrict, int);
+ #endif
+ #if !_GLIBCPP_USE_C99_LONG_LONG_DYNAMIC
using ::atoll;
using ::strtoll;
using ::strtoull;
+ #endif
+ using ::strtof;
using ::strtold;
}
namespace std
{
+ #if !_GLIBCPP_USE_C99_LONG_LONG_DYNAMIC
using __gnu_cxx::lldiv_t;
+ #endif
using __gnu_cxx::_Exit;
using __gnu_cxx::abs;
using __gnu_cxx::llabs;
+ #if !_GLIBCPP_USE_C99_LONG_LONG_DYNAMIC
using __gnu_cxx::div;
using __gnu_cxx::lldiv;
+ #endif
using __gnu_cxx::atoll;
using __gnu_cxx::strtof;
using __gnu_cxx::strtoll;
Index: include/c_std/std_cstdio.h
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/include/c_std/std_cstdio.h,v
retrieving revision 1.4
diff -c -r1.4 std_cstdio.h
*** include/c_std/std_cstdio.h 27 Mar 2002 04:29:32 -0000 1.4
--- include/c_std/std_cstdio.h 18 Apr 2003 08:38:12 -0000
***************
*** 1,6 ****
// -*- C++ -*- forwarding header.
! // Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002
// Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
--- 1,6 ----
// -*- C++ -*- forwarding header.
! // Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003
// Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
***************
*** 152,162 ****
--- 152,175 ----
namespace __gnu_cxx
{
+ #if _GLIBCPP_USE_C99_CHECK || _GLIBCPP_USE_C99_DYNAMIC
+ extern "C" int
+ (snprintf)(char * restrict, size_t, const char * restrict, ...);
+ extern "C" int
+ (vfscanf)(FILE * restrict, const char * restrict, __gnuc_va_list);
+ extern "C" int (vscanf)(const char * restrict, __gnuc_va_list);
+ extern "C" int
+ (vsnprintf)(char * restrict, size_t, const char * restrict, __gnuc_va_list);
+ extern "C" int
+ (vsscanf)(const char * restrict, const char * restrict, __gnuc_va_list);
+ #endif
+ #if !_GLIBCPP_USE_C99_DYNAMIC
using ::snprintf;
using ::vfscanf;
using ::vscanf;
using ::vsnprintf;
using ::vsscanf;
+ #endif
}
namespace std
Index: include/c_std/std_cwchar.h
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/include/c_std/std_cwchar.h,v
retrieving revision 1.4
diff -c -r1.4 std_cwchar.h
*** include/c_std/std_cwchar.h 27 Mar 2002 04:29:32 -0000 1.4
--- include/c_std/std_cwchar.h 18 Apr 2003 08:38:12 -0000
***************
*** 1,6 ****
// -*- C++ -*- forwarding header.
! // Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002
// Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
--- 1,6 ----
// -*- C++ -*- forwarding header.
! // Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003
// Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
***************
*** 225,233 ****
--- 225,247 ----
namespace __gnu_cxx
{
+ #if _GLIBCPP_USE_C99_CHECK || _GLIBCPP_USE_C99_DYNAMIC
+ extern "C" long double
+ (wcstold)(const wchar_t * restrict, wchar_t ** restrict);
+ #endif
+ #if !_GLIBCPP_USE_C99_DYNAMIC
using ::wcstold;
+ #endif
+ #if _GLIBCPP_USE_C99_LONG_LONG_CHECK || _GLIBCPP_USE_C99_LONG_LONG_DYNAMIC
+ extern "C" long long int
+ (wcstoll)(const wchar_t * restrict, wchar_t ** restrict, int);
+ extern "C" unsigned long long int
+ (wcstoull)(const wchar_t * restrict, wchar_t ** restrict, int);
+ #endif
+ #if !_GLIBCPP_USE_C99_LONG_LONG_DYNAMIC
using ::wcstoll;
using ::wcstoull;
+ #endif
}
namespace std
More information about the Libstdc++
mailing list