diff options
author | Jarkko Hietaniemi <jhi@iki.fi> | 2002-03-15 16:07:58 +0000 |
---|---|---|
committer | Jarkko Hietaniemi <jhi@iki.fi> | 2002-03-15 16:07:58 +0000 |
commit | 10bc17b68c7666cd045658934ccb75dd788c8972 (patch) | |
tree | 0a97f4e9c6e3aa079acc3ca0c75d94be194c1387 /reentr.c | |
parent | 6ab308ee9dcbdd9e40dc1aa7ca450e7f854eb8fe (diff) | |
download | perl-10bc17b68c7666cd045658934ccb75dd788c8972.tar.gz |
Monster _r patch: try to scan for all known _r variants,
and then use them (under ithreads). May fail in HP-UX,
and the op/groups is known to be fickle everywhere. Known
to work in Solaris, Linux, Tru64, IRIX, AIX. (Some compiler
warnings in AIX since the first arguments of getnetbyaddr
and getnetbyadd_r are of different types. Thanks, IBM.)
In non-Configure platforms deny the existence of any
of the _r thingies. (Also add the recently introduced
d_tm_* to places it wasn't already in.)
TODO: the suggested glibc buffer growth retry loop in case
some entries (at least for: gr*, host*) are big.
Forgot win32/config.win64.
p4raw-id: //depot/perl@15238
Diffstat (limited to 'reentr.c')
-rw-r--r-- | reentr.c | 271 |
1 files changed, 271 insertions, 0 deletions
diff --git a/reentr.c b/reentr.c new file mode 100644 index 0000000000..a054c06303 --- /dev/null +++ b/reentr.c @@ -0,0 +1,271 @@ +/* + * reentr.c + * + * Copyright (c) 1997-2002, Larry Wall + * + * You may distribute under the terms of either the GNU General Public + * License or the Artistic License, as specified in the README file. + * + * !!!!!!! DO NOT EDIT THIS FILE !!!!!!! + * This file is built by reentrl.pl from data in reentr.pl. + * + * "Saruman," I said, standing away from him, "only one hand at a time can + * wield the One, and you know that well, so do not trouble to say we!" + * + */ + +#include "EXTERN.h" +#define PERL_IN_REENTR_C +#include "perl.h" +#include "reentr.h" + +void +Perl_reentrant_size(pTHX) { +#ifdef USE_REENTRANT_API +#ifdef HAS_ASCTIME_R + PL_reentrant_buffer->_asctime_size = 256; /* Make something up. */ +#endif /* HAS_ASCTIME_R */ +#ifdef HAS_CRYPT_R +#endif /* HAS_CRYPT_R */ +#ifdef HAS_CTIME_R + PL_reentrant_buffer->_ctime_size = 256; /* Make something up. */ +#endif /* HAS_CTIME_R */ +#ifdef HAS_DRAND48_R +#endif /* HAS_DRAND48_R */ +#ifdef HAS_GETGRNAM_R +# if defined(HAS_SYSCONF) && defined(_SC_GETGR_R_SIZE_MAX) && !defined(__GLIBC__) + PL_reentrant_buffer->_getgrent_size = sysconf(_SC_GETGR_R_SIZE_MAX); +# else +# if defined(__osf__) && defined(__alpha) && defined(SIABUFSIZ) + PL_reentrant_buffer->_getgrent_size = SIABUFSIZ; +# else +# ifdef __sgi + PL_reentrant_buffer->_getgrent_size = BUFSIZ; +# else + PL_reentrant_buffer->_getgrent_size = 2048; +# endif +# endif +# endif +#endif /* HAS_GETGRNAM_R */ +#ifdef HAS_GETHOSTBYNAME_R +#if !(GETHOSTBYNAME_R_PROTO == REENTRANT_PROTO_I_CSD) + PL_reentrant_buffer->_gethostent_size = 2048; /* Any better ideas? */ +#endif +#endif /* HAS_GETHOSTBYNAME_R */ +#ifdef HAS_GETLOGIN_R + PL_reentrant_buffer->_getlogin_size = 256; /* Make something up. */ +#endif /* HAS_GETLOGIN_R */ +#ifdef HAS_GETNETBYNAME_R +#if !(GETNETBYNAME_R_PROTO == REENTRANT_PROTO_I_CSD) + PL_reentrant_buffer->_getnetent_size = 2048; /* Any better ideas? */ +#endif +#endif /* HAS_GETNETBYNAME_R */ +#ifdef HAS_GETPROTOBYNAME_R +#if !(GETPROTOBYNAME_R_PROTO == REENTRANT_PROTO_I_CSD) + PL_reentrant_buffer->_getprotoent_size = 2048; /* Any better ideas? */ +#endif +#endif /* HAS_GETPROTOBYNAME_R */ +#ifdef HAS_GETPWNAM_R +# if defined(HAS_SYSCONF) && defined(_SC_GETPW_R_SIZE_MAX) && !defined(__GLIBC__) + PL_reentrant_buffer->_getpwent_size = sysconf(_SC_GETPW_R_SIZE_MAX); +# else +# if defined(__osf__) && defined(__alpha) && defined(SIABUFSIZ) + PL_reentrant_buffer->_getpwent_size = SIABUFSIZ; +# else +# ifdef __sgi + PL_reentrant_buffer->_getpwent_size = BUFSIZ; +# else + PL_reentrant_buffer->_getpwent_size = 2048; +# endif +# endif +# endif +#endif /* HAS_GETPWNAM_R */ +#ifdef HAS_GETSERVBYNAME_R +#if !(GETSERVBYNAME_R_PROTO == REENTRANT_PROTO_I_CCSD) + PL_reentrant_buffer->_getservent_size = 2048; /* Any better ideas? */ +#endif +#endif /* HAS_GETSERVBYNAME_R */ +#ifdef HAS_GETSPNAM_R + PL_reentrant_buffer->_getspent_size = 1024; +#endif /* HAS_GETSPNAM_R */ +#ifdef HAS_GMTIME_R +#endif /* HAS_GMTIME_R */ +#ifdef HAS_LOCALTIME_R +#endif /* HAS_LOCALTIME_R */ +#ifdef HAS_RANDOM_R +#endif /* HAS_RANDOM_R */ +#ifdef HAS_READDIR_R + /* This is the size Solaris recommends. + * (though we go static, should use pathconf() instead) */ + PL_reentrant_buffer->_readdir_size = sizeof(struct dirent) + MAXPATHLEN + 1; +#endif /* HAS_READDIR_R */ +#ifdef HAS_READDIR64_R + /* This is the size Solaris recommends. + * (though we go static, should use pathconf() instead) */ + PL_reentrant_buffer->_readdir64_size = sizeof(struct dirent64) + MAXPATHLEN + 1; +#endif /* HAS_READDIR64_R */ +#ifdef HAS_SETLOCALE_R + PL_reentrant_buffer->_setlocale_size = 256; /* Make something up. */ +#endif /* HAS_SETLOCALE_R */ +#ifdef HAS_STRERROR_R + PL_reentrant_buffer->_strerror_size = 256; /* Make something up. */ +#endif /* HAS_STRERROR_R */ +#ifdef HAS_TTYNAME_R + PL_reentrant_buffer->_ttyname_size = 256; /* Make something up. */ +#endif /* HAS_TTYNAME_R */ + +#endif /* USE_REENTRANT_API */ +} + +void +Perl_reentrant_init(pTHX) { +#ifdef USE_REENTRANT_API + New(31337, PL_reentrant_buffer, 1, REENTR); + Perl_reentrant_size(aTHX); +#ifdef HAS_ASCTIME_R + New(31338, PL_reentrant_buffer->_asctime_buffer, PL_reentrant_buffer->_asctime_size, char); +#endif /* HAS_ASCTIME_R */ +#ifdef HAS_CRYPT_R +#ifdef __GLIBC__ + PL_reentrant_buffer->_crypt_struct.initialized = 0; +#endif +#endif /* HAS_CRYPT_R */ +#ifdef HAS_CTIME_R + New(31338, PL_reentrant_buffer->_ctime_buffer, PL_reentrant_buffer->_ctime_size, char); +#endif /* HAS_CTIME_R */ +#ifdef HAS_DRAND48_R +#endif /* HAS_DRAND48_R */ +#ifdef HAS_GETGRNAM_R +# ifdef USE_GETGRENT_FPTR + PL_reentrant_buffer->_getgrent_fptr = NULL; +# endif + New(31338, PL_reentrant_buffer->_getgrent_buffer, PL_reentrant_buffer->_getgrent_size, char); +#endif /* HAS_GETGRNAM_R */ +#ifdef HAS_GETHOSTBYNAME_R +#if !(GETHOSTBYNAME_R_PROTO == REENTRANT_PROTO_I_CSD) + New(31338, PL_reentrant_buffer->_gethostent_buffer, PL_reentrant_buffer->_gethostent_size, char); +#endif +#endif /* HAS_GETHOSTBYNAME_R */ +#ifdef HAS_GETLOGIN_R + New(31338, PL_reentrant_buffer->_getlogin_buffer, PL_reentrant_buffer->_getlogin_size, char); +#endif /* HAS_GETLOGIN_R */ +#ifdef HAS_GETNETBYNAME_R +#if !(GETNETBYNAME_R_PROTO == REENTRANT_PROTO_I_CSD) + New(31338, PL_reentrant_buffer->_getnetent_buffer, PL_reentrant_buffer->_getnetent_size, char); +#endif +#endif /* HAS_GETNETBYNAME_R */ +#ifdef HAS_GETPROTOBYNAME_R +#if !(GETPROTOBYNAME_R_PROTO == REENTRANT_PROTO_I_CSD) + New(31338, PL_reentrant_buffer->_getprotoent_buffer, PL_reentrant_buffer->_getprotoent_size, char); +#endif +#endif /* HAS_GETPROTOBYNAME_R */ +#ifdef HAS_GETPWNAM_R +# ifdef USE_GETPWENT_FPTR + PL_reentrant_buffer->_getpwent_fptr = NULL; +# endif + New(31338, PL_reentrant_buffer->_getpwent_buffer, PL_reentrant_buffer->_getpwent_size, char); +#endif /* HAS_GETPWNAM_R */ +#ifdef HAS_GETSERVBYNAME_R +#if !(GETSERVBYNAME_R_PROTO == REENTRANT_PROTO_I_CCSD) + New(31338, PL_reentrant_buffer->_getservent_buffer, PL_reentrant_buffer->_getservent_size, char); +#endif +#endif /* HAS_GETSERVBYNAME_R */ +#ifdef HAS_GETSPNAM_R + New(31338, PL_reentrant_buffer->_getspent_buffer, PL_reentrant_buffer->_getspent_size, char); +#endif /* HAS_GETSPNAM_R */ +#ifdef HAS_GMTIME_R +#endif /* HAS_GMTIME_R */ +#ifdef HAS_LOCALTIME_R +#endif /* HAS_LOCALTIME_R */ +#ifdef HAS_RANDOM_R +#endif /* HAS_RANDOM_R */ +#ifdef HAS_READDIR_R + PL_reentrant_buffer->_readdir_struct = (struct dirent*)safemalloc(PL_reentrant_buffer->_readdir_size); +#endif /* HAS_READDIR_R */ +#ifdef HAS_READDIR64_R + PL_reentrant_buffer->_readdir64_struct = (struct dirent64*)safemalloc(PL_reentrant_buffer->_readdir64_size); +#endif /* HAS_READDIR64_R */ +#ifdef HAS_SETLOCALE_R + New(31338, PL_reentrant_buffer->_setlocale_buffer, PL_reentrant_buffer->_setlocale_size, char); +#endif /* HAS_SETLOCALE_R */ +#ifdef HAS_STRERROR_R + New(31338, PL_reentrant_buffer->_strerror_buffer, PL_reentrant_buffer->_strerror_size, char); +#endif /* HAS_STRERROR_R */ +#ifdef HAS_TTYNAME_R + New(31338, PL_reentrant_buffer->_ttyname_buffer, PL_reentrant_buffer->_ttyname_size, char); +#endif /* HAS_TTYNAME_R */ + +#endif /* USE_REENTRANT_API */ +} + +void +Perl_reentrant_free(pTHX) { +#ifdef USE_REENTRANT_API +#ifdef HAS_ASCTIME_R + Safefree(PL_reentrant_buffer->_asctime_buffer); +#endif /* HAS_ASCTIME_R */ +#ifdef HAS_CRYPT_R +#endif /* HAS_CRYPT_R */ +#ifdef HAS_CTIME_R + Safefree(PL_reentrant_buffer->_ctime_buffer); +#endif /* HAS_CTIME_R */ +#ifdef HAS_DRAND48_R +#endif /* HAS_DRAND48_R */ +#ifdef HAS_GETGRNAM_R + Safefree(PL_reentrant_buffer->_getgrent_buffer); +#endif /* HAS_GETGRNAM_R */ +#ifdef HAS_GETHOSTBYNAME_R +#if !(GETHOSTBYNAME_R_PROTO == REENTRANT_PROTO_I_CSD) + Safefree(PL_reentrant_buffer->_gethostent_buffer); +#endif +#endif /* HAS_GETHOSTBYNAME_R */ +#ifdef HAS_GETLOGIN_R + Safefree(PL_reentrant_buffer->_getlogin_buffer); +#endif /* HAS_GETLOGIN_R */ +#ifdef HAS_GETNETBYNAME_R +#if !(GETNETBYNAME_R_PROTO == REENTRANT_PROTO_I_CSD) + Safefree(PL_reentrant_buffer->_getnetent_buffer); +#endif +#endif /* HAS_GETNETBYNAME_R */ +#ifdef HAS_GETPROTOBYNAME_R +#if !(GETPROTOBYNAME_R_PROTO == REENTRANT_PROTO_I_CSD) + Safefree(PL_reentrant_buffer->_getprotoent_buffer); +#endif +#endif /* HAS_GETPROTOBYNAME_R */ +#ifdef HAS_GETPWNAM_R + Safefree(PL_reentrant_buffer->_getpwent_buffer); +#endif /* HAS_GETPWNAM_R */ +#ifdef HAS_GETSERVBYNAME_R +#if !(GETSERVBYNAME_R_PROTO == REENTRANT_PROTO_I_CCSD) + Safefree(PL_reentrant_buffer->_getservent_buffer); +#endif +#endif /* HAS_GETSERVBYNAME_R */ +#ifdef HAS_GETSPNAM_R + Safefree(PL_reentrant_buffer->_getspent_buffer); +#endif /* HAS_GETSPNAM_R */ +#ifdef HAS_GMTIME_R +#endif /* HAS_GMTIME_R */ +#ifdef HAS_LOCALTIME_R +#endif /* HAS_LOCALTIME_R */ +#ifdef HAS_RANDOM_R +#endif /* HAS_RANDOM_R */ +#ifdef HAS_READDIR_R + Safefree(PL_reentrant_buffer->_readdir_struct); +#endif /* HAS_READDIR_R */ +#ifdef HAS_READDIR64_R + Safefree(PL_reentrant_buffer->_readdir64_struct); +#endif /* HAS_READDIR64_R */ +#ifdef HAS_SETLOCALE_R + Safefree(PL_reentrant_buffer->_setlocale_buffer); +#endif /* HAS_SETLOCALE_R */ +#ifdef HAS_STRERROR_R + Safefree(PL_reentrant_buffer->_strerror_buffer); +#endif /* HAS_STRERROR_R */ +#ifdef HAS_TTYNAME_R + Safefree(PL_reentrant_buffer->_ttyname_buffer); +#endif /* HAS_TTYNAME_R */ + + Safefree(PL_reentrant_buffer); +#endif /* USE_REENTRANT_API */ +} + |