RE: [PHP-DEV] PHP 4.0 Bug #5225: Compile problems with reentranttime functions (*_r)

From: Date: Sun, 25 Jun 2000 19:17:36 +0000
Subject: RE: [PHP-DEV] PHP 4.0 Bug #5225: Compile problems with reentranttime functions (*_r)
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-22296@lists.php.net to get a copy of this message
Hi, [...] > > Thanks for your detailed bug report. Can you please try a > > recent snapshot and check whether all the problems have been > > fixed? > > > > http://snaps.php.net/ > > I just downloaded the fix and I think the problem is still > there - at least after a first glance over php_reentrancy.h. > But I'll run configure right now and report back afterwards. ok, I was wrong I've compiled the latest snapshot without errors now. But it was obviously fixed in a different way. Not by defining -D_REENTRANT via configure to get all the HP-UX specific reentrant function prototyes (which are not just the time functions but also readdir_r(), rand_r() etc.) -- which are all there in the HP-UX header files - only guarded with #ifdef _REENTRANT's. But instead is is fixed rather with - I would say - some quirks? Well, it seems to compile - though I don't really like the way the problem is fixed for HP-UX because I'm not sure what would happen if "ZTS" would be defined and if -D_REENTRANT would be declared on a HP-UX 10.20 installation where pthreads are available(?). I'm not sure for which PHP feature ZTS becomes defined? But I think there would be a problem for HP-UX if ZTS gets defined. Well at least some of the TSRM stuff would be compiled into the object even if it wouldn't be necessary. So I my own fix of the problem somewhat more. :-) But perhaps this "ZTS" issue doesn't matter at all... For the time beeing I stick to my own version of the HP fix. And just just in case it matters I want to visualize what I mean with the above statement about ZTS: ~~~~ php_reentrancy.h first undefines: ~~~~ ... #ifdef PHP_HPUX_TIME_R #undef HAVE_LOCALTIME_R #undef HAVE_ASCTIME_R #undef HAVE_CTIME_R #undef HAVE_GMTIME_R #endif --> ok this is necessary since -D_REENTRANT is not declared by configure and hence the compiler cannot see the *_r() prototypes under HP-UX 10.20 which are different from the POSIX prototypes (XXXX: what would happen if -D_REENTRANT would be declared via pthreads?) ... #if !defined(HAVE_LOCALTIME_R) && defined(HAVE_LOCALTIME) #define PHP_NEED_REENTRANCY 1 PHPAPI struct tm *php_localtime_r(const time_t *const timep, struct tm *p_tm); #else #define php_localtime_r localtime_r #ifdef MISSING_LOCALTIME_R_DECL struct tm *localtime_r(const time_t *const timep, struct tm *p_tm); #endif #endif ... --> the above #undef's declare the necessary php_*_r() prototypes for HP-UX but this also defines PHP_NEED_REENTRANCY for HP-UX even though HP-UX has the reentrant *_r() functions, but... --> ...fortunatly later in the file, there is: #if !defined(ZTS) #undef PHP_NEED_REENTRANCY #endif --> ...and since ZTS is not declared PHP_NEED_REENTRANCY is fortunatly undefined again... ~~~~ reentrancy.c defines: ~~~~ #include "php_reentrancy.h" --> ...otherwise we would get this stuff under HP-UX: #if defined(PHP_NEED_REENTRANCY) #include <TSRM.h> static MUTEX_T reentrant_locks[NUMBER_OF_LOCKS]; ... #else ... #endif #if defined(PHP_HPUX_TIME_R) ---> oops, now we HAVE_LOCALTIME_R to enable again -- but it's necessary otherwise the compiler would try to compile the second versions of the php_*_r() functions below... #define HAVE_LOCALTIME_R 1 #define HAVE_CTIME_R 1 #define HAVE_ASCTIME_R 1 #define HAVE_GMTIME_R 1 PHPAPI struct tm *php_localtime_r(const time_t *const timep, struct tm *p_tm) { if (localtime_r(timep, p_tm) == 0) return (p_tm); return (NULL); } ... #endif ... #if !defined(HAVE_LOCALTIME_R) && defined(HAVE_LOCALTIME) PHPAPI struct tm *php_localtime_r(const time_t *const timep, struct tm *p_tm) { struct tm *tmp; local_lock(LOCALTIME_R); ... } #endif ~~~~ MfG, Thomas Wolfram -- mailto:thomas@wolfram.net

« previous php.dev (#22296) next »