summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--reentr.c18
-rw-r--r--reentr.h47
-rw-r--r--regen/reentr.pl14
3 files changed, 72 insertions, 7 deletions
diff --git a/reentr.c b/reentr.c
index 5ef55c001a..8ddda7bfc0 100644
--- a/reentr.c
+++ b/reentr.c
@@ -132,6 +132,12 @@ Perl_reentrant_size(pTHX) {
# endif
# endif /* HAS_GETSPNAM_R */
+# ifdef HAS_GMTIME_R
+# endif /* HAS_GMTIME_R */
+
+# ifdef HAS_LOCALTIME_R
+# endif /* HAS_LOCALTIME_R */
+
# ifdef HAS_READDIR_R
/* This is the size Solaris recommends.
* (though we go static, should use pathconf() instead) */
@@ -235,6 +241,12 @@ Perl_reentrant_init(pTHX) {
Newx(PL_reentrant_buffer->_spent_buffer, PL_reentrant_buffer->_spent_size, char);
# endif /* HAS_GETSPNAM_R */
+# ifdef HAS_GMTIME_R
+# endif /* HAS_GMTIME_R */
+
+# ifdef HAS_LOCALTIME_R
+# endif /* HAS_LOCALTIME_R */
+
# ifdef HAS_READDIR_R
PL_reentrant_buffer->_readdir_struct = (struct dirent*)safemalloc(PL_reentrant_buffer->_readdir_size);
# endif /* HAS_READDIR_R */
@@ -322,6 +334,12 @@ Perl_reentrant_free(pTHX) {
Safefree(PL_reentrant_buffer->_spent_buffer);
# endif /* HAS_GETSPNAM_R */
+# ifdef HAS_GMTIME_R
+# endif /* HAS_GMTIME_R */
+
+# ifdef HAS_LOCALTIME_R
+# endif /* HAS_LOCALTIME_R */
+
# ifdef HAS_READDIR_R
Safefree(PL_reentrant_buffer->_readdir_struct);
# endif /* HAS_READDIR_R */
diff --git a/reentr.h b/reentr.h
index b3c3c03946..cf41900683 100644
--- a/reentr.h
+++ b/reentr.h
@@ -190,12 +190,13 @@
# define REENTRANT_PROTO_S_SBIE 64
# define REENTRANT_PROTO_S_SBW 65
# define REENTRANT_PROTO_S_TISBI 66
-# define REENTRANT_PROTO_S_TSBI 67
-# define REENTRANT_PROTO_S_TSBIE 68
-# define REENTRANT_PROTO_S_TWISBIE 69
-# define REENTRANT_PROTO_V_D 70
-# define REENTRANT_PROTO_V_H 71
-# define REENTRANT_PROTO_V_ID 72
+# define REENTRANT_PROTO_S_TS 67
+# define REENTRANT_PROTO_S_TSBI 68
+# define REENTRANT_PROTO_S_TSBIE 69
+# define REENTRANT_PROTO_S_TWISBIE 70
+# define REENTRANT_PROTO_V_D 71
+# define REENTRANT_PROTO_V_H 72
+# define REENTRANT_PROTO_V_ID 73
/* Defines for indicating which special features are supported. */
@@ -768,6 +769,14 @@ typedef struct {
# endif
# endif /* HAS_GETSPNAM_R */
+# ifdef HAS_GMTIME_R
+ struct tm _gmtime_struct;
+# endif /* HAS_GMTIME_R */
+
+# ifdef HAS_LOCALTIME_R
+ struct tm _localtime_struct;
+# endif /* HAS_LOCALTIME_R */
+
# ifdef HAS_READDIR_R
struct dirent* _readdir_struct;
size_t _readdir_size;
@@ -1453,6 +1462,32 @@ typedef struct {
# endif /* HAS_GETSPNAM_R */
+# ifdef HAS_GMTIME_R
+# if defined(PERL_REENTR_API) && (PERL_REENTR_API+0 == 1)
+# undef gmtime
+# if !defined(gmtime) && GMTIME_R_PROTO == REENTRANT_PROTO_S_TS
+# define gmtime(a) (gmtime_r(a, &PL_reentrant_buffer->_gmtime_struct) ? &PL_reentrant_buffer->_gmtime_struct : 0)
+# endif
+# if defined(gmtime)
+# define PERL_REENTR_USING_GMTIME_R
+# endif
+# endif
+# endif /* HAS_GMTIME_R */
+
+
+# ifdef HAS_LOCALTIME_R
+# if defined(PERL_REENTR_API) && (PERL_REENTR_API+0 == 1)
+# undef localtime
+# if !defined(localtime) && LOCALTIME_R_PROTO == REENTRANT_PROTO_S_TS
+# define localtime(a) (L_R_TZSET localtime_r(a, &PL_reentrant_buffer->_localtime_struct) ? &PL_reentrant_buffer->_localtime_struct : 0)
+# endif
+# if defined(localtime)
+# define PERL_REENTR_USING_LOCALTIME_R
+# endif
+# endif
+# endif /* HAS_LOCALTIME_R */
+
+
# ifdef HAS_READDIR_R
# if defined(PERL_REENTR_API) && (PERL_REENTR_API+0 == 1)
# undef readdir
diff --git a/regen/reentr.pl b/regen/reentr.pl
index 2604d2c8b2..fa961d58f5 100644
--- a/regen/reentr.pl
+++ b/regen/reentr.pl
@@ -495,6 +495,13 @@ EOF
pushinitfree $func;
pushssif $endif;
}
+ elsif ($func =~ /^(gm|local)time$/) {
+ pushssif $ifdef;
+ push @struct, <<EOF; # Fixed size
+ $seent{$func} _${func}_struct;
+EOF
+ pushssif $endif;
+ }
elsif ($func =~ /^(crypt)$/) {
pushssif $ifdef;
push @struct, <<EOF;
@@ -689,7 +696,10 @@ EOF
$w = ", $w" if length $v;
}
- my $call = "${func}_r($v$w)";
+ # This needs a special case, see its definition in config.h
+ my $setup = ($func eq 'localtime') ? "L_R_TZSET " : "";
+
+ my $call = "$setup${func}_r($v$w)";
# Must make OpenBSD happy
my $memzero = '';
@@ -1197,6 +1207,8 @@ getservbyname CC|netdb |struct servent |I_CCSBWR|S_CCSBI|I_CCSD|D=struct servent
getservbyport IC|netdb |struct servent |I_ICSBWR|S_ICSBI|I_ICSD|D=struct servent_data*
getservent |netdb |struct servent |I_SBWR|I_SBI|S_SBI|I_SD|D=struct servent_data*
getspnam C |shadow |struct spwd |I_CSBWR|S_CSBI
+gmtime T |time |struct tm |S_TS|T=time_t*
+localtime T |time |struct tm |S_TS|T=time_t*
readdir T |dirent |struct dirent |I_TSR|I_TS|T=DIR*
readdir64 T |dirent |struct dirent64|I_TSR|I_TS|T=DIR*
setgrent |grp | |I_H|V_H