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

login
register
mail settings
Submitter Janne Blomqvist
Date Jan. 27, 2011, 8:23 p.m.
Message ID <AANLkTi=GyEyoP6LqtjWivWzgGcX4FYb1fFzCZYi=HO4R@mail.gmail.com>
Download mbox | patch
Permalink /patch/80731/
State New
Headers show

Comments

Janne Blomqvist - Jan. 27, 2011, 8:23 p.m.
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
reminding):



(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.

Patch

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);
+#else
+  return NULL;
+#endif
 }
 #endif