[Patch, libfortran] PR 47431 Thread-safe ctime/fdate intrinsics

Janne Blomqvist blomqvist.janne@gmail.com
Thu Jan 27 22:42:00 GMT 2011

On Thu, Jan 27, 2011 at 20:53, Tobias Burnus <burnus@net-b.de> wrote:
> On 01/25/2011 07:16 PM, Janne Blomqvist wrote:
>> the attached patch makes the ctime and fdate intrinsics thread-safe by
>> using ctime_r() if available.
>> Regtested on x86_64-unknown-linux-gnu, Ok for trunk?
> OK. Thanks for the patch. Do not forget the follow up bit of the patch.

Thanks. Committed, with the additional patch on top (not the
s/int/size_t/ thing which I fixed in the ttyname_r() patch, thanks for

diff --git a/libgfortran/intrinsics/ctime.c b/libgfortran/intrinsics/ctime.c
index 5aae95f..2729616 100644
--- a/libgfortran/intrinsics/ctime.c
+++ b/libgfortran/intrinsics/ctime.c
@@ -45,7 +45,11 @@ see the files COPYING3 and COPYING.RUNTIME
respectively.  If not, see
 static char *
 ctime_r (const time_t * timep, char * buf __attribute__((unused)))
+#ifdef HAVE_CTIME
   return ctime (timep);
+  return NULL;

(Not that I expect HAVE_CTIME will ever be false, since it's part of C89).

Sending        libgfortran/ChangeLog
Sending        libgfortran/config.h.in
Sending        libgfortran/configure
Sending        libgfortran/configure.ac
Sending        libgfortran/intrinsics/ctime.c
Transmitting file data .....
Committed revision 169338.

> Tobias
> PS: I think PR 47491 and PR 47375 can be closed as fixed.

Yes, done.

Janne Blomqvist

More information about the Gcc-patches mailing list