sv_utf8_downgrade(tsv, FALSE);
tmps = SvPVX(tsv);
}
+# ifdef USE_ITHREADS
+# ifdef HAS_CRYPT_R
+ if (!PL_reentrant_buffer->_crypt_struct_buffer) {
+ /* This should be threadsafe because in ithreads there is only
+ * one thread per interpreter. If this would not be true,
+ * we would need a mutex to protect this malloc. */
+ PL_reentrant_buffer->_crypt_struct_buffer =
+ (struct crypt_data *)safemalloc(sizeof(struct crypt_data));
+#if defined(__GLIBC__) || defined(__EMX__)
+ if (PL_reentrant_buffer->_crypt_struct_buffer) {
+ PL_reentrant_buffer->_crypt_struct_buffer->initialized = 0;
+ /* work around glibc-2.2.5 bug */
+ PL_reentrant_buffer->_crypt_struct_buffer->current_saltbits = 0;
+ }
+ }
+#endif
+# endif /* HAS_CRYPT_R */
+# endif /* USE_ITHREADS */
# ifdef FCRYPT
sv_setpv(TARG, fcrypt(tmps, SvPV(right, n_a)));
# else
New(31338, PL_reentrant_buffer->_asctime_buffer, PL_reentrant_buffer->_asctime_size, char);
#endif /* HAS_ASCTIME_R */
#ifdef HAS_CRYPT_R
-#if defined(__GLIBC__) || defined(__EMX__)
- PL_reentrant_buffer->_crypt_struct.initialized = 0;
- /* work around glibc-2.2.5 bug */
- PL_reentrant_buffer->_crypt_struct.current_saltbits = 0;
+#if CRYPT_R_PROTO != REENTRANT_PROTO_B_CCD
+ PL_reentrant_buffer->_crypt_struct_buffer = 0;
#endif
#endif /* HAS_CRYPT_R */
#ifdef HAS_CTIME_R
Safefree(PL_reentrant_buffer->_asctime_buffer);
#endif /* HAS_ASCTIME_R */
#ifdef HAS_CRYPT_R
+#if CRYPT_R_PROTO != REENTRANT_PROTO_B_CCD
+ Safefree(PL_reentrant_buffer->_crypt_struct_buffer);
+#endif
#endif /* HAS_CRYPT_R */
#ifdef HAS_CTIME_R
Safefree(PL_reentrant_buffer->_ctime_buffer);
#if CRYPT_R_PROTO == REENTRANT_PROTO_B_CCD
CRYPTD* _crypt_data;
#else
- struct crypt_data _crypt_struct;
+ struct crypt_data *_crypt_struct_buffer;
#endif
#endif /* HAS_CRYPT_R */
#ifdef HAS_CTIME_R
#ifdef HAS_CRYPT_R
# undef crypt
# if !defined(crypt) && CRYPT_R_PROTO == REENTRANT_PROTO_B_CCS
-# define crypt(a, b) crypt_r(a, b, &PL_reentrant_buffer->_crypt_struct)
+# define crypt(a, b) crypt_r(a, b, PL_reentrant_buffer->_crypt_struct_buffer)
# endif
# if !defined(crypt) && CRYPT_R_PROTO == REENTRANT_PROTO_B_CCD
# define crypt(a, b) crypt_r(a, b, &PL_reentrant_buffer->_crypt_data)
#if CRYPT_R_PROTO == REENTRANT_PROTO_B_CCD
$seend{$func} _${func}_data;
#else
- $seent{$func} _${func}_struct;
+ $seent{$func} *_${func}_struct_buffer;
#endif
EOF
push @init, <<EOF;
-#if defined(__GLIBC__) || defined(__EMX__)
- PL_reentrant_buffer->_${func}_struct.initialized = 0;
- /* work around glibc-2.2.5 bug */
- PL_reentrant_buffer->_${func}_struct.current_saltbits = 0;
+#if CRYPT_R_PROTO != REENTRANT_PROTO_B_CCD
+ PL_reentrant_buffer->_${func}_struct_buffer = 0;
+#endif
+EOF
+ push @free, <<EOF;
+#if CRYPT_R_PROTO != REENTRANT_PROTO_B_CCD
+ Safefree(PL_reentrant_buffer->_${func}_struct_buffer);
#endif
EOF
pushssif $endif;
$_ eq 'D' ?
"&PL_reentrant_buffer->_${genfunc}_data" :
$_ eq 'S' ?
- ($func =~ /^readdir/ ?
+ ($func =~ /^readdir\d*$/ ?
"PL_reentrant_buffer->_${genfunc}_struct" :
- "&PL_reentrant_buffer->_${genfunc}_struct" ) :
+ $func =~ /^crypt$/ ?
+ "PL_reentrant_buffer->_${genfunc}_struct_buffer" :
+ "&PL_reentrant_buffer->_${genfunc}_struct") :
$_ eq 'T' && $func eq 'drand48' ?
"&PL_reentrant_buffer->_${genfunc}_double" :
$_ =~ /^[ilt]$/ && $func eq 'random' ?