develooper Front page | perl.perl5.porters | Postings from July 2001

[PATCH] Use reentrant API glibc

From:
Artur Bergman
Date:
July 11, 2001 15:58
Subject:
[PATCH] Use reentrant API glibc
Message ID:
B772A6AD.2288%artur@contiller.se
Following is a patch that starts with support for ./Configure -Dusereentrant
and USE_REENTRANT_API. It starts by making gmtime() and localtime() use
localtime_r and gmtime_r.

All tests pass, tested on a dual linux cpu and seems to work.

Whee, maybe we can end up by saying that 5.8 doesn't have any known ithread
bugs. (And if you know of one, do speak!)

Artur

--- perl-copy/sv.c    Wed Jul 11 22:50:52 2001
+++ perl/sv.c    Wed Jul 11 23:36:20 2001
@@ -9589,6 +9589,11 @@
 
     PL_debug            = proto_perl->Idebug;
 
+#ifdef USE_REENTRANT_API
+    New(31337, PL_reentrant_buffer,1, REBUF);
+    New(31337, PL_reentrant_buffer->tmbuff,1, struct tm);
+#endif
+
     /* create SV map for pointer relocation */
     PL_ptr_table = ptr_table_new();
 
--- perl-copy/op.h    Wed Jul 11 22:50:52 2001
+++ perl/op.h    Wed Jul 11 23:16:37 2001
@@ -456,3 +456,12 @@
 #define PERL_LOADMOD_DENY               0x1
 #define PERL_LOADMOD_NOIMPORT           0x2
 #define PERL_LOADMOD_IMPORT_OPS         0x4
+
+#ifdef USE_REENTRANT_API
+typedef struct {
+  struct tm* tmbuff;
+} REBUF;
+#define localtime(a)       localtime_r(a,PL_reentrant_buffer->tmbuff)
+#define gmtime(a)          gmtime_r(a,PL_reentrant_buffer->tmbuff)
+#endif
+
--- perl-copy/perl.c    Wed Jul 11 22:50:52 2001
+++ perl/perl.c    Wed Jul 11 23:51:31 2001
@@ -315,6 +315,10 @@
 #ifdef USE_ITHREADS
         PL_regex_padav = newAV();
 #endif
+#ifdef USE_REENTRANT_API
+    New(31337, PL_reentrant_buffer,1, REBUF);
+    New(31337, PL_reentrant_buffer->tmbuff,1, struct tm);
+#endif
     ENTER;
 }
 
@@ -806,6 +810,11 @@
     Safefree(PL_thrsv);
     PL_thrsv = Nullsv;
 #endif /* USE_THREADS */
+
+#ifdef USE_REENTRANT_API
+    Safefree(PL_reentrant_buffer->tmbuff);
+    Safefree(PL_reentrant_buffer);
+#endif
 
     sv_free_arenas();
 
--- perl-copy/intrpvar.h    Wed Jul 11 22:50:52 2001
+++ perl/intrpvar.h    Wed Jul 11 23:08:21 2001
@@ -478,6 +478,8 @@
 #if defined(USE_ITHREADS)
 PERLVAR(Iregex_pad,     SV**)    /* All regex objects */
 PERLVAR(Iregex_padav,   AV*)    /* All regex objects */
+
+PERLVAR(Ireentrant_buffer, REBUF*) /* were we store _r buffers */
 #endif
 
 /* New variables must be added to the very end for binary compatibility.




nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About