This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[v3] C99 fixes for new "C" headers (vfscanf, etc)
- To: gcc-patches at gcc dot gnu dot org
- Subject: [v3] C99 fixes for new "C" headers (vfscanf, etc)
- From: Benjamin Kosnik <bkoz at redhat dot com>
- Date: Sun, 10 Jun 2001 15:42:54 -0700
Should get more people over the hump. I'm going to look at
std_cwchar.h next, but less people are complaining about and it might
take a bit of time, so I thought I'd get this in now since it solves
some immediate problems.
tested x86/linux
tested x86/linux x powerpc-eabism
tested powerpc/linux
This is going in on trunk and branch
2001-06-10 Benjamin Kosnik <bkoz@redhat.com>
* acinclude.m4 (GLIBCPP_ENABLE_C99): Add stdio.h checking.
Add checking for strtof, _Exit in stdlib.h
* aclocal.m4: Regenerate.
* configure.in: Regenerate.
* include/c_std/bits/std_cstdio.h: Alphabetize lists.
(snprintf): Put C99 functions into __gnu_cxx namespace.
(vfscanf): Same.
(vscanf): Same.
(vsnprintf): Same.
(vsscanf): Same.
* include/c_std/bits/std_cstdlib.h: Alphabetize lists. Put undefs
for C99 functions within _GLIBCPP_USE_C99 guard.
(_Exit): Same.
(strtof): Same.
(strtold): Same.
* include/bits/locale_facets.tcc: Check if C99 is enabled.
* include/c_std/bits/std_cwchar.h (__gnu_cxx): Put undefs within
C99 guard.
* include/c_std/bits/cmath.tcc: Formatting tweak.
* include/c_std/bits/std_cmath.h: Same.
Index: acinclude.m4
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/acinclude.m4,v
retrieving revision 1.153
diff -c -p -r1.153 acinclude.m4
*** acinclude.m4 2001/06/09 20:30:44 1.153
--- acinclude.m4 2001/06/10 22:40:24
*************** AC_DEFUN(GLIBCPP_CHECK_STDLIB_SUPPORT, [
*** 608,614 ****
ac_save_CXXFLAGS="$CXXFLAGS"
CXXFLAGS='-fno-builtins -D_GNU_SOURCE'
- AC_CHECK_FUNCS(strtof)
GLIBCPP_CHECK_STDLIB_DECL_AND_LINKAGE_2(strtold)
AC_CHECK_FUNCS(drand48)
--- 608,613 ----
*************** AC_DEFUN(GLIBCPP_ENABLE_C99, [dnl
*** 1268,1273 ****
--- 1267,1303 ----
[isunordered(0.0,0.0);],, [ac_c99_math=no])
AC_MSG_RESULT($ac_c99_math)
+ # Check for the existence in <stdio.h> of vscanf, et. al.
+ ac_c99_stdio=yes;
+ AC_MSG_CHECKING([for ISO C99 support in <stdio.h>])
+ AC_TRY_COMPILE([#include <stdio.h>],
+ [snprintf("12", 0, "%i");],, [ac_c99_stdio=no])
+ AC_TRY_COMPILE([#include <stdio.h>
+ #include <stdarg.h>
+ void foo(char* fmt, ...)
+ {va_list args; va_start(args, fmt);
+ vfscanf(stderr, "%i", args);}],
+ [],, [ac_c99_stdio=no])
+ AC_TRY_COMPILE([#include <stdio.h>
+ #include <stdarg.h>
+ void foo(char* fmt, ...)
+ {va_list args; va_start(args, fmt);
+ vscanf("%i", args);}],
+ [],, [ac_c99_stdio=no])
+ AC_TRY_COMPILE([#include <stdio.h>
+ #include <stdarg.h>
+ void foo(char* fmt, ...)
+ {va_list args; va_start(args, fmt);
+ vsnprintf(fmt, 0, "%i", args);}],
+ [],, [ac_c99_stdio=no])
+ AC_TRY_COMPILE([#include <stdio.h>
+ #include <stdarg.h>
+ void foo(char* fmt, ...)
+ {va_list args; va_start(args, fmt);
+ vsscanf(fmt, "%i", args);}],
+ [],, [ac_c99_stdio=no])
+ AC_MSG_RESULT($ac_c99_stdio)
+
# Check for the existence in <stdlib.h> of lldiv_t, et. al.
ac_c99_stdlib=yes;
AC_MSG_CHECKING([for lldiv_t declaration])
*************** AC_DEFUN(GLIBCPP_ENABLE_C99, [dnl
*** 1280,1291 ****
--- 1310,1326 ----
AC_MSG_CHECKING([for ISO C99 support in <stdlib.h>])
AC_TRY_COMPILE([#include <stdlib.h>],
+ [char* tmp; strtof("gnu", &tmp);],, [ac_c99_stdlib=no])
+ AC_TRY_COMPILE([#include <stdlib.h>],
+ [char* tmp; strtold("gnu", &tmp);],, [ac_c99_stdlib=no])
+ AC_TRY_COMPILE([#include <stdlib.h>],
[char* tmp; strtoll("gnu", &tmp, 10);],, [ac_c99_stdlib=no])
AC_TRY_COMPILE([#include <stdlib.h>],
[char* tmp; strtoull("gnu", &tmp, 10);],, [ac_c99_stdlib=no])
AC_TRY_COMPILE([#include <stdlib.h>], [llabs(10);],, [ac_c99_stdlib=no])
AC_TRY_COMPILE([#include <stdlib.h>], [lldiv(10,1);],, [ac_c99_stdlib=no])
AC_TRY_COMPILE([#include <stdlib.h>], [atoll("10");],, [ac_c99_stdlib=no])
+ AC_TRY_COMPILE([#include <stdlib.h>], [_Exit(0);],, [ac_c99_stdlib=no])
if test x"$ac_c99_lldiv_t" = x"no"; then
ac_c99_stdlib=no;
fi;
*************** AC_DEFUN(GLIBCPP_ENABLE_C99, [dnl
*** 1303,1310 ****
AC_MSG_RESULT($ac_c99_wchar)
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)
--- 1338,1346 ----
AC_MSG_RESULT($ac_c99_wchar)
AC_MSG_CHECKING([for enabled ISO C99 support])
! if test x"$ac_c99_math" = x"no" || test x"$ac_c99_stdio" = x"no" \
! || test x"$ac_c99_stdlib" = x"no" \
! || test x"$ac_c99_wchar" = x"no"; then
enable_c99=no;
fi;
AC_MSG_RESULT($enable_c99)
Index: include/bits/locale_facets.tcc
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/include/bits/locale_facets.tcc,v
retrieving revision 1.14
diff -c -p -r1.14 locale_facets.tcc
*** locale_facets.tcc 2001/05/31 12:14:53 1.14
--- locale_facets.tcc 2001/06/10 22:41:12
*************** namespace std
*** 571,577 ****
// Stage 2: convert and store results.
char* __sanity;
errno = 0;
! #ifdef _GLIBCPP_HAVE_STRTOF
float __f = strtof(__xtrc, &__sanity);
#else
float __f = static_cast<float>(strtod(__xtrc, &__sanity));
--- 571,577 ----
// Stage 2: convert and store results.
char* __sanity;
errno = 0;
! #ifdef _GLIBCPP_USE_C99
float __f = strtof(__xtrc, &__sanity);
#else
float __f = static_cast<float>(strtod(__xtrc, &__sanity));
*************** namespace std
*** 611,617 ****
return __beg;
}
! #if defined(_GLIBCPP_HAVE_STRTOLD) && !defined(__hpux)
template<typename _CharT, typename _InIter>
_InIter
num_get<_CharT, _InIter>::
--- 611,617 ----
return __beg;
}
! #if defined(_GLIBCPP_USE_C99) && !defined(__hpux)
template<typename _CharT, typename _InIter>
_InIter
num_get<_CharT, _InIter>::
Index: include/c_std/bits/cmath.tcc
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/include/c_std/bits/cmath.tcc,v
retrieving revision 1.1
diff -c -p -r1.1 cmath.tcc
*** cmath.tcc 2000/12/22 00:26:19 1.1
--- cmath.tcc 2001/06/10 22:41:13
***************
*** 32,38 ****
#ifndef _CPP_BITS_CMATH_TCC
#define _CPP_BITS_CMATH_TCC 1
! namespace std {
export template<typename _Tp>
_Tp
__cmath_power(_Tp __x, unsigned int __n)
--- 32,39 ----
#ifndef _CPP_BITS_CMATH_TCC
#define _CPP_BITS_CMATH_TCC 1
! namespace std
! {
export template<typename _Tp>
_Tp
__cmath_power(_Tp __x, unsigned int __n)
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.14
diff -c -p -r1.14 std_cmath.h
*** std_cmath.h 2001/06/08 23:22:25 1.14
--- std_cmath.h 2001/06/10 22:41:14
*************** namespace std
*** 495,501 ****
inline long double
tanh(long double __x) { return ::tanh(static_cast<double>(__x)); }
#endif
! } // std
#if _GLIBCPP_USE_C99
--- 495,501 ----
inline long double
tanh(long double __x) { return ::tanh(static_cast<double>(__x)); }
#endif
! }
#if _GLIBCPP_USE_C99
*************** namespace __gnu_cxx
*** 556,562 ****
int
__capture_isunordered(_Tp __f1, _Tp __f2)
{ return isunordered(__f1, __f2); }
! } // namespace __gnu_cxx
#endif
#undef fpclassify
--- 556,562 ----
int
__capture_isunordered(_Tp __f1, _Tp __f2)
{ return isunordered(__f1, __f2); }
! }
#endif
#undef fpclassify
*************** namespace std
*** 651,653 ****
--- 651,656 ----
#endif
#endif
+
+
+
Index: include/c_std/bits/std_cstdio.h
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/include/c_std/bits/std_cstdio.h,v
retrieving revision 1.12
diff -c -p -r1.12 std_cstdio.h
*** std_cstdio.h 2001/06/10 07:42:25 1.12
--- std_cstdio.h 2001/06/10 22:41:14
***************
*** 34,139 ****
#ifndef _CPP_CSTDIO
#define _CPP_CSTDIO 1
#include <bits/std_cstddef.h>
#pragma GCC system_header
#include_next <stdio.h>
// Get rid of those macros defined in <stdio.h> in lieu of real functions.
! #undef remove
! #undef rename
! #undef tmpfile
! #undef tmpnam
#undef fclose
#undef fflush
- #undef fopen
- #undef freopen
- #undef setbuf
- #undef setvbuf
- #undef fprintf
- #undef fscanf
- #undef printf
- #undef scanf
- #undef sprintf
- #undef sscanf
- #undef vfprintf
- #undef vfscanf
- #undef vprintf
- #undef vscanf
- #undef vsprintf
- #undef vsscanf
#undef fgetc
#undef fgets
#undef fputc
#undef fputs
#undef getc
#undef getchar
#undef gets
#undef putc
#undef putchar
#undef puts
! #undef ungetc
! #undef fread
! #undef fwrite
! #undef fgetpos
! #undef fseek
! #undef fsetpos
! #undef ftell
#undef rewind
! #undef clearerr
! #undef feof
! #undef ferror
! #undef perror
namespace std
{
using ::FILE;
using ::fpos_t;
! using ::remove;
! using ::rename;
! using ::tmpfile;
! using ::tmpnam;
using ::fclose;
using ::fflush;
- using ::fopen;
- using ::freopen;
- using ::setbuf;
- using ::setvbuf;
- using ::fprintf;
- using ::fscanf;
- using ::printf;
- using ::scanf;
- using ::sprintf;
- using ::sscanf;
- using ::vfprintf;
- using ::vfscanf;
- using ::vprintf;
- using ::vscanf;
- using ::vsprintf;
- using ::vsscanf;
using ::fgetc;
using ::fgets;
using ::fputc;
using ::fputs;
using ::getc;
using ::getchar;
using ::gets;
using ::putc;
using ::putchar;
using ::puts;
! using ::ungetc;
! using ::fread;
! using ::fwrite;
! using ::fgetpos;
! using ::fseek;
! using ::fsetpos;
! using ::ftell;
using ::rewind;
! using ::clearerr;
! using ::feof;
! using ::ferror;
! using ::perror;
}
#endif
--- 34,161 ----
#ifndef _CPP_CSTDIO
#define _CPP_CSTDIO 1
+ #include <bits/c++config.h>
#include <bits/std_cstddef.h>
#pragma GCC system_header
#include_next <stdio.h>
// Get rid of those macros defined in <stdio.h> in lieu of real functions.
! #undef clearerr
#undef fclose
+ #undef feof
+ #undef ferror
#undef fflush
#undef fgetc
+ #undef fgetpos
#undef fgets
+ #undef fopen
+ #undef fprintf
#undef fputc
#undef fputs
+ #undef fread
+ #undef freopen
+ #undef fscanf
+ #undef fseek
+ #undef fsetpos
+ #undef ftell
+ #undef fwrite
#undef getc
#undef getchar
#undef gets
+ #undef perror
+ #undef printf
#undef putc
#undef putchar
#undef puts
! #undef remove
! #undef rename
#undef rewind
! #undef scanf
! #undef setbuf
! #undef setvbuf
! #undef sprintf
! #undef sscanf
! #undef tmpfile
! #undef tmpnam
! #undef ungetc
! #undef vfprintf
! #undef vprintf
! #undef vsprintf
namespace std
{
using ::FILE;
using ::fpos_t;
! using ::clearerr;
using ::fclose;
+ using ::feof;
+ using ::ferror;
using ::fflush;
using ::fgetc;
+ using ::fgetpos;
using ::fgets;
+ using ::fopen;
+ using ::fprintf;
using ::fputc;
using ::fputs;
+ using ::fread;
+ using ::freopen;
+ using ::fscanf;
+ using ::fseek;
+ using ::fsetpos;
+ using ::ftell;
+ using ::fwrite;
using ::getc;
using ::getchar;
using ::gets;
+ using ::perror;
+ using ::printf;
using ::putc;
using ::putchar;
using ::puts;
! using ::remove;
! using ::rename;
using ::rewind;
! using ::scanf;
! using ::setbuf;
! using ::setvbuf;
! using ::sprintf;
! using ::sscanf;
! using ::tmpfile;
! using ::tmpnam;
! using ::ungetc;
! using ::vfprintf;
! using ::vprintf;
! using ::vsprintf;
! }
!
! #if _GLIBCPP_USE_C99
!
! #undef snprintf
! #undef vfscanf
! #undef vscanf
! #undef vsnprintf
! #undef vsscanf
!
! namespace __gnu_cxx
! {
! using ::snprintf;
! using ::vfscanf;
! using ::vscanf;
! using ::vsnprintf;
! using ::vsscanf;
! }
!
! namespace std
! {
! using __gnu_cxx::snprintf;
! using __gnu_cxx::vfscanf;
! using __gnu_cxx::vscanf;
! using __gnu_cxx::vsnprintf;
! using __gnu_cxx::vsscanf;
}
+ #endif
#endif
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.15
diff -c -p -r1.15 std_cstdlib.h
*** std_cstdlib.h 2001/06/09 18:53:35 1.15
--- std_cstdlib.h 2001/06/10 22:41:14
***************
*** 41,132 ****
#include_next <stdlib.h>
// Get rid of those macros defined in <stdlib.h> in lieu of real functions.
#undef atof
#undef atoi
#undef atol
! #undef strtod
! #undef strtof
! #undef strtol
! #undef strtoul
! #undef rand
! #undef srand
#undef calloc
! #undef free
! #undef malloc
! #undef realloc
! #undef abort
! #undef atexit
#undef exit
! //#undef _Exit
#undef getenv
- #undef system
- #undef bsearch
- #undef qsort
- #undef abs
#undef labs
- #undef llabs
- #undef div
#undef ldiv
! #undef lldiv
#undef mblen
- #undef mbtowc
- #undef wctomb
#undef mbstowcs
#undef wcstombs
! #undef atoll
! #undef strtoll
! #undef strtoull
! #undef strtold
namespace std
{
using ::div_t;
using ::ldiv_t;
using ::atof;
using ::atoi;
using ::atol;
! using ::strtod;
! #if _GLIBCPP_HAVE_STRTOF
! using ::strtof;
! #endif
! using ::strtol;
! using ::strtoul;
! using ::rand;
! using ::srand;
using ::calloc;
! using ::free;
! using ::malloc;
! using ::realloc;
! using ::abort;
! using ::atexit;
using ::exit;
! // using ::_Exit;
using ::getenv;
- using ::system;
- using ::bsearch;
- using ::qsort;
- using ::abs;
using ::labs;
- using ::div;
using ::ldiv;
using ::mblen;
- using ::mbtowc;
- using ::wctomb;
using ::mbstowcs;
using ::wcstombs;
inline long
abs(long __i) { return labs(__i); }
inline ldiv_t
div(long __i, long __j) { return ldiv(__i, __j); }
! } // namespace std
#if _GLIBCPP_USE_C99
namespace __gnu_cxx
{
using ::lldiv_t;
inline long long
abs(long long __x) { return __x >= 0 ? __x : -__x; }
--- 41,131 ----
#include_next <stdlib.h>
// Get rid of those macros defined in <stdlib.h> in lieu of real functions.
+ #undef abort
+ #undef abs
+ #undef atexit
#undef atof
#undef atoi
#undef atol
! #undef bsearch
#undef calloc
! #undef div
#undef exit
! #undef free
#undef getenv
#undef labs
#undef ldiv
! #undef malloc
#undef mblen
#undef mbstowcs
+ #undef mbtowc
+ #undef qsort
+ #undef rand
+ #undef realloc
+ #undef srand
+ #undef strtod
+ #undef strtol
+ #undef strtoul
+ #undef system
#undef wcstombs
! #undef wctomb
namespace std
{
using ::div_t;
using ::ldiv_t;
+ using ::abort;
+ using ::abs;
+ using ::atexit;
using ::atof;
using ::atoi;
using ::atol;
! using ::bsearch;
using ::calloc;
! using ::div;
using ::exit;
! using ::free;
using ::getenv;
using ::labs;
using ::ldiv;
+ using ::malloc;
using ::mblen;
using ::mbstowcs;
+ using ::mbtowc;
+ using ::qsort;
+ using ::rand;
+ using ::realloc;
+ using ::srand;
+ using ::strtod;
+ using ::strtol;
+ using ::strtoul;
+ using ::system;
using ::wcstombs;
+ using ::wctomb;
inline long
abs(long __i) { return labs(__i); }
inline ldiv_t
div(long __i, long __j) { return ldiv(__i, __j); }
! }
#if _GLIBCPP_USE_C99
+
+ #undef _Exit
+ #undef llabs
+ #undef lldiv
+ #undef atoll
+ #undef strtoll
+ #undef strtoull
+ #undef strtof
+ #undef strtold
+
namespace __gnu_cxx
{
using ::lldiv_t;
+ using ::_Exit;
inline long long
abs(long long __x) { return __x >= 0 ? __x : -__x; }
*************** namespace __gnu_cxx
*** 143,169 ****
{ lldiv_t __q; __q.quot = __n / __d; __q.rem = __n % __d; return __q; }
using ::atoll;
using ::strtoll;
using ::strtoull;
-
- #ifdef _GLIBCPP_HAVE_STRTOLD
using ::strtold;
! #endif
! } // namespace __gnu_cxx
namespace std
{
using __gnu_cxx::lldiv_t;
using __gnu_cxx::abs;
using __gnu_cxx::llabs;
using __gnu_cxx::div;
using __gnu_cxx::lldiv;
using __gnu_cxx::atoll;
using __gnu_cxx::strtoll;
using __gnu_cxx::strtoull;
- #ifdef _GLIBCPP_HAVE_STRTOLD
using __gnu_cxx::strtold;
- #endif
}
#endif
--- 142,166 ----
{ 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;
using __gnu_cxx::strtoull;
using __gnu_cxx::strtold;
}
#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.14
diff -c -p -r1.14 std_cwchar.h
*** std_cwchar.h 2001/06/09 18:53:35 1.14
--- std_cwchar.h 2001/06/10 22:41:14
*************** namespace std
*** 112,118 ****
#undef wmemmove
#undef wmemset
#undef wcsftime
-
#undef wcschr
#undef wcspbrk
#undef wcsrchr
--- 112,117 ----
*************** namespace std
*** 212,217 ****
--- 211,221 ----
}
#if _GLIBCPP_USE_C99
+
+ #undef wcstold
+ #undef wcstoll
+ #undef wcstoull
+
namespace __gnu_cxx
{
using ::wcstold;