summaryrefslogtreecommitdiff
path: root/reentr.pl
diff options
context:
space:
mode:
Diffstat (limited to 'reentr.pl')
-rw-r--r--reentr.pl28
1 files changed, 25 insertions, 3 deletions
diff --git a/reentr.pl b/reentr.pl
index 13cf4d1087..9edc7ade26 100644
--- a/reentr.pl
+++ b/reentr.pl
@@ -61,13 +61,29 @@ print <<EOF;
#ifndef REENTR_H
#define REENTR_H
+/* If compiling for a threaded perl, we will macro-wrap the system/library
+ * interfaces (e.g. getpwent()) which have threaded versions
+ * (e.g. getpwent_r()), which will handle things correctly for
+ * the Perl interpreter, but otherwise (for XS) the wrapping does
+ * not take place. See L<perlxs/Thread-aware system interfaces>.
+ */
+
+#ifndef PERL_REENTR_API
+# if defined(PERL_CORE) || defined(PERL_EXT)
+# define PERL_REENTR_API 1
+# else
+# define PERL_REENTR_API 0
+# endif
+#endif
+
#ifdef USE_REENTRANT_API
/* Deprecations: some platforms have the said reentrant interfaces
* but they are declared obsolete and are not to be used. Often this
* means that the platform has threadsafed the interfaces (hopefully).
* All this is OS version dependent, so we are of course fooling ourselves.
- * If you know of more deprecations on some platforms, please add your own. */
+ * If you know of more deprecations on some platforms, please add your own
+ * (by editing reentr.pl, mind!) */
#ifdef __hpux
# undef HAS_CRYPT_R
@@ -547,7 +563,7 @@ EOF
push @size, <<EOF;
# if defined(HAS_SYSCONF) && defined($sc) && !defined(__GLIBC__)
PL_reentrant_buffer->$sz = sysconf($sc);
- if (PL_reentrant_buffer->$sz == -1)
+ if (PL_reentrant_buffer->$sz == (size_t) -1)
PL_reentrant_buffer->$sz = REENTRANTUSUALSIZE;
# else
# if defined(__osf__) && defined(__alpha) && defined(SIABUFSIZ)
@@ -634,6 +650,7 @@ EOF
push @wrap, $ifdef;
push @wrap, <<EOF;
+# if defined(PERL_REENTR_API) && (PERL_REENTR_API == 1)
# undef $func
EOF
@@ -698,6 +715,7 @@ EOF
} split '', $b;
$w = ", $w" if length $v;
}
+
my $call = "${func}_r($v$w)";
# Must make OpenBSD happy
@@ -732,10 +750,14 @@ EOF
}
}
push @wrap, <<EOF;
-# endif
+# endif /* if defined(PERL_REENTR_API) && (PERL_REENTR_API == 1) */
EOF
}
+ push @wrap, <<EOF;
+# endif /* HAS_\U$func */
+EOF
+
push @wrap, $endif, "\n";
}
}