summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJarkko Hietaniemi <jhi@iki.fi>2002-03-17 18:39:22 +0000
committerJarkko Hietaniemi <jhi@iki.fi>2002-03-17 18:39:22 +0000
commitedd309b7facc349294ca0ee12a41c07bb525e567 (patch)
treead42446abdab6bba10810e31c14e4feba7c65a18
parentf272994b1ce9066a01ab0ed3d6c5353b37057838 (diff)
downloadperl-edd309b7facc349294ca0ee12a41c07bb525e567.tar.gz
Implement the retry-on-ERANGE for the get*_r().
The buffer will keep doubling until 64k. p4raw-id: //depot/perl@15272
-rw-r--r--embed.fnc1
-rw-r--r--embed.h1
-rw-r--r--global.sym1
-rw-r--r--pp_sys.c50
-rw-r--r--proto.h5
-rw-r--r--reentr.c188
-rw-r--r--reentr.h329
-rw-r--r--reentr.pl213
8 files changed, 677 insertions, 111 deletions
diff --git a/embed.fnc b/embed.fnc
index d58208de47..414174aec8 100644
--- a/embed.fnc
+++ b/embed.fnc
@@ -558,6 +558,7 @@ Ap |struct perl_thread* |new_struct_thread|struct perl_thread *t
Ap |void |reentrant_size
Ap |void |reentrant_init
Ap |void |reentrant_free
+Afnp |void* |reentrant_retry|const char*|...
#endif
Ap |void |call_atexit |ATEXIT_t fn|void *ptr
Apd |I32 |call_argv |const char* sub_name|I32 flags|char** argv
diff --git a/embed.h b/embed.h
index cda99dcbc2..457c786677 100644
--- a/embed.h
+++ b/embed.h
@@ -537,6 +537,7 @@
#define reentrant_size Perl_reentrant_size
#define reentrant_init Perl_reentrant_init
#define reentrant_free Perl_reentrant_free
+#define reentrant_retry Perl_reentrant_retry
#endif
#define call_atexit Perl_call_atexit
#define call_argv Perl_call_argv
diff --git a/global.sym b/global.sym
index ee846a0486..d826bc6fc7 100644
--- a/global.sym
+++ b/global.sym
@@ -324,6 +324,7 @@ Perl_new_struct_thread
Perl_reentrant_size
Perl_reentrant_init
Perl_reentrant_free
+Perl_reentrant_retry
Perl_call_atexit
Perl_call_argv
Perl_call_method
diff --git a/pp_sys.c b/pp_sys.c
index b8d7328df1..47602103cd 100644
--- a/pp_sys.c
+++ b/pp_sys.c
@@ -4631,12 +4631,14 @@ PP(pp_ghostent)
STRLEN n_a;
EXTEND(SP, 10);
- if (which == OP_GHBYNAME)
+ if (which == OP_GHBYNAME) {
#ifdef HAS_GETHOSTBYNAME
- hent = PerlSock_gethostbyname(POPpbytex);
+ char* name = POPpbytex;
+ hent = PerlSock_gethostbyname(name);
#else
DIE(aTHX_ PL_no_sock_func, "gethostbyname");
#endif
+ }
else if (which == OP_GHBYADDR) {
#ifdef HAS_GETHOSTBYADDR
int addrtype = POPi;
@@ -4744,12 +4746,14 @@ PP(pp_gnetent)
struct netent *nent;
STRLEN n_a;
- if (which == OP_GNBYNAME)
+ if (which == OP_GNBYNAME){
#ifdef HAS_GETNETBYNAME
- nent = PerlSock_getnetbyname(POPpbytex);
+ char *name = POPpbytex;
+ nent = PerlSock_getnetbyname(name);
#else
DIE(aTHX_ PL_no_sock_func, "getnetbyname");
#endif
+ }
else if (which == OP_GNBYADDR) {
#ifdef HAS_GETNETBYADDR
int addrtype = POPi;
@@ -4843,18 +4847,22 @@ PP(pp_gprotoent)
struct protoent *pent;
STRLEN n_a;
- if (which == OP_GPBYNAME)
+ if (which == OP_GPBYNAME) {
#ifdef HAS_GETPROTOBYNAME
- pent = PerlSock_getprotobyname(POPpbytex);
+ char* name = POPpbytex;
+ pent = PerlSock_getprotobyname(name);
#else
DIE(aTHX_ PL_no_sock_func, "getprotobyname");
#endif
- else if (which == OP_GPBYNUMBER)
+ }
+ else if (which == OP_GPBYNUMBER) {
#ifdef HAS_GETPROTOBYNUMBER
- pent = PerlSock_getprotobynumber(POPi);
+ int number = POPi;
+ pent = PerlSock_getprotobynumber(number);
#else
- DIE(aTHX_ PL_no_sock_func, "getprotobynumber");
+ DIE(aTHX_ PL_no_sock_func, "getprotobynumber");
#endif
+ }
else
#ifdef HAS_GETPROTOENT
pent = PerlSock_getprotoent();
@@ -5175,10 +5183,16 @@ PP(pp_gpwent)
switch (which) {
case OP_GPWNAM:
- pwent = getpwnam(POPpbytex);
- break;
+ {
+ char* name = POPpbytex;
+ pwent = getpwnam(name);
+ }
+ break;
case OP_GPWUID:
- pwent = getpwuid((Uid_t)POPi);
+ {
+ Uid_t uid = POPi;
+ pwent = getpwuid(uid);
+ }
break;
case OP_GPWENT:
# ifdef HAS_GETPWENT
@@ -5375,10 +5389,14 @@ PP(pp_ggrent)
struct group *grent;
STRLEN n_a;
- if (which == OP_GGRNAM)
- grent = (struct group *)getgrnam(POPpbytex);
- else if (which == OP_GGRGID)
- grent = (struct group *)getgrgid(POPi);
+ if (which == OP_GGRNAM) {
+ char* name = POPpbytex;
+ grent = (struct group *)getgrnam(name);
+ }
+ else if (which == OP_GGRGID) {
+ Gid_t gid = POPi;
+ grent = (struct group *)getgrgid(gid);
+ }
else
#ifdef HAS_GETGRENT
grent = (struct group *)getgrent();
diff --git a/proto.h b/proto.h
index 5bb5ddd2a0..b7515be6ab 100644
--- a/proto.h
+++ b/proto.h
@@ -599,6 +599,11 @@ PERL_CALLCONV struct perl_thread* Perl_new_struct_thread(pTHX_ struct perl_threa
PERL_CALLCONV void Perl_reentrant_size(pTHX);
PERL_CALLCONV void Perl_reentrant_init(pTHX);
PERL_CALLCONV void Perl_reentrant_free(pTHX);
+PERL_CALLCONV void* Perl_reentrant_retry(const char*, ...)
+#ifdef CHECK_FORMAT
+ __attribute__((format(printf,1,2)))
+#endif
+;
#endif
PERL_CALLCONV void Perl_call_atexit(pTHX_ ATEXIT_t fn, void *ptr);
PERL_CALLCONV I32 Perl_call_argv(pTHX_ const char* sub_name, I32 flags, char** argv);
diff --git a/reentr.c b/reentr.c
index a054c06303..76098a9faf 100644
--- a/reentr.c
+++ b/reentr.c
@@ -42,7 +42,7 @@ Perl_reentrant_size(pTHX) {
# ifdef __sgi
PL_reentrant_buffer->_getgrent_size = BUFSIZ;
# else
- PL_reentrant_buffer->_getgrent_size = 2048;
+ PL_reentrant_buffer->_getgrent_size = 256;
# endif
# endif
# endif
@@ -75,7 +75,7 @@ Perl_reentrant_size(pTHX) {
# ifdef __sgi
PL_reentrant_buffer->_getpwent_size = BUFSIZ;
# else
- PL_reentrant_buffer->_getpwent_size = 2048;
+ PL_reentrant_buffer->_getpwent_size = 256;
# endif
# endif
# endif
@@ -269,3 +269,187 @@ Perl_reentrant_free(pTHX) {
#endif /* USE_REENTRANT_API */
}
+void*
+Perl_reentrant_retry(const char *f, ...)
+{
+ dTHX;
+ void *retptr = NULL;
+#ifdef USE_REENTRANT_API
+ void *p0, *p1;
+ size_t asize;
+ int anint;
+ va_list ap;
+
+ va_start(ap, f);
+
+#define REENTRANTHALFMAXSIZE 32768 /* The maximum may end up twice this. */
+
+ switch (PL_op->op_type) {
+#ifdef USE_GETHOSTENT_BUFFER
+ case OP_GHBYADDR:
+ case OP_GHBYNAME:
+ case OP_GHOSTENT:
+ {
+ if (PL_reentrant_buffer->_gethostent_size <= REENTRANTHALFMAXSIZE) {
+ PL_reentrant_buffer->_gethostent_size *= 2;
+ Renew(PL_reentrant_buffer->_gethostent_buffer,
+ PL_reentrant_buffer->_gethostent_size, char);
+ switch (PL_op->op_type) {
+ case OP_GHBYADDR:
+ p0 = va_arg(ap, void *);
+ asize = va_arg(ap, size_t);
+ anint = va_arg(ap, int);
+ retptr = gethostbyaddr(p0, asize, anint); break;
+ case OP_GHBYNAME:
+ p0 = va_arg(ap, void *);
+ retptr = gethostbyname(p0); break;
+ case OP_GHOSTENT:
+ retptr = gethostent(); break;
+ default:
+ break;
+ }
+ }
+ }
+ break;
+#endif
+#ifdef USE_GETGRENT_BUFFER
+ case OP_GGRNAM:
+ case OP_GGRGID:
+ case OP_GGRENT:
+ {
+ if (PL_reentrant_buffer->_getgrent_size <= REENTRANTHALFMAXSIZE) {
+ Gid_t gid;
+ PL_reentrant_buffer->_getgrent_size *= 2;
+ Renew(PL_reentrant_buffer->_getgrent_buffer,
+ PL_reentrant_buffer->_getgrent_size, char);
+ switch (PL_op->op_type) {
+ case OP_GGRNAM:
+ p0 = va_arg(ap, void *);
+ retptr = getgrnam(p0); break;
+ case OP_GGRGID:
+ gid = va_arg(ap, Gid_t);
+ retptr = getgrgid(gid); break;
+ case OP_GGRENT:
+ retptr = getgrent(); break;
+ default:
+ break;
+ }
+ }
+ }
+ break;
+#endif
+#ifdef USE_GETNETENT_BUFFER
+ case OP_GNBYADDR:
+ case OP_GNBYNAME:
+ case OP_GNETENT:
+ {
+ if (PL_reentrant_buffer->_getnetent_size <= REENTRANTHALFMAXSIZE) {
+ Netdb_net_t net;
+ PL_reentrant_buffer->_getnetent_size *= 2;
+ Renew(PL_reentrant_buffer->_getnetent_buffer,
+ PL_reentrant_buffer->_getnetent_size, char);
+ switch (PL_op->op_type) {
+ case OP_GNBYADDR:
+ net = va_arg(ap, Netdb_net_t);
+ anint = va_arg(ap, int);
+ retptr = getnetbyaddr(net, anint); break;
+ case OP_GNBYNAME:
+ p0 = va_arg(ap, void *);
+ retptr = getnetbyname(p0); break;
+ case OP_GNETENT:
+ retptr = getnetent(); break;
+ default:
+ break;
+ }
+ }
+ }
+ break;
+#endif
+#ifdef USE_GETPWENT_BUFFER
+ case OP_GPWNAM:
+ case OP_GPWUID:
+ case OP_GPWENT:
+ {
+ if (PL_reentrant_buffer->_getpwent_size <= REENTRANTHALFMAXSIZE) {
+ Uid_t uid;
+ PL_reentrant_buffer->_getpwent_size *= 2;
+ Renew(PL_reentrant_buffer->_getpwent_buffer,
+ PL_reentrant_buffer->_getpwent_size, char);
+ switch (PL_op->op_type) {
+ case OP_GPWNAM:
+ p0 = va_arg(ap, void *);
+ retptr = getpwnam(p0); break;
+ case OP_GPWUID:
+ uid = va_arg(ap, Uid_t);
+ retptr = getpwuid(uid); break;
+ case OP_GPWENT:
+ retptr = getpwent(); break;
+ default:
+ break;
+ }
+ }
+ }
+ break;
+#endif
+#ifdef USE_GETPROTOENT_BUFFER
+ case OP_GPBYNAME:
+ case OP_GPBYNUMBER:
+ case OP_GPROTOENT:
+ {
+ if (PL_reentrant_buffer->_getprotoent_size <= REENTRANTHALFMAXSIZE) {
+ PL_reentrant_buffer->_getprotoent_size *= 2;
+ Renew(PL_reentrant_buffer->_getprotoent_buffer,
+ PL_reentrant_buffer->_getprotoent_size, char);
+ switch (PL_op->op_type) {
+ case OP_GPBYNAME:
+ p0 = va_arg(ap, void *);
+ retptr = getprotobyname(p0); break;
+ case OP_GPBYNUMBER:
+ anint = va_arg(ap, int);
+ retptr = getprotobynumber(anint); break;
+ case OP_GPROTOENT:
+ retptr = getprotoent(); break;
+ default:
+ break;
+ }
+ }
+ }
+ break;
+#endif
+#ifdef USE_GETSERVENT_BUFFER
+ case OP_GSBYNAME:
+ case OP_GSBYPORT:
+ case OP_GSERVENT:
+ {
+ if (PL_reentrant_buffer->_getservent_size <= REENTRANTHALFMAXSIZE) {
+ PL_reentrant_buffer->_getservent_size *= 2;
+ Renew(PL_reentrant_buffer->_getservent_buffer,
+ PL_reentrant_buffer->_getservent_size, char);
+ switch (PL_op->op_type) {
+ case OP_GSBYNAME:
+ p0 = va_arg(ap, void *);
+ p1 = va_arg(ap, void *);
+ retptr = getservbyname(p0, p1); break;
+ case OP_GSBYPORT:
+ anint = va_arg(ap, int);
+ p0 = va_arg(ap, void *);
+ retptr = getservbyport(anint, p0); break;
+ case OP_GSERVENT:
+ retptr = getservent(); break;
+ default:
+ break;
+ }
+ }
+ }
+ break;
+#endif
+ default:
+ /* Not known how to retry, so just fail. */
+ break;
+ }
+
+ va_end(ap);
+#endif
+ return retptr;
+}
+
diff --git a/reentr.h b/reentr.h
index 310fe97ecf..6060fb7ed3 100644
--- a/reentr.h
+++ b/reentr.h
@@ -161,6 +161,32 @@
/* Defines for indicating which special features are supported. */
+/* The getgrent getgrgid getgrnam using buffer? */
+
+#if defined(HAS_GETGRENT_R) && (GETGRENT_R_PROTO == REENTRANT_PROTO_I_SBWR || GETGRENT_R_PROTO == REENTRANT_PROTO_I_SBIR || GETGRENT_R_PROTO == REENTRANT_PROTO_S_SBW || GETGRENT_R_PROTO == REENTRANT_PROTO_S_SBI || GETGRENT_R_PROTO == REENTRANT_PROTO_I_SBI || GETGRENT_R_PROTO == REENTRANT_PROTO_I_SBIH)
+# define GETGRENT_R_HAS_BUFFER
+#else
+# undef GETGRENT_R_HAS_BUFFER
+#endif
+#if defined(HAS_GETGRGID_R) && (GETGRGID_R_PROTO == REENTRANT_PROTO_I_TSBWR || GETGRGID_R_PROTO == REENTRANT_PROTO_I_TSBIR || GETGRGID_R_PROTO == REENTRANT_PROTO_I_TSBI || GETGRGID_R_PROTO == REENTRANT_PROTO_S_TSBI)
+# define GETGRGID_R_HAS_BUFFER
+#else
+# undef GETGRGID_R_HAS_BUFFER
+#endif
+#if defined(HAS_GETGRNAM_R) && (GETGRNAM_R_PROTO == REENTRANT_PROTO_I_CSBWR || GETGRNAM_R_PROTO == REENTRANT_PROTO_I_CSBIR || GETGRNAM_R_PROTO == REENTRANT_PROTO_S_CBI || GETGRNAM_R_PROTO == REENTRANT_PROTO_I_CSBI || GETGRNAM_R_PROTO == REENTRANT_PROTO_S_CSBI)
+# define GETGRNAM_R_HAS_BUFFER
+#else
+# undef GETGRNAM_R_HAS_BUFFER
+#endif
+
+/* Any of the getgrent getgrgid getgrnam using buffer? */
+
+#if (defined(GETGRENT_R_HAS_BUFFER) || defined(GETGRGID_R_HAS_BUFFER) || defined(GETGRNAM_R_HAS_BUFFER))
+# define USE_GETGRENT_BUFFER
+#else
+# undef USE_GETGRENT_BUFFER
+#endif
+
/* The getgrent getgrgid getgrnam using ptr? */
#if defined(HAS_GETGRENT_R) && (GETGRENT_R_PROTO == REENTRANT_PROTO_I_SBWR || GETGRENT_R_PROTO == REENTRANT_PROTO_I_SBIR)
@@ -261,6 +287,27 @@
# undef USE_GETPWENT_FPTR
#endif
+/* The getpwent getpwgid getpwnam using buffer? */
+
+#if defined(HAS_GETPWENT_R) && (GETPWENT_R_PROTO == REENTRANT_PROTO_I_SBWR || GETPWENT_R_PROTO == REENTRANT_PROTO_I_SBIR || GETPWENT_R_PROTO == REENTRANT_PROTO_S_SBW || GETPWENT_R_PROTO == REENTRANT_PROTO_S_SBI || GETPWENT_R_PROTO == REENTRANT_PROTO_I_SBI || GETPWENT_R_PROTO == REENTRANT_PROTO_I_SBIH)
+# define GETPWENT_R_HAS_BUFFER
+#else
+# undef GETPWENT_R_HAS_BUFFER
+#endif
+#if defined(HAS_GETPWNAM_R) && (GETPWNAM_R_PROTO == REENTRANT_PROTO_I_CSBWR || GETPWNAM_R_PROTO == REENTRANT_PROTO_I_CSBIR || GETPWNAM_R_PROTO == REENTRANT_PROTO_S_CSBI || GETPWNAM_R_PROTO == REENTRANT_PROTO_I_CSBI)
+# define GETPWNAM_R_HAS_BUFFER
+#else
+# undef GETPWNAM_R_HAS_BUFFER
+#endif
+
+/* Any of the getpwent getpwgid getpwnam using buffer? */
+
+#if (defined(GETPWENT_R_HAS_BUFFER) || defined(GETPWGID_R_HAS_BUFFER) || defined(GETPWNAM_R_HAS_BUFFER))
+# define USE_GETPWENT_BUFFER
+#else
+# undef USE_GETPWENT_BUFFER
+#endif
+
/* The gethostent gethostbyaddr gethostbyname using ptr? */
#if defined(HAS_GETHOSTENT_R) && (GETHOSTENT_R_PROTO == REENTRANT_PROTO_I_SBWRE)
@@ -365,6 +412,110 @@
# undef USE_GETSERVENT_PTR
#endif
+/* The gethostent gethostbyaddr gethostbyname using buffer? */
+
+#if defined(HAS_GETHOSTENT_R) && (GETHOSTENT_R_PROTO == REENTRANT_PROTO_I_SBWRE || GETHOSTENT_R_PROTO == REENTRANT_PROTO_I_SBIE || GETHOSTENT_R_PROTO == REENTRANT_PROTO_S_SBIE || GETHOSTENT_R_PROTO == REENTRANT_PROTO_S_SBI || GETHOSTENT_R_PROTO == REENTRANT_PROTO_I_SBI)
+# define GETHOSTENT_R_HAS_BUFFER
+#else
+# undef GETHOSTENT_R_HAS_BUFFER
+#endif
+#if defined(HAS_GETHOSTBYADDR_R) && (GETHOSTBYADDR_R_PROTO == REENTRANT_PROTO_I_CWISBWRE || GETHOSTBYADDR_R_PROTO == REENTRANT_PROTO_S_CWISBWIE || GETHOSTBYADDR_R_PROTO == REENTRANT_PROTO_S_CWISBIE || GETHOSTBYADDR_R_PROTO == REENTRANT_PROTO_S_TWISBIE || GETHOSTBYADDR_R_PROTO == REENTRANT_PROTO_S_CIISBIE || GETHOSTBYADDR_R_PROTO == REENTRANT_PROTO_S_CSBIE || GETHOSTBYADDR_R_PROTO == REENTRANT_PROTO_S_TSBIE)
+# define GETHOSTBYADDR_R_HAS_BUFFER
+#else
+# undef GETHOSTBYADDR_R_HAS_BUFFER
+#endif
+#if defined(HAS_GETHOSTBYNAME_R) && (GETHOSTBYNAME_R_PROTO == REENTRANT_PROTO_I_CSBWRE || GETHOSTBYNAME_R_PROTO == REENTRANT_PROTO_S_CSBIE)
+# define GETHOSTBYNAME_R_HAS_BUFFER
+#else
+# undef GETHOSTBYNAME_R_HAS_BUFFER
+#endif
+
+/* Any of the gethostent gethostbyaddr gethostbyname using buffer? */
+
+#if (defined(GETHOSTENT_R_HAS_BUFFER) || defined(GETHOSTBYADDR_R_HAS_BUFFER) || defined(GETHOSTBYNAME_R_HAS_BUFFER))
+# define USE_GETHOSTENT_BUFFER
+#else
+# undef USE_GETHOSTENT_BUFFER
+#endif
+
+/* The getnetent getnetbyaddr getnetbyname using buffer? */
+
+#if defined(HAS_GETNETENT_R) && (GETNETENT_R_PROTO == REENTRANT_PROTO_I_SBWRE || GETNETENT_R_PROTO == REENTRANT_PROTO_I_SBIE || GETNETENT_R_PROTO == REENTRANT_PROTO_S_SBIE || GETNETENT_R_PROTO == REENTRANT_PROTO_S_SBI || GETNETENT_R_PROTO == REENTRANT_PROTO_I_SBI)
+# define GETNETENT_R_HAS_BUFFER
+#else
+# undef GETNETENT_R_HAS_BUFFER
+#endif
+#if defined(HAS_GETNETBYADDR_R) && (GETNETBYADDR_R_PROTO == REENTRANT_PROTO_I_UISBWRE || GETNETBYADDR_R_PROTO == REENTRANT_PROTO_I_LISBI || GETNETBYADDR_R_PROTO == REENTRANT_PROTO_S_TISBI || GETNETBYADDR_R_PROTO == REENTRANT_PROTO_S_LISBI)
+# define GETNETBYADDR_R_HAS_BUFFER
+#else
+# undef GETNETBYADDR_R_HAS_BUFFER
+#endif
+#if defined(HAS_GETNETBYNAME_R) && (GETNETBYNAME_R_PROTO == REENTRANT_PROTO_I_CSBWRE || GETNETBYNAME_R_PROTO == REENTRANT_PROTO_I_CSBI || GETNETBYNAME_R_PROTO == REENTRANT_PROTO_S_CSBI)
+# define GETNETBYNAME_R_HAS_BUFFER
+#else
+# undef GETNETBYNAME_R_HAS_BUFFER
+#endif
+
+/* Any of the getnetent getnetbyaddr getnetbyname using buffer? */
+
+#if (defined(GETNETENT_R_HAS_BUFFER) || defined(GETNETBYADDR_R_HAS_BUFFER) || defined(GETNETBYNAME_R_HAS_BUFFER))
+# define USE_GETNETENT_BUFFER
+#else
+# undef USE_GETNETENT_BUFFER
+#endif
+
+/* The getprotoent getprotobyname getprotobynumber using buffer? */
+
+#if defined(HAS_GETPROTOENT_R) && (GETPROTOENT_R_PROTO == REENTRANT_PROTO_I_SBWR || GETPROTOENT_R_PROTO == REENTRANT_PROTO_I_SBI || GETPROTOENT_R_PROTO == REENTRANT_PROTO_S_SBI)
+# define GETPROTOENT_R_HAS_BUFFER
+#else
+# undef GETPROTOENT_R_HAS_BUFFER
+#endif
+#if defined(HAS_GETPROTOBYNAME_R) && (GETPROTOBYNAME_R_PROTO == REENTRANT_PROTO_I_CSBWR || GETPROTOBYNAME_R_PROTO == REENTRANT_PROTO_S_CSBI)
+# define GETPROTOBYNAME_R_HAS_BUFFER
+#else
+# undef GETPROTOBYNAME_R_HAS_BUFFER
+#endif
+#if defined(HAS_GETPROTOBYNUMBER_R) && (GETPROTOBYNUMBER_R_PROTO == REENTRANT_PROTO_I_ISBWR || GETPROTOBYNUMBER_R_PROTO == REENTRANT_PROTO_S_ISBI)
+# define GETPROTOBYNUMBER_R_HAS_BUFFER
+#else
+# undef GETPROTOBYNUMBER_R_HAS_BUFFER
+#endif
+
+/* Any of the getprotoent getprotobyname getprotobynumber using buffer? */
+
+#if (defined(GETPROTOENT_R_HAS_BUFFER) || defined(GETPROTOBYNAME_R_HAS_BUFFER) || defined(GETPROTOBYNUMBER_R_HAS_BUFFER))
+# define USE_GETPROTOENT_BUFFER
+#else
+# undef USE_GETPROTOENT_BUFFER
+#endif
+
+/* The getservent getservbyname getservbyport using buffer? */
+
+#if defined(HAS_GETSERVENT_R) && (GETSERVENT_R_PROTO == REENTRANT_PROTO_I_SBWR || GETSERVENT_R_PROTO == REENTRANT_PROTO_I_SBI || GETSERVENT_R_PROTO == REENTRANT_PROTO_S_SBI)
+# define GETSERVENT_R_HAS_BUFFER
+#else
+# undef GETSERVENT_R_HAS_BUFFER
+#endif
+#if defined(HAS_GETSERVBYNAME_R) && (GETSERVBYNAME_R_PROTO == REENTRANT_PROTO_I_CCSBWR || GETSERVBYNAME_R_PROTO == REENTRANT_PROTO_S_CCSBI)
+# define GETSERVBYNAME_R_HAS_BUFFER
+#else
+# undef GETSERVBYNAME_R_HAS_BUFFER
+#endif
+#if defined(HAS_GETSERVBYPORT_R) && (GETSERVBYPORT_R_PROTO == REENTRANT_PROTO_I_ICSBWR || GETSERVBYPORT_R_PROTO == REENTRANT_PROTO_S_ICSBI)
+# define GETSERVBYPORT_R_HAS_BUFFER
+#else
+# undef GETSERVBYPORT_R_HAS_BUFFER
+#endif
+
+/* Any of the getservent getservbyname getservbyport using buffer? */
+
+#if (defined(GETSERVENT_R_HAS_BUFFER) || defined(GETSERVBYNAME_R_HAS_BUFFER) || defined(GETSERVBYPORT_R_HAS_BUFFER))
+# define USE_GETSERVENT_BUFFER
+#else
+# undef USE_GETSERVENT_BUFFER
+#endif
+
/* The gethostent gethostbyaddr gethostbyname using errno? */
#if defined(HAS_GETHOSTENT_R) && (GETHOSTENT_R_PROTO == REENTRANT_PROTO_I_SBWRE || GETHOSTENT_R_PROTO == REENTRANT_PROTO_I_SBIE || GETHOSTENT_R_PROTO == REENTRANT_PROTO_S_SBIE)
@@ -684,136 +835,136 @@ typedef struct {
#ifdef HAS_GETGRENT_R
# undef getgrent
# if !defined(getgrent) && GETGRENT_R_PROTO == REENTRANT_PROTO_I_SBWR
-# define getgrent() (((errno = getgrent_r(&PL_reentrant_buffer->_getgrent_struct, PL_reentrant_buffer->_getgrent_buffer, PL_reentrant_buffer->_getgrent_size, &PL_reentrant_buffer->_getgrent_ptr))) == 0 ? PL_reentrant_buffer->_getgrent_ptr : 0)
+# define getgrent() (((errno = getgrent_r(&PL_reentrant_buffer->_getgrent_struct, PL_reentrant_buffer->_getgrent_buffer, PL_reentrant_buffer->_getgrent_size, &PL_reentrant_buffer->_getgrent_ptr))) == 0 ? PL_reentrant_buffer->_getgrent_ptr : (errno == ERANGE ? Perl_reentrant_retry("getgrent") : 0))
# endif
# if !defined(getgrent) && GETGRENT_R_PROTO == REENTRANT_PROTO_I_SBIR
-# define getgrent() (((errno = getgrent_r(&PL_reentrant_buffer->_getgrent_struct, PL_reentrant_buffer->_getgrent_buffer, PL_reentrant_buffer->_getgrent_size, &PL_reentrant_buffer->_getgrent_ptr))) == 0 ? PL_reentrant_buffer->_getgrent_ptr : 0)
+# define getgrent() (((errno = getgrent_r(&PL_reentrant_buffer->_getgrent_struct, PL_reentrant_buffer->_getgrent_buffer, PL_reentrant_buffer->_getgrent_size, &PL_reentrant_buffer->_getgrent_ptr))) == 0 ? PL_reentrant_buffer->_getgrent_ptr : (errno == ERANGE ? Perl_reentrant_retry("getgrent") : 0))
# endif
# if !defined(getgrent) && GETGRENT_R_PROTO == REENTRANT_PROTO_S_SBW
-# define getgrent() (getgrent_r(&PL_reentrant_buffer->_getgrent_struct, PL_reentrant_buffer->_getgrent_buffer, PL_reentrant_buffer->_getgrent_size) ? &PL_reentrant_buffer->_getgrent_struct : 0)
+# define getgrent() (getgrent_r(&PL_reentrant_buffer->_getgrent_struct, PL_reentrant_buffer->_getgrent_buffer, PL_reentrant_buffer->_getgrent_size) ? &PL_reentrant_buffer->_getgrent_struct : (errno == ERANGE ? Perl_reentrant_retry("getgrent") : 0))
# endif
# if !defined(getgrent) && GETGRENT_R_PROTO == REENTRANT_PROTO_S_SBI
-# define getgrent() (getgrent_r(&PL_reentrant_buffer->_getgrent_struct, PL_reentrant_buffer->_getgrent_buffer, PL_reentrant_buffer->_getgrent_size) ? &PL_reentrant_buffer->_getgrent_struct : 0)
+# define getgrent() (getgrent_r(&PL_reentrant_buffer->_getgrent_struct, PL_reentrant_buffer->_getgrent_buffer, PL_reentrant_buffer->_getgrent_size) ? &PL_reentrant_buffer->_getgrent_struct : (errno == ERANGE ? Perl_reentrant_retry("getgrent") : 0))
# endif
# if !defined(getgrent) && GETGRENT_R_PROTO == REENTRANT_PROTO_I_SBI
-# define getgrent() (((errno = getgrent_r(&PL_reentrant_buffer->_getgrent_struct, PL_reentrant_buffer->_getgrent_buffer, PL_reentrant_buffer->_getgrent_size))) == 0 ? &PL_reentrant_buffer->_getgrent_struct : 0)
+# define getgrent() (((errno = getgrent_r(&PL_reentrant_buffer->_getgrent_struct, PL_reentrant_buffer->_getgrent_buffer, PL_reentrant_buffer->_getgrent_size))) == 0 ? &PL_reentrant_buffer->_getgrent_struct : (errno == ERANGE ? Perl_reentrant_retry("getgrent") : 0))
# endif
# if !defined(getgrent) && GETGRENT_R_PROTO == REENTRANT_PROTO_I_SBIH
-# define getgrent() (((errno = getgrent_r(&PL_reentrant_buffer->_getgrent_struct, PL_reentrant_buffer->_getgrent_buffer, PL_reentrant_buffer->_getgrent_size, &PL_reentrant_buffer->_getgrent_fptr))) == 0 ? &PL_reentrant_buffer->_getgrent_struct : 0)
+# define getgrent() (((errno = getgrent_r(&PL_reentrant_buffer->_getgrent_struct, PL_reentrant_buffer->_getgrent_buffer, PL_reentrant_buffer->_getgrent_size, &PL_reentrant_buffer->_getgrent_fptr))) == 0 ? &PL_reentrant_buffer->_getgrent_struct : (errno == ERANGE ? Perl_reentrant_retry("getgrent") : 0))
# endif
#endif /* HAS_GETGRENT_R */
#ifdef HAS_GETGRGID_R
# undef getgrgid
# if !defined(getgrgid) && GETGRGID_R_PROTO == REENTRANT_PROTO_I_TSBWR
-# define getgrgid(a) (((errno = getgrgid_r(a, &PL_reentrant_buffer->_getgrent_struct, PL_reentrant_buffer->_getgrent_buffer, PL_reentrant_buffer->_getgrent_size, &PL_reentrant_buffer->_getgrent_ptr))) == 0 ? PL_reentrant_buffer->_getgrent_ptr : 0)
+# define getgrgid(a) (((errno = getgrgid_r(a, &PL_reentrant_buffer->_getgrent_struct, PL_reentrant_buffer->_getgrent_buffer, PL_reentrant_buffer->_getgrent_size, &PL_reentrant_buffer->_getgrent_ptr))) == 0 ? PL_reentrant_buffer->_getgrent_ptr : (errno == ERANGE ? Perl_reentrant_retry("getgrgid", a) : 0))
# endif
# if !defined(getgrgid) && GETGRGID_R_PROTO == REENTRANT_PROTO_I_TSBIR
-# define getgrgid(a) (((errno = getgrgid_r(a, &PL_reentrant_buffer->_getgrent_struct, PL_reentrant_buffer->_getgrent_buffer, PL_reentrant_buffer->_getgrent_size, &PL_reentrant_buffer->_getgrent_ptr))) == 0 ? PL_reentrant_buffer->_getgrent_ptr : 0)
+# define getgrgid(a) (((errno = getgrgid_r(a, &PL_reentrant_buffer->_getgrent_struct, PL_reentrant_buffer->_getgrent_buffer, PL_reentrant_buffer->_getgrent_size, &PL_reentrant_buffer->_getgrent_ptr))) == 0 ? PL_reentrant_buffer->_getgrent_ptr : (errno == ERANGE ? Perl_reentrant_retry("getgrgid", a) : 0))
# endif
# if !defined(getgrgid) && GETGRGID_R_PROTO == REENTRANT_PROTO_I_TSBI
-# define getgrgid(a) (((errno = getgrgid_r(a, &PL_reentrant_buffer->_getgrent_struct, PL_reentrant_buffer->_getgrent_buffer, PL_reentrant_buffer->_getgrent_size))) == 0 ? &PL_reentrant_buffer->_getgrent_struct : 0)
+# define getgrgid(a) (((errno = getgrgid_r(a, &PL_reentrant_buffer->_getgrent_struct, PL_reentrant_buffer->_getgrent_buffer, PL_reentrant_buffer->_getgrent_size))) == 0 ? &PL_reentrant_buffer->_getgrent_struct : (errno == ERANGE ? Perl_reentrant_retry("getgrgid", a) : 0))
# endif
# if !defined(getgrgid) && GETGRGID_R_PROTO == REENTRANT_PROTO_S_TSBI
-# define getgrgid(a) (getgrgid_r(a, &PL_reentrant_buffer->_getgrent_struct, PL_reentrant_buffer->_getgrent_buffer, PL_reentrant_buffer->_getgrent_size) ? &PL_reentrant_buffer->_getgrent_struct : 0)
+# define getgrgid(a) (getgrgid_r(a, &PL_reentrant_buffer->_getgrent_struct, PL_reentrant_buffer->_getgrent_buffer, PL_reentrant_buffer->_getgrent_size) ? &PL_reentrant_buffer->_getgrent_struct : (errno == ERANGE ? Perl_reentrant_retry("getgrgid", a) : 0))
# endif
#endif /* HAS_GETGRGID_R */
#ifdef HAS_GETGRNAM_R
# undef getgrnam
# if !defined(getgrnam) && GETGRNAM_R_PROTO == REENTRANT_PROTO_I_CSBWR
-# define getgrnam(a) (((errno = getgrnam_r(a, &PL_reentrant_buffer->_getgrent_struct, PL_reentrant_buffer->_getgrent_buffer, PL_reentrant_buffer->_getgrent_size, &PL_reentrant_buffer->_getgrent_ptr))) == 0 ? PL_reentrant_buffer->_getgrent_ptr : 0)
+# define getgrnam(a) (((errno = getgrnam_r(a, &PL_reentrant_buffer->_getgrent_struct, PL_reentrant_buffer->_getgrent_buffer, PL_reentrant_buffer->_getgrent_size, &PL_reentrant_buffer->_getgrent_ptr))) == 0 ? PL_reentrant_buffer->_getgrent_ptr : (errno == ERANGE ? Perl_reentrant_retry("getgrnam", a) : 0))
# endif
# if !defined(getgrnam) && GETGRNAM_R_PROTO == REENTRANT_PROTO_I_CSBIR
-# define getgrnam(a) (((errno = getgrnam_r(a, &PL_reentrant_buffer->_getgrent_struct, PL_reentrant_buffer->_getgrent_buffer, PL_reentrant_buffer->_getgrent_size, &PL_reentrant_buffer->_getgrent_ptr))) == 0 ? PL_reentrant_buffer->_getgrent_ptr : 0)
+# define getgrnam(a) (((errno = getgrnam_r(a, &PL_reentrant_buffer->_getgrent_struct, PL_reentrant_buffer->_getgrent_buffer, PL_reentrant_buffer->_getgrent_size, &PL_reentrant_buffer->_getgrent_ptr))) == 0 ? PL_reentrant_buffer->_getgrent_ptr : (errno == ERANGE ? Perl_reentrant_retry("getgrnam", a) : 0))
# endif
# if !defined(getgrnam) && GETGRNAM_R_PROTO == REENTRANT_PROTO_S_CBI
-# define getgrnam(a) (getgrnam_r(a, PL_reentrant_buffer->_getgrent_buffer, PL_reentrant_buffer->_getgrent_size) ? PL_reentrant_buffer->_getgrent_buffer : 0)
+# define getgrnam(a) (getgrnam_r(a, PL_reentrant_buffer->_getgrent_buffer, PL_reentrant_buffer->_getgrent_size) ? PL_reentrant_buffer->_getgrent_buffer : (errno == ERANGE ? Perl_reentrant_retry("getgrnam", a) : 0))
# endif
# if !defined(getgrnam) && GETGRNAM_R_PROTO == REENTRANT_PROTO_I_CSBI
-# define getgrnam(a) (((errno = getgrnam_r(a, &PL_reentrant_buffer->_getgrent_struct, PL_reentrant_buffer->_getgrent_buffer, PL_reentrant_buffer->_getgrent_size))) == 0 ? &PL_reentrant_buffer->_getgrent_struct : 0)
+# define getgrnam(a) (((errno = getgrnam_r(a, &PL_reentrant_buffer->_getgrent_struct, PL_reentrant_buffer->_getgrent_buffer, PL_reentrant_buffer->_getgrent_size))) == 0 ? &PL_reentrant_buffer->_getgrent_struct : (errno == ERANGE ? Perl_reentrant_retry("getgrnam", a) : 0))
# endif
# if !defined(getgrnam) && GETGRNAM_R_PROTO == REENTRANT_PROTO_S_CSBI
-# define getgrnam(a) (getgrnam_r(a, &PL_reentrant_buffer->_getgrent_struct, PL_reentrant_buffer->_getgrent_buffer, PL_reentrant_buffer->_getgrent_size) ? &PL_reentrant_buffer->_getgrent_struct : 0)
+# define getgrnam(a) (getgrnam_r(a, &PL_reentrant_buffer->_getgrent_struct, PL_reentrant_buffer->_getgrent_buffer, PL_reentrant_buffer->_getgrent_size) ? &PL_reentrant_buffer->_getgrent_struct : (errno == ERANGE ? Perl_reentrant_retry("getgrnam", a) : 0))
# endif
#endif /* HAS_GETGRNAM_R */
#ifdef HAS_GETHOSTBYADDR_R
# undef gethostbyaddr
# if !defined(gethostbyaddr) && GETHOSTBYADDR_R_PROTO == REENTRANT_PROTO_I_CWISBWRE
-# define gethostbyaddr(a, b, c) (((errno = gethostbyaddr_r(a, b, c, &PL_reentrant_buffer->_gethostent_struct, PL_reentrant_buffer->_gethostent_buffer, PL_reentrant_buffer->_gethostent_size, &PL_reentrant_buffer->_gethostent_ptr, &PL_reentrant_buffer->_gethostent_errno))) == 0 ? PL_reentrant_buffer->_gethostent_ptr : 0)
+# define gethostbyaddr(a, b, c) (((errno = gethostbyaddr_r(a, b, c, &PL_reentrant_buffer->_gethostent_struct, PL_reentrant_buffer->_gethostent_buffer, PL_reentrant_buffer->_gethostent_size, &PL_reentrant_buffer->_gethostent_ptr, &PL_reentrant_buffer->_gethostent_errno))) == 0 ? PL_reentrant_buffer->_gethostent_ptr : (errno == ERANGE ? Perl_reentrant_retry("gethostbyaddr", a, b, c) : 0))
# endif
# if !defined(gethostbyaddr) && GETHOSTBYADDR_R_PROTO == REENTRANT_PROTO_S_CWISBWIE
-# define gethostbyaddr(a, b, c) (gethostbyaddr_r(a, b, c, &PL_reentrant_buffer->_gethostent_struct, PL_reentrant_buffer->_gethostent_buffer, PL_reentrant_buffer->_gethostent_size, PL_reentrant_buffer->_gethostent_size, &PL_reentrant_buffer->_gethostent_errno) ? &PL_reentrant_buffer->_gethostent_struct : 0)
+# define gethostbyaddr(a, b, c) (gethostbyaddr_r(a, b, c, &PL_reentrant_buffer->_gethostent_struct, PL_reentrant_buffer->_gethostent_buffer, PL_reentrant_buffer->_gethostent_size, PL_reentrant_buffer->_gethostent_size, &PL_reentrant_buffer->_gethostent_errno) ? &PL_reentrant_buffer->_gethostent_struct : (errno == ERANGE ? Perl_reentrant_retry("gethostbyaddr", a, b, c) : 0))
# endif
# if !defined(gethostbyaddr) && GETHOSTBYADDR_R_PROTO == REENTRANT_PROTO_S_CWISBIE
-# define gethostbyaddr(a, b, c) (gethostbyaddr_r(a, b, c, &PL_reentrant_buffer->_gethostent_struct, PL_reentrant_buffer->_gethostent_buffer, PL_reentrant_buffer->_gethostent_size, &PL_reentrant_buffer->_gethostent_errno) ? &PL_reentrant_buffer->_gethostent_struct : 0)
+# define gethostbyaddr(a, b, c) (gethostbyaddr_r(a, b, c, &PL_reentrant_buffer->_gethostent_struct, PL_reentrant_buffer->_gethostent_buffer, PL_reentrant_buffer->_gethostent_size, &PL_reentrant_buffer->_gethostent_errno) ? &PL_reentrant_buffer->_gethostent_struct : (errno == ERANGE ? Perl_reentrant_retry("gethostbyaddr", a, b, c) : 0))
# endif
# if !defined(gethostbyaddr) && GETHOSTBYADDR_R_PROTO == REENTRANT_PROTO_S_TWISBIE
-# define gethostbyaddr(a, b, c) (gethostbyaddr_r(a, b, c, &PL_reentrant_buffer->_gethostent_struct, PL_reentrant_buffer->_gethostent_buffer, PL_reentrant_buffer->_gethostent_size, &PL_reentrant_buffer->_gethostent_errno) ? &PL_reentrant_buffer->_gethostent_struct : 0)
+# define gethostbyaddr(a, b, c) (gethostbyaddr_r(a, b, c, &PL_reentrant_buffer->_gethostent_struct, PL_reentrant_buffer->_gethostent_buffer, PL_reentrant_buffer->_gethostent_size, &PL_reentrant_buffer->_gethostent_errno) ? &PL_reentrant_buffer->_gethostent_struct : (errno == ERANGE ? Perl_reentrant_retry("gethostbyaddr", a, b, c) : 0))
# endif
# if !defined(gethostbyaddr) && GETHOSTBYADDR_R_PROTO == REENTRANT_PROTO_S_CIISBIE
-# define gethostbyaddr(a, b, c) (gethostbyaddr_r(a, b, c, &PL_reentrant_buffer->_gethostent_struct, PL_reentrant_buffer->_gethostent_buffer, PL_reentrant_buffer->_gethostent_size, &PL_reentrant_buffer->_gethostent_errno) ? &PL_reentrant_buffer->_gethostent_struct : 0)
+# define gethostbyaddr(a, b, c) (gethostbyaddr_r(a, b, c, &PL_reentrant_buffer->_gethostent_struct, PL_reentrant_buffer->_gethostent_buffer, PL_reentrant_buffer->_gethostent_size, &PL_reentrant_buffer->_gethostent_errno) ? &PL_reentrant_buffer->_gethostent_struct : (errno == ERANGE ? Perl_reentrant_retry("gethostbyaddr", a, b, c) : 0))
# endif
# if !defined(gethostbyaddr) && GETHOSTBYADDR_R_PROTO == REENTRANT_PROTO_S_CSBIE
-# define gethostbyaddr(a, b, c) (gethostbyaddr_r(a, b, c, PL_reentrant_buffer->_gethostent_size, &PL_reentrant_buffer->_gethostent_errno) ? 1 : 0)
+# define gethostbyaddr(a, b, c) (gethostbyaddr_r(a, b, c, PL_reentrant_buffer->_gethostent_size, &PL_reentrant_buffer->_gethostent_errno) ? 1 : (errno == ERANGE ? Perl_reentrant_retry("gethostbyaddr", a, b, c) : 0))
# endif
# if !defined(gethostbyaddr) && GETHOSTBYADDR_R_PROTO == REENTRANT_PROTO_S_TSBIE
-# define gethostbyaddr(a, b, c) (gethostbyaddr_r(a, b, c, PL_reentrant_buffer->_gethostent_size, &PL_reentrant_buffer->_gethostent_errno) ? 1 : 0)
+# define gethostbyaddr(a, b, c) (gethostbyaddr_r(a, b, c, PL_reentrant_buffer->_gethostent_size, &PL_reentrant_buffer->_gethostent_errno) ? 1 : (errno == ERANGE ? Perl_reentrant_retry("gethostbyaddr", a, b, c) : 0))
# endif
# if !defined(gethostbyaddr) && GETHOSTBYADDR_R_PROTO == REENTRANT_PROTO_I_CWISD
-# define gethostbyaddr(a, b, c) (((errno = gethostbyaddr_r(a, b, c, &PL_reentrant_buffer->_gethostent_struct, &PL_reentrant_buffer->_gethostent_data))) == 0 ? &PL_reentrant_buffer->_gethostent_struct : 0)
+# define gethostbyaddr(a, b, c) (((errno = gethostbyaddr_r(a, b, c, &PL_reentrant_buffer->_gethostent_struct, &PL_reentrant_buffer->_gethostent_data))) == 0 ? &PL_reentrant_buffer->_gethostent_struct : (errno == ERANGE ? Perl_reentrant_retry("gethostbyaddr", a, b, c) : 0))
# endif
# if !defined(gethostbyaddr) && GETHOSTBYADDR_R_PROTO == REENTRANT_PROTO_I_CIISD
-# define gethostbyaddr(a, b, c) (((errno = gethostbyaddr_r(a, b, c, &PL_reentrant_buffer->_gethostent_struct, &PL_reentrant_buffer->_gethostent_data))) == 0 ? &PL_reentrant_buffer->_gethostent_struct : 0)
+# define gethostbyaddr(a, b, c) (((errno = gethostbyaddr_r(a, b, c, &PL_reentrant_buffer->_gethostent_struct, &PL_reentrant_buffer->_gethostent_data))) == 0 ? &PL_reentrant_buffer->_gethostent_struct : (errno == ERANGE ? Perl_reentrant_retry("gethostbyaddr", a, b, c) : 0))
# endif
# if !defined(gethostbyaddr) && GETHOSTBYADDR_R_PROTO == REENTRANT_PROTO_I_CII
-# define gethostbyaddr(a, b, c) (((errno = gethostbyaddr_r(a, b, c))) == 0 ? 1 : 0)
+# define gethostbyaddr(a, b, c) (((errno = gethostbyaddr_r(a, b, c))) == 0 ? 1 : (errno == ERANGE ? Perl_reentrant_retry("gethostbyaddr", a, b, c) : 0))
# endif
#endif /* HAS_GETHOSTBYADDR_R */
#ifdef HAS_GETHOSTBYNAME_R
# undef gethostbyname
# if !defined(gethostbyname) && GETHOSTBYNAME_R_PROTO == REENTRANT_PROTO_I_CSBWRE
-# define gethostbyname(a) (((errno = gethostbyname_r(a, &PL_reentrant_buffer->_gethostent_struct, PL_reentrant_buffer->_gethostent_buffer, PL_reentrant_buffer->_gethostent_size, &PL_reentrant_buffer->_gethostent_ptr, &PL_reentrant_buffer->_gethostent_errno))) == 0 ? PL_reentrant_buffer->_gethostent_ptr : 0)
+# define gethostbyname(a) (((errno = gethostbyname_r(a, &PL_reentrant_buffer->_gethostent_struct, PL_reentrant_buffer->_gethostent_buffer, PL_reentrant_buffer->_gethostent_size, &PL_reentrant_buffer->_gethostent_ptr, &PL_reentrant_buffer->_gethostent_errno))) == 0 ? PL_reentrant_buffer->_gethostent_ptr : (errno == ERANGE ? Perl_reentrant_retry("gethostbyname", a) : 0))
# endif
# if !defined(gethostbyname) && GETHOSTBYNAME_R_PROTO == REENTRANT_PROTO_S_CSBIE
-# define gethostbyname(a) (gethostbyname_r(a, &PL_reentrant_buffer->_gethostent_struct, PL_reentrant_buffer->_gethostent_buffer, PL_reentrant_buffer->_gethostent_size, &PL_reentrant_buffer->_gethostent_errno) ? &PL_reentrant_buffer->_gethostent_struct : 0)
+# define gethostbyname(a) (gethostbyname_r(a, &PL_reentrant_buffer->_gethostent_struct, PL_reentrant_buffer->_gethostent_buffer, PL_reentrant_buffer->_gethostent_size, &PL_reentrant_buffer->_gethostent_errno) ? &PL_reentrant_buffer->_gethostent_struct : (errno == ERANGE ? Perl_reentrant_retry("gethostbyname", a) : 0))
# endif
# if !defined(gethostbyname) && GETHOSTBYNAME_R_PROTO == REENTRANT_PROTO_I_CSD
-# define gethostbyname(a) (((errno = gethostbyname_r(a, &PL_reentrant_buffer->_gethostent_struct, &PL_reentrant_buffer->_gethostent_data))) == 0 ? &PL_reentrant_buffer->_gethostent_struct : 0)
+# define gethostbyname(a) (((errno = gethostbyname_r(a, &PL_reentrant_buffer->_gethostent_struct, &PL_reentrant_buffer->_gethostent_data))) == 0 ? &PL_reentrant_buffer->_gethostent_struct : (errno == ERANGE ? Perl_reentrant_retry("gethostbyname", a) : 0))
# endif
#endif /* HAS_GETHOSTBYNAME_R */
#ifdef HAS_GETHOSTENT_R
# undef gethostent
# if !defined(gethostent) && GETHOSTENT_R_PROTO == REENTRANT_PROTO_I_SBWRE
-# define gethostent() (((errno = gethostent_r(&PL_reentrant_buffer->_gethostent_struct, PL_reentrant_buffer->_gethostent_buffer, PL_reentrant_buffer->_gethostent_size, &PL_reentrant_buffer->_gethostent_ptr, &PL_reentrant_buffer->_gethostent_errno))) == 0 ? PL_reentrant_buffer->_gethostent_ptr : 0)
+# define gethostent() (((errno = gethostent_r(&PL_reentrant_buffer->_gethostent_struct, PL_reentrant_buffer->_gethostent_buffer, PL_reentrant_buffer->_gethostent_size, &PL_reentrant_buffer->_gethostent_ptr, &PL_reentrant_buffer->_gethostent_errno))) == 0 ? PL_reentrant_buffer->_gethostent_ptr : (errno == ERANGE ? Perl_reentrant_retry("gethostent") : 0))
# endif
# if !defined(gethostent) && GETHOSTENT_R_PROTO == REENTRANT_PROTO_I_SBIE
-# define gethostent() (((errno = gethostent_r(&PL_reentrant_buffer->_gethostent_struct, PL_reentrant_buffer->_gethostent_buffer, PL_reentrant_buffer->_gethostent_size, &PL_reentrant_buffer->_gethostent_errno))) == 0 ? &PL_reentrant_buffer->_gethostent_struct : 0)
+# define gethostent() (((errno = gethostent_r(&PL_reentrant_buffer->_gethostent_struct, PL_reentrant_buffer->_gethostent_buffer, PL_reentrant_buffer->_gethostent_size, &PL_reentrant_buffer->_gethostent_errno))) == 0 ? &PL_reentrant_buffer->_gethostent_struct : (errno == ERANGE ? Perl_reentrant_retry("gethostent") : 0))
# endif
# if !defined(gethostent) && GETHOSTENT_R_PROTO == REENTRANT_PROTO_S_SBIE
-# define gethostent() (gethostent_r(&PL_reentrant_buffer->_gethostent_struct, PL_reentrant_buffer->_gethostent_buffer, PL_reentrant_buffer->_gethostent_size, &PL_reentrant_buffer->_gethostent_errno) ? &PL_reentrant_buffer->_gethostent_struct : 0)
+# define gethostent() (gethostent_r(&PL_reentrant_buffer->_gethostent_struct, PL_reentrant_buffer->_gethostent_buffer, PL_reentrant_buffer->_gethostent_size, &PL_reentrant_buffer->_gethostent_errno) ? &PL_reentrant_buffer->_gethostent_struct : (errno == ERANGE ? Perl_reentrant_retry("gethostent") : 0))
# endif
# if !defined(gethostent) && GETHOSTENT_R_PROTO == REENTRANT_PROTO_S_SBI
-# define gethostent() (gethostent_r(&PL_reentrant_buffer->_gethostent_struct, PL_reentrant_buffer->_gethostent_buffer, PL_reentrant_buffer->_gethostent_size) ? &PL_reentrant_buffer->_gethostent_struct : 0)
+# define gethostent() (gethostent_r(&PL_reentrant_buffer->_gethostent_struct, PL_reentrant_buffer->_gethostent_buffer, PL_reentrant_buffer->_gethostent_size) ? &PL_reentrant_buffer->_gethostent_struct : (errno == ERANGE ? Perl_reentrant_retry("gethostent") : 0))
# endif
# if !defined(gethostent) && GETHOSTENT_R_PROTO == REENTRANT_PROTO_I_SBI
-# define gethostent() (((errno = gethostent_r(&PL_reentrant_buffer->_gethostent_struct, PL_reentrant_buffer->_gethostent_buffer, PL_reentrant_buffer->_gethostent_size))) == 0 ? &PL_reentrant_buffer->_gethostent_struct : 0)
+# define gethostent() (((errno = gethostent_r(&PL_reentrant_buffer->_gethostent_struct, PL_reentrant_buffer->_gethostent_buffer, PL_reentrant_buffer->_gethostent_size))) == 0 ? &PL_reentrant_buffer->_gethostent_struct : (errno == ERANGE ? Perl_reentrant_retry("gethostent") : 0))
# endif
# if !defined(gethostent) && GETHOSTENT_R_PROTO == REENTRANT_PROTO_I_SD
-# define gethostent() (((errno = gethostent_r(&PL_reentrant_buffer->_gethostent_struct, &PL_reentrant_buffer->_gethostent_data))) == 0 ? &PL_reentrant_buffer->_gethostent_struct : 0)
+# define gethostent() (((errno = gethostent_r(&PL_reentrant_buffer->_gethostent_struct, &PL_reentrant_buffer->_gethostent_data))) == 0 ? &PL_reentrant_buffer->_gethostent_struct : (errno == ERANGE ? Perl_reentrant_retry("gethostent") : 0))
# endif
#endif /* HAS_GETHOSTENT_R */
#ifdef HAS_GETLOGIN_R
# undef getlogin
# if !defined(getlogin) && GETLOGIN_R_PROTO == REENTRANT_PROTO_I_BW
-# define getlogin() (((errno = getlogin_r(PL_reentrant_buffer->_getlogin_buffer, PL_reentrant_buffer->_getlogin_size))) == 0 ? PL_reentrant_buffer->_getlogin_buffer : 0)
+# define getlogin() (((errno = getlogin_r(PL_reentrant_buffer->_getlogin_buffer, PL_reentrant_buffer->_getlogin_size))) == 0 ? PL_reentrant_buffer->_getlogin_buffer : (errno == ERANGE ? Perl_reentrant_retry("getlogin") : 0))
# endif
# if !defined(getlogin) && GETLOGIN_R_PROTO == REENTRANT_PROTO_I_BI
-# define getlogin() (((errno = getlogin_r(PL_reentrant_buffer->_getlogin_buffer, PL_reentrant_buffer->_getlogin_size))) == 0 ? PL_reentrant_buffer->_getlogin_buffer : 0)
+# define getlogin() (((errno = getlogin_r(PL_reentrant_buffer->_getlogin_buffer, PL_reentrant_buffer->_getlogin_size))) == 0 ? PL_reentrant_buffer->_getlogin_buffer : (errno == ERANGE ? Perl_reentrant_retry("getlogin") : 0))
# endif
# if !defined(getlogin) && GETLOGIN_R_PROTO == REENTRANT_PROTO_B_BW
# define getlogin() getlogin_r(PL_reentrant_buffer->_getlogin_buffer, PL_reentrant_buffer->_getlogin_size)
@@ -826,211 +977,211 @@ typedef struct {
#ifdef HAS_GETNETBYADDR_R
# undef getnetbyaddr
# if !defined(getnetbyaddr) && GETNETBYADDR_R_PROTO == REENTRANT_PROTO_I_UISBWRE
-# define getnetbyaddr(a, b) (((errno = getnetbyaddr_r(a, b, &PL_reentrant_buffer->_getnetent_struct, PL_reentrant_buffer->_getnetent_buffer, PL_reentrant_buffer->_getnetent_size, &PL_reentrant_buffer->_getnetent_ptr, &PL_reentrant_buffer->_getnetent_errno))) == 0 ? PL_reentrant_buffer->_getnetent_ptr : 0)
+# define getnetbyaddr(a, b) (((errno = getnetbyaddr_r(a, b, &PL_reentrant_buffer->_getnetent_struct, PL_reentrant_buffer->_getnetent_buffer, PL_reentrant_buffer->_getnetent_size, &PL_reentrant_buffer->_getnetent_ptr, &PL_reentrant_buffer->_getnetent_errno))) == 0 ? PL_reentrant_buffer->_getnetent_ptr : (errno == ERANGE ? Perl_reentrant_retry("getnetbyaddr", a, b) : 0))
# endif
# if !defined(getnetbyaddr) && GETNETBYADDR_R_PROTO == REENTRANT_PROTO_I_LISBI
-# define getnetbyaddr(a, b) (((errno = getnetbyaddr_r(a, b, &PL_reentrant_buffer->_getnetent_struct, PL_reentrant_buffer->_getnetent_buffer, PL_reentrant_buffer->_getnetent_size))) == 0 ? &PL_reentrant_buffer->_getnetent_struct : 0)
+# define getnetbyaddr(a, b) (((errno = getnetbyaddr_r(a, b, &PL_reentrant_buffer->_getnetent_struct, PL_reentrant_buffer->_getnetent_buffer, PL_reentrant_buffer->_getnetent_size))) == 0 ? &PL_reentrant_buffer->_getnetent_struct : (errno == ERANGE ? Perl_reentrant_retry("getnetbyaddr", a, b) : 0))
# endif
# if !defined(getnetbyaddr) && GETNETBYADDR_R_PROTO == REENTRANT_PROTO_S_TISBI
-# define getnetbyaddr(a, b) (getnetbyaddr_r(a, b, &PL_reentrant_buffer->_getnetent_struct, PL_reentrant_buffer->_getnetent_buffer, PL_reentrant_buffer->_getnetent_size) ? &PL_reentrant_buffer->_getnetent_struct : 0)
+# define getnetbyaddr(a, b) (getnetbyaddr_r(a, b, &PL_reentrant_buffer->_getnetent_struct, PL_reentrant_buffer->_getnetent_buffer, PL_reentrant_buffer->_getnetent_size) ? &PL_reentrant_buffer->_getnetent_struct : (errno == ERANGE ? Perl_reentrant_retry("getnetbyaddr", a, b) : 0))
# endif
# if !defined(getnetbyaddr) && GETNETBYADDR_R_PROTO == REENTRANT_PROTO_S_LISBI
-# define getnetbyaddr(a, b) (getnetbyaddr_r(a, b, &PL_reentrant_buffer->_getnetent_struct, PL_reentrant_buffer->_getnetent_buffer, PL_reentrant_buffer->_getnetent_size) ? &PL_reentrant_buffer->_getnetent_struct : 0)
+# define getnetbyaddr(a, b) (getnetbyaddr_r(a, b, &PL_reentrant_buffer->_getnetent_struct, PL_reentrant_buffer->_getnetent_buffer, PL_reentrant_buffer->_getnetent_size) ? &PL_reentrant_buffer->_getnetent_struct : (errno == ERANGE ? Perl_reentrant_retry("getnetbyaddr", a, b) : 0))
# endif
# if !defined(getnetbyaddr) && GETNETBYADDR_R_PROTO == REENTRANT_PROTO_I_TISD
-# define getnetbyaddr(a, b) (((errno = getnetbyaddr_r(a, b, &PL_reentrant_buffer->_getnetent_struct, &PL_reentrant_buffer->_getnetent_data))) == 0 ? &PL_reentrant_buffer->_getnetent_struct : 0)
+# define getnetbyaddr(a, b) (((errno = getnetbyaddr_r(a, b, &PL_reentrant_buffer->_getnetent_struct, &PL_reentrant_buffer->_getnetent_data))) == 0 ? &PL_reentrant_buffer->_getnetent_struct : (errno == ERANGE ? Perl_reentrant_retry("getnetbyaddr", a, b) : 0))
# endif
# if !defined(getnetbyaddr) && GETNETBYADDR_R_PROTO == REENTRANT_PROTO_I_LISD
-# define getnetbyaddr(a, b) (((errno = getnetbyaddr_r(a, b, &PL_reentrant_buffer->_getnetent_struct, &PL_reentrant_buffer->_getnetent_data))) == 0 ? &PL_reentrant_buffer->_getnetent_struct : 0)
+# define getnetbyaddr(a, b) (((errno = getnetbyaddr_r(a, b, &PL_reentrant_buffer->_getnetent_struct, &PL_reentrant_buffer->_getnetent_data))) == 0 ? &PL_reentrant_buffer->_getnetent_struct : (errno == ERANGE ? Perl_reentrant_retry("getnetbyaddr", a, b) : 0))
# endif
# if !defined(getnetbyaddr) && GETNETBYADDR_R_PROTO == REENTRANT_PROTO_I_IISD
-# define getnetbyaddr(a, b) (((errno = getnetbyaddr_r(a, b, &PL_reentrant_buffer->_getnetent_struct, &PL_reentrant_buffer->_getnetent_data))) == 0 ? &PL_reentrant_buffer->_getnetent_struct : 0)
+# define getnetbyaddr(a, b) (((errno = getnetbyaddr_r(a, b, &PL_reentrant_buffer->_getnetent_struct, &PL_reentrant_buffer->_getnetent_data))) == 0 ? &PL_reentrant_buffer->_getnetent_struct : (errno == ERANGE ? Perl_reentrant_retry("getnetbyaddr", a, b) : 0))
# endif
#endif /* HAS_GETNETBYADDR_R */
#ifdef HAS_GETNETBYNAME_R
# undef getnetbyname
# if !defined(getnetbyname) && GETNETBYNAME_R_PROTO == REENTRANT_PROTO_I_CSBWRE
-# define getnetbyname(a) (((errno = getnetbyname_r(a, &PL_reentrant_buffer->_getnetent_struct, PL_reentrant_buffer->_getnetent_buffer, PL_reentrant_buffer->_getnetent_size, &PL_reentrant_buffer->_getnetent_ptr, &PL_reentrant_buffer->_getnetent_errno))) == 0 ? PL_reentrant_buffer->_getnetent_ptr : 0)
+# define getnetbyname(a) (((errno = getnetbyname_r(a, &PL_reentrant_buffer->_getnetent_struct, PL_reentrant_buffer->_getnetent_buffer, PL_reentrant_buffer->_getnetent_size, &PL_reentrant_buffer->_getnetent_ptr, &PL_reentrant_buffer->_getnetent_errno))) == 0 ? PL_reentrant_buffer->_getnetent_ptr : (errno == ERANGE ? Perl_reentrant_retry("getnetbyname", a) : 0))
# endif
# if !defined(getnetbyname) && GETNETBYNAME_R_PROTO == REENTRANT_PROTO_I_CSBI
-# define getnetbyname(a) (((errno = getnetbyname_r(a, &PL_reentrant_buffer->_getnetent_struct, PL_reentrant_buffer->_getnetent_buffer, PL_reentrant_buffer->_getnetent_size))) == 0 ? &PL_reentrant_buffer->_getnetent_struct : 0)
+# define getnetbyname(a) (((errno = getnetbyname_r(a, &PL_reentrant_buffer->_getnetent_struct, PL_reentrant_buffer->_getnetent_buffer, PL_reentrant_buffer->_getnetent_size))) == 0 ? &PL_reentrant_buffer->_getnetent_struct : (errno == ERANGE ? Perl_reentrant_retry("getnetbyname", a) : 0))
# endif
# if !defined(getnetbyname) && GETNETBYNAME_R_PROTO == REENTRANT_PROTO_S_CSBI
-# define getnetbyname(a) (getnetbyname_r(a, &PL_reentrant_buffer->_getnetent_struct, PL_reentrant_buffer->_getnetent_buffer, PL_reentrant_buffer->_getnetent_size) ? &PL_reentrant_buffer->_getnetent_struct : 0)
+# define getnetbyname(a) (getnetbyname_r(a, &PL_reentrant_buffer->_getnetent_struct, PL_reentrant_buffer->_getnetent_buffer, PL_reentrant_buffer->_getnetent_size) ? &PL_reentrant_buffer->_getnetent_struct : (errno == ERANGE ? Perl_reentrant_retry("getnetbyname", a) : 0))
# endif
# if !defined(getnetbyname) && GETNETBYNAME_R_PROTO == REENTRANT_PROTO_I_CSD
-# define getnetbyname(a) (((errno = getnetbyname_r(a, &PL_reentrant_buffer->_getnetent_struct, &PL_reentrant_buffer->_getnetent_data))) == 0 ? &PL_reentrant_buffer->_getnetent_struct : 0)
+# define getnetbyname(a) (((errno = getnetbyname_r(a, &PL_reentrant_buffer->_getnetent_struct, &PL_reentrant_buffer->_getnetent_data))) == 0 ? &PL_reentrant_buffer->_getnetent_struct : (errno == ERANGE ? Perl_reentrant_retry("getnetbyname", a) : 0))
# endif
#endif /* HAS_GETNETBYNAME_R */
#ifdef HAS_GETNETENT_R
# undef getnetent
# if !defined(getnetent) && GETNETENT_R_PROTO == REENTRANT_PROTO_I_SBWRE
-# define getnetent() (((errno = getnetent_r(&PL_reentrant_buffer->_getnetent_struct, PL_reentrant_buffer->_getnetent_buffer, PL_reentrant_buffer->_getnetent_size, &PL_reentrant_buffer->_getnetent_ptr, &PL_reentrant_buffer->_getnetent_errno))) == 0 ? PL_reentrant_buffer->_getnetent_ptr : 0)
+# define getnetent() (((errno = getnetent_r(&PL_reentrant_buffer->_getnetent_struct, PL_reentrant_buffer->_getnetent_buffer, PL_reentrant_buffer->_getnetent_size, &PL_reentrant_buffer->_getnetent_ptr, &PL_reentrant_buffer->_getnetent_errno))) == 0 ? PL_reentrant_buffer->_getnetent_ptr : (errno == ERANGE ? Perl_reentrant_retry("getnetent") : 0))
# endif
# if !defined(getnetent) && GETNETENT_R_PROTO == REENTRANT_PROTO_I_SBIE
-# define getnetent() (((errno = getnetent_r(&PL_reentrant_buffer->_getnetent_struct, PL_reentrant_buffer->_getnetent_buffer, PL_reentrant_buffer->_getnetent_size, &PL_reentrant_buffer->_getnetent_errno))) == 0 ? &PL_reentrant_buffer->_getnetent_struct : 0)
+# define getnetent() (((errno = getnetent_r(&PL_reentrant_buffer->_getnetent_struct, PL_reentrant_buffer->_getnetent_buffer, PL_reentrant_buffer->_getnetent_size, &PL_reentrant_buffer->_getnetent_errno))) == 0 ? &PL_reentrant_buffer->_getnetent_struct : (errno == ERANGE ? Perl_reentrant_retry("getnetent") : 0))
# endif
# if !defined(getnetent) && GETNETENT_R_PROTO == REENTRANT_PROTO_S_SBIE
-# define getnetent() (getnetent_r(&PL_reentrant_buffer->_getnetent_struct, PL_reentrant_buffer->_getnetent_buffer, PL_reentrant_buffer->_getnetent_size, &PL_reentrant_buffer->_getnetent_errno) ? &PL_reentrant_buffer->_getnetent_struct : 0)
+# define getnetent() (getnetent_r(&PL_reentrant_buffer->_getnetent_struct, PL_reentrant_buffer->_getnetent_buffer, PL_reentrant_buffer->_getnetent_size, &PL_reentrant_buffer->_getnetent_errno) ? &PL_reentrant_buffer->_getnetent_struct : (errno == ERANGE ? Perl_reentrant_retry("getnetent") : 0))
# endif
# if !defined(getnetent) && GETNETENT_R_PROTO == REENTRANT_PROTO_S_SBI
-# define getnetent() (getnetent_r(&PL_reentrant_buffer->_getnetent_struct, PL_reentrant_buffer->_getnetent_buffer, PL_reentrant_buffer->_getnetent_size) ? &PL_reentrant_buffer->_getnetent_struct : 0)
+# define getnetent() (getnetent_r(&PL_reentrant_buffer->_getnetent_struct, PL_reentrant_buffer->_getnetent_buffer, PL_reentrant_buffer->_getnetent_size) ? &PL_reentrant_buffer->_getnetent_struct : (errno == ERANGE ? Perl_reentrant_retry("getnetent") : 0))
# endif
# if !defined(getnetent) && GETNETENT_R_PROTO == REENTRANT_PROTO_I_SBI
-# define getnetent() (((errno = getnetent_r(&PL_reentrant_buffer->_getnetent_struct, PL_reentrant_buffer->_getnetent_buffer, PL_reentrant_buffer->_getnetent_size))) == 0 ? &PL_reentrant_buffer->_getnetent_struct : 0)
+# define getnetent() (((errno = getnetent_r(&PL_reentrant_buffer->_getnetent_struct, PL_reentrant_buffer->_getnetent_buffer, PL_reentrant_buffer->_getnetent_size))) == 0 ? &PL_reentrant_buffer->_getnetent_struct : (errno == ERANGE ? Perl_reentrant_retry("getnetent") : 0))
# endif
# if !defined(getnetent) && GETNETENT_R_PROTO == REENTRANT_PROTO_I_SD
-# define getnetent() (((errno = getnetent_r(&PL_reentrant_buffer->_getnetent_struct, &PL_reentrant_buffer->_getnetent_data))) == 0 ? &PL_reentrant_buffer->_getnetent_struct : 0)
+# define getnetent() (((errno = getnetent_r(&PL_reentrant_buffer->_getnetent_struct, &PL_reentrant_buffer->_getnetent_data))) == 0 ? &PL_reentrant_buffer->_getnetent_struct : (errno == ERANGE ? Perl_reentrant_retry("getnetent") : 0))
# endif
#endif /* HAS_GETNETENT_R */
#ifdef HAS_GETPROTOBYNAME_R
# undef getprotobyname
# if !defined(getprotobyname) && GETPROTOBYNAME_R_PROTO == REENTRANT_PROTO_I_CSBWR
-# define getprotobyname(a) (((errno = getprotobyname_r(a, &PL_reentrant_buffer->_getprotoent_struct, PL_reentrant_buffer->_getprotoent_buffer, PL_reentrant_buffer->_getprotoent_size, &PL_reentrant_buffer->_getprotoent_ptr))) == 0 ? PL_reentrant_buffer->_getprotoent_ptr : 0)
+# define getprotobyname(a) (((errno = getprotobyname_r(a, &PL_reentrant_buffer->_getprotoent_struct, PL_reentrant_buffer->_getprotoent_buffer, PL_reentrant_buffer->_getprotoent_size, &PL_reentrant_buffer->_getprotoent_ptr))) == 0 ? PL_reentrant_buffer->_getprotoent_ptr : (errno == ERANGE ? Perl_reentrant_retry("getprotobyname", a) : 0))
# endif
# if !defined(getprotobyname) && GETPROTOBYNAME_R_PROTO == REENTRANT_PROTO_S_CSBI
-# define getprotobyname(a) (getprotobyname_r(a, &PL_reentrant_buffer->_getprotoent_struct, PL_reentrant_buffer->_getprotoent_buffer, PL_reentrant_buffer->_getprotoent_size) ? &PL_reentrant_buffer->_getprotoent_struct : 0)
+# define getprotobyname(a) (getprotobyname_r(a, &PL_reentrant_buffer->_getprotoent_struct, PL_reentrant_buffer->_getprotoent_buffer, PL_reentrant_buffer->_getprotoent_size) ? &PL_reentrant_buffer->_getprotoent_struct : (errno == ERANGE ? Perl_reentrant_retry("getprotobyname", a) : 0))
# endif
# if !defined(getprotobyname) && GETPROTOBYNAME_R_PROTO == REENTRANT_PROTO_I_CSD
-# define getprotobyname(a) (((errno = getprotobyname_r(a, &PL_reentrant_buffer->_getprotoent_struct, &PL_reentrant_buffer->_getprotoent_data))) == 0 ? &PL_reentrant_buffer->_getprotoent_struct : 0)
+# define getprotobyname(a) (((errno = getprotobyname_r(a, &PL_reentrant_buffer->_getprotoent_struct, &PL_reentrant_buffer->_getprotoent_data))) == 0 ? &PL_reentrant_buffer->_getprotoent_struct : (errno == ERANGE ? Perl_reentrant_retry("getprotobyname", a) : 0))
# endif
#endif /* HAS_GETPROTOBYNAME_R */
#ifdef HAS_GETPROTOBYNUMBER_R
# undef getprotobynumber
# if !defined(getprotobynumber) && GETPROTOBYNUMBER_R_PROTO == REENTRANT_PROTO_I_ISBWR
-# define getprotobynumber(a) (((errno = getprotobynumber_r(a, &PL_reentrant_buffer->_getprotoent_struct, PL_reentrant_buffer->_getprotoent_buffer, PL_reentrant_buffer->_getprotoent_size, &PL_reentrant_buffer->_getprotoent_ptr))) == 0 ? PL_reentrant_buffer->_getprotoent_ptr : 0)
+# define getprotobynumber(a) (((errno = getprotobynumber_r(a, &PL_reentrant_buffer->_getprotoent_struct, PL_reentrant_buffer->_getprotoent_buffer, PL_reentrant_buffer->_getprotoent_size, &PL_reentrant_buffer->_getprotoent_ptr))) == 0 ? PL_reentrant_buffer->_getprotoent_ptr : (errno == ERANGE ? Perl_reentrant_retry("getprotobynumber", a) : 0))
# endif
# if !defined(getprotobynumber) && GETPROTOBYNUMBER_R_PROTO == REENTRANT_PROTO_S_ISBI
-# define getprotobynumber(a) (getprotobynumber_r(a, &PL_reentrant_buffer->_getprotoent_struct, PL_reentrant_buffer->_getprotoent_buffer, PL_reentrant_buffer->_getprotoent_size) ? &PL_reentrant_buffer->_getprotoent_struct : 0)
+# define getprotobynumber(a) (getprotobynumber_r(a, &PL_reentrant_buffer->_getprotoent_struct, PL_reentrant_buffer->_getprotoent_buffer, PL_reentrant_buffer->_getprotoent_size) ? &PL_reentrant_buffer->_getprotoent_struct : (errno == ERANGE ? Perl_reentrant_retry("getprotobynumber", a) : 0))
# endif
# if !defined(getprotobynumber) && GETPROTOBYNUMBER_R_PROTO == REENTRANT_PROTO_I_ISD
-# define getprotobynumber(a) (((errno = getprotobynumber_r(a, &PL_reentrant_buffer->_getprotoent_struct, &PL_reentrant_buffer->_getprotoent_data))) == 0 ? &PL_reentrant_buffer->_getprotoent_struct : 0)
+# define getprotobynumber(a) (((errno = getprotobynumber_r(a, &PL_reentrant_buffer->_getprotoent_struct, &PL_reentrant_buffer->_getprotoent_data))) == 0 ? &PL_reentrant_buffer->_getprotoent_struct : (errno == ERANGE ? Perl_reentrant_retry("getprotobynumber", a) : 0))
# endif
#endif /* HAS_GETPROTOBYNUMBER_R */
#ifdef HAS_GETPROTOENT_R
# undef getprotoent
# if !defined(getprotoent) && GETPROTOENT_R_PROTO == REENTRANT_PROTO_I_SBWR
-# define getprotoent() (((errno = getprotoent_r(&PL_reentrant_buffer->_getprotoent_struct, PL_reentrant_buffer->_getprotoent_buffer, PL_reentrant_buffer->_getprotoent_size, &PL_reentrant_buffer->_getprotoent_ptr))) == 0 ? PL_reentrant_buffer->_getprotoent_ptr : 0)
+# define getprotoent() (((errno = getprotoent_r(&PL_reentrant_buffer->_getprotoent_struct, PL_reentrant_buffer->_getprotoent_buffer, PL_reentrant_buffer->_getprotoent_size, &PL_reentrant_buffer->_getprotoent_ptr))) == 0 ? PL_reentrant_buffer->_getprotoent_ptr : (errno == ERANGE ? Perl_reentrant_retry("getprotoent") : 0))
# endif
# if !defined(getprotoent) && GETPROTOENT_R_PROTO == REENTRANT_PROTO_I_SBI
-# define getprotoent() (((errno = getprotoent_r(&PL_reentrant_buffer->_getprotoent_struct, PL_reentrant_buffer->_getprotoent_buffer, PL_reentrant_buffer->_getprotoent_size))) == 0 ? &PL_reentrant_buffer->_getprotoent_struct : 0)
+# define getprotoent() (((errno = getprotoent_r(&PL_reentrant_buffer->_getprotoent_struct, PL_reentrant_buffer->_getprotoent_buffer, PL_reentrant_buffer->_getprotoent_size))) == 0 ? &PL_reentrant_buffer->_getprotoent_struct : (errno == ERANGE ? Perl_reentrant_retry("getprotoent") : 0))
# endif
# if !defined(getprotoent) && GETPROTOENT_R_PROTO == REENTRANT_PROTO_S_SBI
-# define getprotoent() (getprotoent_r(&PL_reentrant_buffer->_getprotoent_struct, PL_reentrant_buffer->_getprotoent_buffer, PL_reentrant_buffer->_getprotoent_size) ? &PL_reentrant_buffer->_getprotoent_struct : 0)
+# define getprotoent() (getprotoent_r(&PL_reentrant_buffer->_getprotoent_struct, PL_reentrant_buffer->_getprotoent_buffer, PL_reentrant_buffer->_getprotoent_size) ? &PL_reentrant_buffer->_getprotoent_struct : (errno == ERANGE ? Perl_reentrant_retry("getprotoent") : 0))
# endif
# if !defined(getprotoent) && GETPROTOENT_R_PROTO == REENTRANT_PROTO_I_SD
-# define getprotoent() (((errno = getprotoent_r(&PL_reentrant_buffer->_getprotoent_struct, &PL_reentrant_buffer->_getprotoent_data))) == 0 ? &PL_reentrant_buffer->_getprotoent_struct : 0)
+# define getprotoent() (((errno = getprotoent_r(&PL_reentrant_buffer->_getprotoent_struct, &PL_reentrant_buffer->_getprotoent_data))) == 0 ? &PL_reentrant_buffer->_getprotoent_struct : (errno == ERANGE ? Perl_reentrant_retry("getprotoent") : 0))
# endif
#endif /* HAS_GETPROTOENT_R */
#ifdef HAS_GETPWENT_R
# undef getpwent
# if !defined(getpwent) && GETPWENT_R_PROTO == REENTRANT_PROTO_I_SBWR
-# define getpwent() (((errno = getpwent_r(&PL_reentrant_buffer->_getpwent_struct, PL_reentrant_buffer->_getpwent_buffer, PL_reentrant_buffer->_getpwent_size, &PL_reentrant_buffer->_getpwent_ptr))) == 0 ? PL_reentrant_buffer->_getpwent_ptr : 0)
+# define getpwent() (((errno = getpwent_r(&PL_reentrant_buffer->_getpwent_struct, PL_reentrant_buffer->_getpwent_buffer, PL_reentrant_buffer->_getpwent_size, &PL_reentrant_buffer->_getpwent_ptr))) == 0 ? PL_reentrant_buffer->_getpwent_ptr : (errno == ERANGE ? Perl_reentrant_retry("getpwent") : 0))
# endif
# if !defined(getpwent) && GETPWENT_R_PROTO == REENTRANT_PROTO_I_SBIR
-# define getpwent() (((errno = getpwent_r(&PL_reentrant_buffer->_getpwent_struct, PL_reentrant_buffer->_getpwent_buffer, PL_reentrant_buffer->_getpwent_size, &PL_reentrant_buffer->_getpwent_ptr))) == 0 ? PL_reentrant_buffer->_getpwent_ptr : 0)
+# define getpwent() (((errno = getpwent_r(&PL_reentrant_buffer->_getpwent_struct, PL_reentrant_buffer->_getpwent_buffer, PL_reentrant_buffer->_getpwent_size, &PL_reentrant_buffer->_getpwent_ptr))) == 0 ? PL_reentrant_buffer->_getpwent_ptr : (errno == ERANGE ? Perl_reentrant_retry("getpwent") : 0))
# endif
# if !defined(getpwent) && GETPWENT_R_PROTO == REENTRANT_PROTO_S_SBW
-# define getpwent() (getpwent_r(&PL_reentrant_buffer->_getpwent_struct, PL_reentrant_buffer->_getpwent_buffer, PL_reentrant_buffer->_getpwent_size) ? &PL_reentrant_buffer->_getpwent_struct : 0)
+# define getpwent() (getpwent_r(&PL_reentrant_buffer->_getpwent_struct, PL_reentrant_buffer->_getpwent_buffer, PL_reentrant_buffer->_getpwent_size) ? &PL_reentrant_buffer->_getpwent_struct : (errno == ERANGE ? Perl_reentrant_retry("getpwent") : 0))
# endif
# if !defined(getpwent) && GETPWENT_R_PROTO == REENTRANT_PROTO_S_SBI
-# define getpwent() (getpwent_r(&PL_reentrant_buffer->_getpwent_struct, PL_reentrant_buffer->_getpwent_buffer, PL_reentrant_buffer->_getpwent_size) ? &PL_reentrant_buffer->_getpwent_struct : 0)
+# define getpwent() (getpwent_r(&PL_reentrant_buffer->_getpwent_struct, PL_reentrant_buffer->_getpwent_buffer, PL_reentrant_buffer->_getpwent_size) ? &PL_reentrant_buffer->_getpwent_struct : (errno == ERANGE ? Perl_reentrant_retry("getpwent") : 0))
# endif
# if !defined(getpwent) && GETPWENT_R_PROTO == REENTRANT_PROTO_I_SBI
-# define getpwent() (((errno = getpwent_r(&PL_reentrant_buffer->_getpwent_struct, PL_reentrant_buffer->_getpwent_buffer, PL_reentrant_buffer->_getpwent_size))) == 0 ? &PL_reentrant_buffer->_getpwent_struct : 0)
+# define getpwent() (((errno = getpwent_r(&PL_reentrant_buffer->_getpwent_struct, PL_reentrant_buffer->_getpwent_buffer, PL_reentrant_buffer->_getpwent_size))) == 0 ? &PL_reentrant_buffer->_getpwent_struct : (errno == ERANGE ? Perl_reentrant_retry("getpwent") : 0))
# endif
# if !defined(getpwent) && GETPWENT_R_PROTO == REENTRANT_PROTO_I_SBIH
-# define getpwent() (((errno = getpwent_r(&PL_reentrant_buffer->_getpwent_struct, PL_reentrant_buffer->_getpwent_buffer, PL_reentrant_buffer->_getpwent_size, &PL_reentrant_buffer->_getpwent_fptr))) == 0 ? &PL_reentrant_buffer->_getpwent_struct : 0)
+# define getpwent() (((errno = getpwent_r(&PL_reentrant_buffer->_getpwent_struct, PL_reentrant_buffer->_getpwent_buffer, PL_reentrant_buffer->_getpwent_size, &PL_reentrant_buffer->_getpwent_fptr))) == 0 ? &PL_reentrant_buffer->_getpwent_struct : (errno == ERANGE ? Perl_reentrant_retry("getpwent") : 0))
# endif
#endif /* HAS_GETPWENT_R */
#ifdef HAS_GETPWNAM_R
# undef getpwnam
# if !defined(getpwnam) && GETPWNAM_R_PROTO == REENTRANT_PROTO_I_CSBWR
-# define getpwnam(a) (((errno = getpwnam_r(a, &PL_reentrant_buffer->_getpwent_struct, PL_reentrant_buffer->_getpwent_buffer, PL_reentrant_buffer->_getpwent_size, &PL_reentrant_buffer->_getpwent_ptr))) == 0 ? PL_reentrant_buffer->_getpwent_ptr : 0)
+# define getpwnam(a) (((errno = getpwnam_r(a, &PL_reentrant_buffer->_getpwent_struct, PL_reentrant_buffer->_getpwent_buffer, PL_reentrant_buffer->_getpwent_size, &PL_reentrant_buffer->_getpwent_ptr))) == 0 ? PL_reentrant_buffer->_getpwent_ptr : (errno == ERANGE ? Perl_reentrant_retry("getpwnam", a) : 0))
# endif
# if !defined(getpwnam) && GETPWNAM_R_PROTO == REENTRANT_PROTO_I_CSBIR
-# define getpwnam(a) (((errno = getpwnam_r(a, &PL_reentrant_buffer->_getpwent_struct, PL_reentrant_buffer->_getpwent_buffer, PL_reentrant_buffer->_getpwent_size, &PL_reentrant_buffer->_getpwent_ptr))) == 0 ? PL_reentrant_buffer->_getpwent_ptr : 0)
+# define getpwnam(a) (((errno = getpwnam_r(a, &PL_reentrant_buffer->_getpwent_struct, PL_reentrant_buffer->_getpwent_buffer, PL_reentrant_buffer->_getpwent_size, &PL_reentrant_buffer->_getpwent_ptr))) == 0 ? PL_reentrant_buffer->_getpwent_ptr : (errno == ERANGE ? Perl_reentrant_retry("getpwnam", a) : 0))
# endif
# if !defined(getpwnam) && GETPWNAM_R_PROTO == REENTRANT_PROTO_S_CSBI
-# define getpwnam(a) (getpwnam_r(a, &PL_reentrant_buffer->_getpwent_struct, PL_reentrant_buffer->_getpwent_buffer, PL_reentrant_buffer->_getpwent_size) ? &PL_reentrant_buffer->_getpwent_struct : 0)
+# define getpwnam(a) (getpwnam_r(a, &PL_reentrant_buffer->_getpwent_struct, PL_reentrant_buffer->_getpwent_buffer, PL_reentrant_buffer->_getpwent_size) ? &PL_reentrant_buffer->_getpwent_struct : (errno == ERANGE ? Perl_reentrant_retry("getpwnam", a) : 0))
# endif
# if !defined(getpwnam) && GETPWNAM_R_PROTO == REENTRANT_PROTO_I_CSBI
-# define getpwnam(a) (((errno = getpwnam_r(a, &PL_reentrant_buffer->_getpwent_struct, PL_reentrant_buffer->_getpwent_buffer, PL_reentrant_buffer->_getpwent_size))) == 0 ? &PL_reentrant_buffer->_getpwent_struct : 0)
+# define getpwnam(a) (((errno = getpwnam_r(a, &PL_reentrant_buffer->_getpwent_struct, PL_reentrant_buffer->_getpwent_buffer, PL_reentrant_buffer->_getpwent_size))) == 0 ? &PL_reentrant_buffer->_getpwent_struct : (errno == ERANGE ? Perl_reentrant_retry("getpwnam", a) : 0))
# endif
#endif /* HAS_GETPWNAM_R */
#ifdef HAS_GETPWUID_R
# undef getpwuid
# if !defined(getpwuid) && GETPWUID_R_PROTO == REENTRANT_PROTO_I_TSBWR
-# define getpwuid(a) (((errno = getpwuid_r(a, &PL_reentrant_buffer->_getpwent_struct, PL_reentrant_buffer->_getpwent_buffer, PL_reentrant_buffer->_getpwent_size, &PL_reentrant_buffer->_getpwent_ptr))) == 0 ? PL_reentrant_buffer->_getpwent_ptr : 0)
+# define getpwuid(a) (((errno = getpwuid_r(a, &PL_reentrant_buffer->_getpwent_struct, PL_reentrant_buffer->_getpwent_buffer, PL_reentrant_buffer->_getpwent_size, &PL_reentrant_buffer->_getpwent_ptr))) == 0 ? PL_reentrant_buffer->_getpwent_ptr : (errno == ERANGE ? Perl_reentrant_retry("getpwuid", a) : 0))
# endif
# if !defined(getpwuid) && GETPWUID_R_PROTO == REENTRANT_PROTO_I_TSBIR
-# define getpwuid(a) (((errno = getpwuid_r(a, &PL_reentrant_buffer->_getpwent_struct, PL_reentrant_buffer->_getpwent_buffer, PL_reentrant_buffer->_getpwent_size, &PL_reentrant_buffer->_getpwent_ptr))) == 0 ? PL_reentrant_buffer->_getpwent_ptr : 0)
+# define getpwuid(a) (((errno = getpwuid_r(a, &PL_reentrant_buffer->_getpwent_struct, PL_reentrant_buffer->_getpwent_buffer, PL_reentrant_buffer->_getpwent_size, &PL_reentrant_buffer->_getpwent_ptr))) == 0 ? PL_reentrant_buffer->_getpwent_ptr : (errno == ERANGE ? Perl_reentrant_retry("getpwuid", a) : 0))
# endif
# if !defined(getpwuid) && GETPWUID_R_PROTO == REENTRANT_PROTO_I_TSBI
-# define getpwuid(a) (((errno = getpwuid_r(a, &PL_reentrant_buffer->_getpwent_struct, PL_reentrant_buffer->_getpwent_buffer, PL_reentrant_buffer->_getpwent_size))) == 0 ? &PL_reentrant_buffer->_getpwent_struct : 0)
+# define getpwuid(a) (((errno = getpwuid_r(a, &PL_reentrant_buffer->_getpwent_struct, PL_reentrant_buffer->_getpwent_buffer, PL_reentrant_buffer->_getpwent_size))) == 0 ? &PL_reentrant_buffer->_getpwent_struct : (errno == ERANGE ? Perl_reentrant_retry("getpwuid", a) : 0))
# endif
# if !defined(getpwuid) && GETPWUID_R_PROTO == REENTRANT_PROTO_S_TSBI
-# define getpwuid(a) (getpwuid_r(a, &PL_reentrant_buffer->_getpwent_struct, PL_reentrant_buffer->_getpwent_buffer, PL_reentrant_buffer->_getpwent_size) ? &PL_reentrant_buffer->_getpwent_struct : 0)
+# define getpwuid(a) (getpwuid_r(a, &PL_reentrant_buffer->_getpwent_struct, PL_reentrant_buffer->_getpwent_buffer, PL_reentrant_buffer->_getpwent_size) ? &PL_reentrant_buffer->_getpwent_struct : (errno == ERANGE ? Perl_reentrant_retry("getpwuid", a) : 0))
# endif
#endif /* HAS_GETPWUID_R */
#ifdef HAS_GETSERVBYNAME_R
# undef getservbyname
# if !defined(getservbyname) && GETSERVBYNAME_R_PROTO == REENTRANT_PROTO_I_CCSBWR
-# define getservbyname(a, b) (((errno = getservbyname_r(a, b, &PL_reentrant_buffer->_getservent_struct, PL_reentrant_buffer->_getservent_buffer, PL_reentrant_buffer->_getservent_size, &PL_reentrant_buffer->_getservent_ptr))) == 0 ? PL_reentrant_buffer->_getservent_ptr : 0)
+# define getservbyname(a, b) (((errno = getservbyname_r(a, b, &PL_reentrant_buffer->_getservent_struct, PL_reentrant_buffer->_getservent_buffer, PL_reentrant_buffer->_getservent_size, &PL_reentrant_buffer->_getservent_ptr))) == 0 ? PL_reentrant_buffer->_getservent_ptr : (errno == ERANGE ? Perl_reentrant_retry("getservbyname", a, b) : 0))
# endif
# if !defined(getservbyname) && GETSERVBYNAME_R_PROTO == REENTRANT_PROTO_S_CCSBI
-# define getservbyname(a, b) (getservbyname_r(a, b, &PL_reentrant_buffer->_getservent_struct, PL_reentrant_buffer->_getservent_buffer, PL_reentrant_buffer->_getservent_size) ? &PL_reentrant_buffer->_getservent_struct : 0)
+# define getservbyname(a, b) (getservbyname_r(a, b, &PL_reentrant_buffer->_getservent_struct, PL_reentrant_buffer->_getservent_buffer, PL_reentrant_buffer->_getservent_size) ? &PL_reentrant_buffer->_getservent_struct : (errno == ERANGE ? Perl_reentrant_retry("getservbyname", a, b) : 0))
# endif
# if !defined(getservbyname) && GETSERVBYNAME_R_PROTO == REENTRANT_PROTO_I_CCSD
-# define getservbyname(a, b) (((errno = getservbyname_r(a, b, &PL_reentrant_buffer->_getservent_struct, &PL_reentrant_buffer->_getservent_data))) == 0 ? &PL_reentrant_buffer->_getservent_struct : 0)
+# define getservbyname(a, b) (((errno = getservbyname_r(a, b, &PL_reentrant_buffer->_getservent_struct, &PL_reentrant_buffer->_getservent_data))) == 0 ? &PL_reentrant_buffer->_getservent_struct : (errno == ERANGE ? Perl_reentrant_retry("getservbyname", a, b) : 0))
# endif
#endif /* HAS_GETSERVBYNAME_R */
#ifdef HAS_GETSERVBYPORT_R
# undef getservbyport
# if !defined(getservbyport) && GETSERVBYPORT_R_PROTO == REENTRANT_PROTO_I_ICSBWR
-# define getservbyport(a, b) (((errno = getservbyport_r(a, b, &PL_reentrant_buffer->_getservent_struct, PL_reentrant_buffer->_getservent_buffer, PL_reentrant_buffer->_getservent_size, &PL_reentrant_buffer->_getservent_ptr))) == 0 ? PL_reentrant_buffer->_getservent_ptr : 0)
+# define getservbyport(a, b) (((errno = getservbyport_r(a, b, &PL_reentrant_buffer->_getservent_struct, PL_reentrant_buffer->_getservent_buffer, PL_reentrant_buffer->_getservent_size, &PL_reentrant_buffer->_getservent_ptr))) == 0 ? PL_reentrant_buffer->_getservent_ptr : (errno == ERANGE ? Perl_reentrant_retry("getservbyport", a, b) : 0))
# endif
# if !defined(getservbyport) && GETSERVBYPORT_R_PROTO == REENTRANT_PROTO_S_ICSBI
-# define getservbyport(a, b) (getservbyport_r(a, b, &PL_reentrant_buffer->_getservent_struct, PL_reentrant_buffer->_getservent_buffer, PL_reentrant_buffer->_getservent_size) ? &PL_reentrant_buffer->_getservent_struct : 0)
+# define getservbyport(a, b) (getservbyport_r(a, b, &PL_reentrant_buffer->_getservent_struct, PL_reentrant_buffer->_getservent_buffer, PL_reentrant_buffer->_getservent_size) ? &PL_reentrant_buffer->_getservent_struct : (errno == ERANGE ? Perl_reentrant_retry("getservbyport", a, b) : 0))
# endif
# if !defined(getservbyport) && GETSERVBYPORT_R_PROTO == REENTRANT_PROTO_I_ICSD
-# define getservbyport(a, b) (((errno = getservbyport_r(a, b, &PL_reentrant_buffer->_getservent_struct, &PL_reentrant_buffer->_getservent_data))) == 0 ? &PL_reentrant_buffer->_getservent_struct : 0)
+# define getservbyport(a, b) (((errno = getservbyport_r(a, b, &PL_reentrant_buffer->_getservent_struct, &PL_reentrant_buffer->_getservent_data))) == 0 ? &PL_reentrant_buffer->_getservent_struct : (errno == ERANGE ? Perl_reentrant_retry("getservbyport", a, b) : 0))
# endif
#endif /* HAS_GETSERVBYPORT_R */
#ifdef HAS_GETSERVENT_R
# undef getservent
# if !defined(getservent) && GETSERVENT_R_PROTO == REENTRANT_PROTO_I_SBWR
-# define getservent() (((errno = getservent_r(&PL_reentrant_buffer->_getservent_struct, PL_reentrant_buffer->_getservent_buffer, PL_reentrant_buffer->_getservent_size, &PL_reentrant_buffer->_getservent_ptr))) == 0 ? PL_reentrant_buffer->_getservent_ptr : 0)
+# define getservent() (((errno = getservent_r(&PL_reentrant_buffer->_getservent_struct, PL_reentrant_buffer->_getservent_buffer, PL_reentrant_buffer->_getservent_size, &PL_reentrant_buffer->_getservent_ptr))) == 0 ? PL_reentrant_buffer->_getservent_ptr : (errno == ERANGE ? Perl_reentrant_retry("getservent") : 0))
# endif
# if !defined(getservent) && GETSERVENT_R_PROTO == REENTRANT_PROTO_I_SBI
-# define getservent() (((errno = getservent_r(&PL_reentrant_buffer->_getservent_struct, PL_reentrant_buffer->_getservent_buffer, PL_reentrant_buffer->_getservent_size))) == 0 ? &PL_reentrant_buffer->_getservent_struct : 0)
+# define getservent() (((errno = getservent_r(&PL_reentrant_buffer->_getservent_struct, PL_reentrant_buffer->_getservent_buffer, PL_reentrant_buffer->_getservent_size))) == 0 ? &PL_reentrant_buffer->_getservent_struct : (errno == ERANGE ? Perl_reentrant_retry("getservent") : 0))
# endif
# if !defined(getservent) && GETSERVENT_R_PROTO == REENTRANT_PROTO_S_SBI
-# define getservent() (getservent_r(&PL_reentrant_buffer->_getservent_struct, PL_reentrant_buffer->_getservent_buffer, PL_reentrant_buffer->_getservent_size) ? &PL_reentrant_buffer->_getservent_struct : 0)
+# define getservent() (getservent_r(&PL_reentrant_buffer->_getservent_struct, PL_reentrant_buffer->_getservent_buffer, PL_reentrant_buffer->_getservent_size) ? &PL_reentrant_buffer->_getservent_struct : (errno == ERANGE ? Perl_reentrant_retry("getservent") : 0))
# endif
# if !defined(getservent) && GETSERVENT_R_PROTO == REENTRANT_PROTO_I_SD
-# define getservent() (((errno = getservent_r(&PL_reentrant_buffer->_getservent_struct, &PL_reentrant_buffer->_getservent_data))) == 0 ? &PL_reentrant_buffer->_getservent_struct : 0)
+# define getservent() (((errno = getservent_r(&PL_reentrant_buffer->_getservent_struct, &PL_reentrant_buffer->_getservent_data))) == 0 ? &PL_reentrant_buffer->_getservent_struct : (errno == ERANGE ? Perl_reentrant_retry("getservent") : 0))
# endif
#endif /* HAS_GETSERVENT_R */
#ifdef HAS_GETSPNAM_R
# undef getspnam
# if !defined(getspnam) && GETSPNAM_R_PROTO == REENTRANT_PROTO_I_CSBWR
-# define getspnam(a) (((errno = getspnam_r(a, &PL_reentrant_buffer->_getspent_struct, PL_reentrant_buffer->_getspent_buffer, PL_reentrant_buffer->_getspent_size, &PL_reentrant_buffer->_getspent_ptr))) == 0 ? PL_reentrant_buffer->_getspent_ptr : 0)
+# define getspnam(a) (((errno = getspnam_r(a, &PL_reentrant_buffer->_getspent_struct, PL_reentrant_buffer->_getspent_buffer, PL_reentrant_buffer->_getspent_size, &PL_reentrant_buffer->_getspent_ptr))) == 0 ? PL_reentrant_buffer->_getspent_ptr : (errno == ERANGE ? Perl_reentrant_retry("getspnam", a) : 0))
# endif
# if !defined(getspnam) && GETSPNAM_R_PROTO == REENTRANT_PROTO_S_CSBI
-# define getspnam(a) (getspnam_r(a, &PL_reentrant_buffer->_getspent_struct, PL_reentrant_buffer->_getspent_buffer, PL_reentrant_buffer->_getspent_size) ? &PL_reentrant_buffer->_getspent_struct : 0)
+# define getspnam(a) (getspnam_r(a, &PL_reentrant_buffer->_getspent_struct, PL_reentrant_buffer->_getspent_buffer, PL_reentrant_buffer->_getspent_size) ? &PL_reentrant_buffer->_getspent_struct : (errno == ERANGE ? Perl_reentrant_retry("getspnam", a) : 0))
# endif
#endif /* HAS_GETSPNAM_R */
diff --git a/reentr.pl b/reentr.pl
index 3d9a159923..1e0947adac 100644
--- a/reentr.pl
+++ b/reentr.pl
@@ -336,6 +336,9 @@ EOF
EOF
}
+define('BUFFER', 'B',
+ qw(getgrent getgrgid getgrnam));
+
define('PTR', 'R',
qw(getgrent getgrgid getgrnam));
define('PTR', 'R',
@@ -348,6 +351,9 @@ define('FPTR', 'H',
define('FPTR', 'H',
qw(getpwent getpwnam getpwuid));
+define('BUFFER', 'B',
+ qw(getpwent getpwgid getpwnam));
+
define('PTR', 'R',
qw(gethostent gethostbyaddr gethostbyname));
define('PTR', 'R',
@@ -357,6 +363,15 @@ define('PTR', 'R',
define('PTR', 'R',
qw(getservent getservbyname getservbyport));
+define('BUFFER', 'B',
+ qw(gethostent gethostbyaddr gethostbyname));
+define('BUFFER', 'B',
+ qw(getnetent getnetbyaddr getnetbyname));
+define('BUFFER', 'B',
+ qw(getprotoent getprotobyname getprotobynumber));
+define('BUFFER', 'B',
+ qw(getservent getservbyname getservbyport));
+
define('ERRNO', 'E',
qw(gethostent gethostbyaddr gethostbyname));
define('ERRNO', 'E',
@@ -441,7 +456,7 @@ EOF
# ifdef __sgi
PL_reentrant_buffer->_${g}_size = BUFSIZ;
# else
- PL_reentrant_buffer->_${g}_size = 2048;
+ PL_reentrant_buffer->_${g}_size = 256;
# endif
# endif
# endif
@@ -527,7 +542,6 @@ EOF
my ($r, $a) = split '_', $p;
my $test = $r eq 'I' ? ' == 0' : '';
my $true = 1;
- my $false = 0;
my $g = $f;
if ($g =~ /^(?:get|set|end)(pw|gr|host|net|proto|serv|sp)/) {
$g = "get$1ent";
@@ -585,9 +599,16 @@ EOF
# define $f($v) $call
EOF
} else {
- push @wrap, <<EOF;
-# define $f($v) ($call$test ? $true : $false)
+ if ($f =~ /^get/) {
+ my $rv = $v ? ", $v" : "";
+ push @wrap, <<EOF;
+# define $f($v) ($call$test ? $true : (errno == ERANGE ? Perl_reentrant_retry("$f"$rv) : 0))
EOF
+ } else {
+ push @wrap, <<EOF;
+# define $f($v) ($call$test ? $true : 0)
+EOF
+ }
}
push @wrap, <<EOF;
# endif
@@ -668,6 +689,190 @@ Perl_reentrant_free(pTHX) {
#endif /* USE_REENTRANT_API */
}
+void*
+Perl_reentrant_retry(const char *f, ...)
+{
+ dTHX;
+ void *retptr = NULL;
+#ifdef USE_REENTRANT_API
+ void *p0, *p1;
+ size_t asize;
+ int anint;
+ va_list ap;
+
+ va_start(ap, f);
+
+#define REENTRANTHALFMAXSIZE 32768 /* The maximum may end up twice this. */
+
+ switch (PL_op->op_type) {
+#ifdef USE_GETHOSTENT_BUFFER
+ case OP_GHBYADDR:
+ case OP_GHBYNAME:
+ case OP_GHOSTENT:
+ {
+ if (PL_reentrant_buffer->_gethostent_size <= REENTRANTHALFMAXSIZE) {
+ PL_reentrant_buffer->_gethostent_size *= 2;
+ Renew(PL_reentrant_buffer->_gethostent_buffer,
+ PL_reentrant_buffer->_gethostent_size, char);
+ switch (PL_op->op_type) {
+ case OP_GHBYADDR:
+ p0 = va_arg(ap, void *);
+ asize = va_arg(ap, size_t);
+ anint = va_arg(ap, int);
+ retptr = gethostbyaddr(p0, asize, anint); break;
+ case OP_GHBYNAME:
+ p0 = va_arg(ap, void *);
+ retptr = gethostbyname(p0); break;
+ case OP_GHOSTENT:
+ retptr = gethostent(); break;
+ default:
+ break;
+ }
+ }
+ }
+ break;
+#endif
+#ifdef USE_GETGRENT_BUFFER
+ case OP_GGRNAM:
+ case OP_GGRGID:
+ case OP_GGRENT:
+ {
+ if (PL_reentrant_buffer->_getgrent_size <= REENTRANTHALFMAXSIZE) {
+ Gid_t gid;
+ PL_reentrant_buffer->_getgrent_size *= 2;
+ Renew(PL_reentrant_buffer->_getgrent_buffer,
+ PL_reentrant_buffer->_getgrent_size, char);
+ switch (PL_op->op_type) {
+ case OP_GGRNAM:
+ p0 = va_arg(ap, void *);
+ retptr = getgrnam(p0); break;
+ case OP_GGRGID:
+ gid = va_arg(ap, Gid_t);
+ retptr = getgrgid(gid); break;
+ case OP_GGRENT:
+ retptr = getgrent(); break;
+ default:
+ break;
+ }
+ }
+ }
+ break;
+#endif
+#ifdef USE_GETNETENT_BUFFER
+ case OP_GNBYADDR:
+ case OP_GNBYNAME:
+ case OP_GNETENT:
+ {
+ if (PL_reentrant_buffer->_getnetent_size <= REENTRANTHALFMAXSIZE) {
+ Netdb_net_t net;
+ PL_reentrant_buffer->_getnetent_size *= 2;
+ Renew(PL_reentrant_buffer->_getnetent_buffer,
+ PL_reentrant_buffer->_getnetent_size, char);
+ switch (PL_op->op_type) {
+ case OP_GNBYADDR:
+ net = va_arg(ap, Netdb_net_t);
+ anint = va_arg(ap, int);
+ retptr = getnetbyaddr(net, anint); break;
+ case OP_GNBYNAME:
+ p0 = va_arg(ap, void *);
+ retptr = getnetbyname(p0); break;
+ case OP_GNETENT:
+ retptr = getnetent(); break;
+ default:
+ break;
+ }
+ }
+ }
+ break;
+#endif
+#ifdef USE_GETPWENT_BUFFER
+ case OP_GPWNAM:
+ case OP_GPWUID:
+ case OP_GPWENT:
+ {
+ if (PL_reentrant_buffer->_getpwent_size <= REENTRANTHALFMAXSIZE) {
+ Uid_t uid;
+ PL_reentrant_buffer->_getpwent_size *= 2;
+ Renew(PL_reentrant_buffer->_getpwent_buffer,
+ PL_reentrant_buffer->_getpwent_size, char);
+ switch (PL_op->op_type) {
+ case OP_GPWNAM:
+ p0 = va_arg(ap, void *);
+ retptr = getpwnam(p0); break;
+ case OP_GPWUID:
+ uid = va_arg(ap, Uid_t);
+ retptr = getpwuid(uid); break;
+ case OP_GPWENT:
+ retptr = getpwent(); break;
+ default:
+ break;
+ }
+ }
+ }
+ break;
+#endif
+#ifdef USE_GETPROTOENT_BUFFER
+ case OP_GPBYNAME:
+ case OP_GPBYNUMBER:
+ case OP_GPROTOENT:
+ {
+ if (PL_reentrant_buffer->_getprotoent_size <= REENTRANTHALFMAXSIZE) {
+ PL_reentrant_buffer->_getprotoent_size *= 2;
+ Renew(PL_reentrant_buffer->_getprotoent_buffer,
+ PL_reentrant_buffer->_getprotoent_size, char);
+ switch (PL_op->op_type) {
+ case OP_GPBYNAME:
+ p0 = va_arg(ap, void *);
+ retptr = getprotobyname(p0); break;
+ case OP_GPBYNUMBER:
+ anint = va_arg(ap, int);
+ retptr = getprotobynumber(anint); break;
+ case OP_GPROTOENT:
+ retptr = getprotoent(); break;
+ default:
+ break;
+ }
+ }
+ }
+ break;
+#endif
+#ifdef USE_GETSERVENT_BUFFER
+ case OP_GSBYNAME:
+ case OP_GSBYPORT:
+ case OP_GSERVENT:
+ {
+ if (PL_reentrant_buffer->_getservent_size <= REENTRANTHALFMAXSIZE) {
+ PL_reentrant_buffer->_getservent_size *= 2;
+ Renew(PL_reentrant_buffer->_getservent_buffer,
+ PL_reentrant_buffer->_getservent_size, char);
+ switch (PL_op->op_type) {
+ case OP_GSBYNAME:
+ p0 = va_arg(ap, void *);
+ p1 = va_arg(ap, void *);
+ retptr = getservbyname(p0, p1); break;
+ case OP_GSBYPORT:
+ anint = va_arg(ap, int);
+ p0 = va_arg(ap, void *);
+ retptr = getservbyport(anint, p0); break;
+ case OP_GSERVENT:
+ retptr = getservent(); break;
+ default:
+ break;
+ }
+ }
+ }
+ break;
+#endif
+ default:
+ /* Not known how to retry, so just fail. */
+ break;
+ }
+
+ va_end(ap);
+#endif
+ return retptr;
+}
+
EOF
__DATA__