From 9e09cd236ce2be94ed828668c2925a25ce81616d Mon Sep 17 00:00:00 2001 From: ktietz Date: Mon, 8 Mar 2010 08:01:55 +0000 Subject: [PATCH] 2010-03-08 Kai TIetz PR/42950 * libgfortran.h (_POSIX): Define if __MINGW32__ is defined. (gfc_printf): Define to gnu_printf for __MINGW32__ case, otherwise to __printf__. (gfc_strtof,gfc_strtod,gfc_strtold): Define for mingw case to POSIX compatible converter functions. (runtime_error): Use instead gfc_printf as formatter attribute name. (runtime_error_at): Likewise. (runtime_warning_at): Likewise. (st_printf): Likewise. * intrinsics/date_and_time.c (localtime_r): Undefine possible defined macro. (gmtime_r): Likewise. * io/read.c (convert_real): Use gfc_strtof, gfc_strtod, and gfc_strtold. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@157271 138bc75d-0d04-0410-961f-82ee72b054a4 --- libgfortran/ChangeLog | 19 +++++++++++++++++++ libgfortran/intrinsics/date_and_time.c | 10 ++++++++++ libgfortran/io/read.c | 10 +++++----- libgfortran/libgfortran.h | 30 ++++++++++++++++++++++++++---- 4 files changed, 60 insertions(+), 9 deletions(-) diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog index 2eadbba61d4..bed26b90cfe 100644 --- a/libgfortran/ChangeLog +++ b/libgfortran/ChangeLog @@ -1,3 +1,22 @@ +2010-03-08 Kai TIetz + + PR/42950 + * libgfortran.h (_POSIX): Define if __MINGW32__ is defined. + (gfc_printf): Define to gnu_printf for __MINGW32__ case, + otherwise to __printf__. + (gfc_strtof,gfc_strtod,gfc_strtold): Define for mingw case + to POSIX compatible converter functions. + (runtime_error): Use instead gfc_printf as formatter + attribute name. + (runtime_error_at): Likewise. + (runtime_warning_at): Likewise. + (st_printf): Likewise. + * intrinsics/date_and_time.c (localtime_r): Undefine + possible defined macro. + (gmtime_r): Likewise. + * io/read.c (convert_real): Use gfc_strtof, gfc_strtod, + and gfc_strtold. + 2010-02-24 Jerry DeLisle PR libfortran/43155 diff --git a/libgfortran/intrinsics/date_and_time.c b/libgfortran/intrinsics/date_and_time.c index 4bc6e6928c0..a3f39a76d5b 100644 --- a/libgfortran/intrinsics/date_and_time.c +++ b/libgfortran/intrinsics/date_and_time.c @@ -55,6 +55,11 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see thread-local storage so they are threadsafe. */ #ifndef HAVE_LOCALTIME_R +/* If _POSIX is defined localtime_r gets defined by mingw-w64 headers. */ +#ifdef localtime_r +#undef localtime_r +#endif + static struct tm * localtime_r (const time_t * timep, struct tm * result) { @@ -64,6 +69,11 @@ localtime_r (const time_t * timep, struct tm * result) #endif #ifndef HAVE_GMTIME_R +/* If _POSIX is defined gmtime_r gets defined by mingw-w64 headers. */ +#ifdef gmtime_r +#undef gmtime_r +#endif + static struct tm * gmtime_r (const time_t * timep, struct tm * result) { diff --git a/libgfortran/io/read.c b/libgfortran/io/read.c index 03046b943b9..43f4b76b580 100644 --- a/libgfortran/io/read.c +++ b/libgfortran/io/read.c @@ -144,25 +144,25 @@ convert_real (st_parameter_dt *dtp, void *dest, const char *buffer, int length) case 4: *((GFC_REAL_4*) dest) = #if defined(HAVE_STRTOF) - strtof (buffer, NULL); + gfc_strtof (buffer, NULL); #else - (GFC_REAL_4) strtod (buffer, NULL); + (GFC_REAL_4) gfc_strtod (buffer, NULL); #endif break; case 8: - *((GFC_REAL_8*) dest) = strtod (buffer, NULL); + *((GFC_REAL_8*) dest) = gfc_strtod (buffer, NULL); break; #if defined(HAVE_GFC_REAL_10) && defined (HAVE_STRTOLD) case 10: - *((GFC_REAL_10*) dest) = strtold (buffer, NULL); + *((GFC_REAL_10*) dest) = gfc_strtold (buffer, NULL); break; #endif #if defined(HAVE_GFC_REAL_16) && defined (HAVE_STRTOLD) case 16: - *((GFC_REAL_16*) dest) = strtold (buffer, NULL); + *((GFC_REAL_16*) dest) = gfc_strtold (buffer, NULL); break; #endif diff --git a/libgfortran/libgfortran.h b/libgfortran/libgfortran.h index dd63fa4e616..8d1fa4dfec1 100644 --- a/libgfortran/libgfortran.h +++ b/libgfortran/libgfortran.h @@ -28,6 +28,15 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #ifndef LIBGFOR_H #define LIBGFOR_H +/* Ensure that ANSI conform stdio is used. This needs to be set before + any system header file is included. */ +#if defined __MINGW32__ +# define _POSIX 1 +# define gfc_printf gnu_printf +#else +# define gfc_printf __printf__ +#endif + /* config.h MUST be first because it can affect system headers. */ #include "config.h" @@ -37,6 +46,19 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #include #include +#ifdef __MINGW32__ +extern float __strtof (const char *, char **); +#define gfc_strtof __strtof +extern double __strtod (const char *, char **); +#define gfc_strtod __strtod +extern long double __strtold (const char *, char **); +#define gfc_strtold __strtold +#else +#define gfc_strtof strtof +#define gfc_strtod strtod +#define gfc_strtold strtold +#endif + #if HAVE_COMPLEX_H # include #else @@ -703,15 +725,15 @@ extern void show_locus (st_parameter_common *); internal_proto(show_locus); extern void runtime_error (const char *, ...) - __attribute__ ((noreturn, format (printf, 1, 2))); + __attribute__ ((noreturn, format (gfc_printf, 1, 2))); iexport_proto(runtime_error); extern void runtime_error_at (const char *, const char *, ...) - __attribute__ ((noreturn, format (printf, 2, 3))); + __attribute__ ((noreturn, format (gfc_printf, 2, 3))); iexport_proto(runtime_error_at); extern void runtime_warning_at (const char *, const char *, ...) - __attribute__ ((format (printf, 2, 3))); + __attribute__ ((format (gfc_printf, 2, 3))); iexport_proto(runtime_warning_at); extern void internal_error (st_parameter_common *, const char *) @@ -795,7 +817,7 @@ extern int unit_to_fd (int); internal_proto(unit_to_fd); extern int st_printf (const char *, ...) - __attribute__ ((format (printf, 1, 2))); + __attribute__ ((format (gfc_printf, 1, 2))); internal_proto(st_printf); extern int st_vprintf (const char *, va_list); -- 2.11.0