+2011-01-27 Janne Blomqvist <jb@gcc.gnu.org>
+
+ PR libfortran/47431
+ * config.h.in: Regenerated.
+ * configure: Regenerated.
+ * configure.ac: Add check for ctime_r().
+ * intrinsics/ctime.c (ctime_r): Fallback implementation.
+ (fdate): Use ctime_r() instead of ctime().
+ (fdate_sub): Likewise.
+ (ctime): Likewise.
+ (ctime_sub): Likewise.
+
2011-01-27 Janne Blomqvist <jb@gcc.gnu.org>
PR libfortran/47432
AC_CHECK_FUNCS(sleep time ttyname signal alarm ctime clock access fork execl)
AC_CHECK_FUNCS(wait setmode execvp pipe dup2 close fdopen strcasestr getrlimit)
AC_CHECK_FUNCS(gettimeofday stat fstat lstat getpwuid vsnprintf dup getcwd)
-AC_CHECK_FUNCS(localtime_r gmtime_r strerror_r getpwuid_r ttyname_r)
+AC_CHECK_FUNCS(localtime_r gmtime_r strerror_r getpwuid_r ttyname_r ctime_r)
# Check for glibc backtrace functions
AC_CHECK_FUNCS(backtrace backtrace_symbols)
/* Implementation of the CTIME and FDATE g77 intrinsics.
- Copyright (C) 2005, 2007, 2009 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2007, 2009, 2011 Free Software Foundation, Inc.
Contributed by François-Xavier Coudert <coudert@clipper.ens.fr>
-This file is part of the GNU Fortran 95 runtime library (libgfortran).
+This file is part of the GNU Fortran runtime library (libgfortran).
Libgfortran is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
#include <string.h>
+#ifndef HAVE_CTIME_R
+static char *
+ctime_r (const time_t * timep, char * buf __attribute__((unused)))
+{
+#ifdef HAVE_CTIME
+ return ctime (timep);
+#else
+ return NULL;
+#endif
+}
+#endif
+
+/* ctime_r() buffer size needs to be at least 26 bytes. */
+#define CSZ 26
+
extern void fdate (char **, gfc_charlen_type *);
export_proto(fdate);
fdate (char ** date, gfc_charlen_type * date_len)
{
#if defined(HAVE_TIME) && defined(HAVE_CTIME)
+ char cbuf[CSZ];
int i;
time_t now = time(NULL);
- *date = ctime (&now);
+ *date = ctime_r (&now, cbuf);
if (*date != NULL)
{
*date = strdup (*date);
fdate_sub (char * date, gfc_charlen_type date_len)
{
#if defined(HAVE_TIME) && defined(HAVE_CTIME)
+ char cbuf[CSZ];
int i;
char *d;
time_t now = time(NULL);
memset (date, ' ', date_len);
#if defined(HAVE_TIME) && defined(HAVE_CTIME)
- d = ctime (&now);
+ d = ctime_r (&now, cbuf);
if (d != NULL)
{
i = 0;
PREFIX(ctime) (char ** date, gfc_charlen_type * date_len, GFC_INTEGER_8 t)
{
#if defined(HAVE_CTIME)
+ char cbuf[CSZ];
time_t now = t;
int i;
- *date = ctime (&now);
+ *date = ctime_r (&now, cbuf);
if (*date != NULL)
{
*date = strdup (*date);
ctime_sub (GFC_INTEGER_8 * t, char * date, gfc_charlen_type date_len)
{
#if defined(HAVE_CTIME)
+ char cbuf[CSZ];
int i;
char *d;
time_t now = *t;
memset (date, ' ', date_len);
#if defined(HAVE_CTIME)
- d = ctime (&now);
+ d = ctime_r (&now, cbuf);
if (d != NULL)
{
i = 0;