php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #5225 Compile problems with reentrant time functions (*_r)
Submitted: 2000-06-25 18:00 UTC Modified: 2000-07-11 15:07 UTC
From: thomas at wolfram dot net Assigned:
Status: Closed Package: Compile Failure
PHP Version: 4.0.0 OS: HP-UX 10.20
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: thomas at wolfram dot net
New email:
PHP Version: OS:

 

 [2000-06-25 18:00 UTC] thomas at wolfram dot net
I compiled PHP 4.0.0 under HP-UX 10.20 (no DCE threads installed if that matters) using gcc 2.8.1 and found
and fixed a problem of compiling reentrancy.c under
this system.
My configure line was:

./configure  --prefix=/home/web/php4 \
  --with-config-file-path=/home/web/php4 \
  --with-apache=../apache_1.3.12 \
  --with-mysql \
  --enable-track-vars \
  --enable-bcmath \
  --enable-ftp

Compilation of reentrancy.c caused following compiler problem:
  ====
reentrancy.c: In function `php_localtime_r':
reentrancy.c:53: warning: implicit declaration of function `localtime_r'
reentrancy.c: In function `php_ctime_r':
reentrancy.c:60: warning: implicit declaration of function `ctime_r'
reentrancy.c: In function `php_asctime_r':
reentrancy.c:67: warning: implicit declaration of function `asctime_r'
reentrancy.c: In function `php_gmtime_r':
reentrancy.c:74: warning: implicit declaration of function `gmtime_r'
reentrancy.c: At top level:
reentrancy.c:84: redefinition of `php_localtime_r'
reentrancy.c:52: `php_localtime_r' previously defined here
reentrancy.c:105: redefinition of `php_ctime_r'
reentrancy.c:59: `php_ctime_r' previously defined here
reentrancy.c:123: redefinition of `php_asctime_r'
reentrancy.c:66: `php_asctime_r' previously defined here
reentrancy.c:141: redefinition of `php_gmtime_r'
reentrancy.c:73: `php_gmtime_r' previously defined here
  ====

I found that the problem was caused by a combination of a missing macro definition (-D_REENTRANT) which was not set by the configure script (perhaps because I've no DCE threads installed?) and some wrong lines in php_reentrancy.h. The code in reentrancy.c already tries to workaround the different return types of the reentrant time functions (localtime_r() etc.) with defining special functions just for HP-UX. But because -D_REENTRANT is not set in configure, it doesn't see the existing prototypes of localtime_r() etc. and declares MISSING_*DECL which in turn leads in php_reentrancy.h to the definition of a wrong (i.e. non-HPUX) prototype. Moreover this header file wrongly undefines HAVE_LOCALTIME_R etc. for HP-UX (because this was a attempt to fix the problem?).

Anyway, I was able to fix the problem and now have PHP 4.0.0 working by setting CPPFLAGS before running configure this way:

CPPFLAGS=-D_REENTRANT ; export CPPFLAGS
./configure  --prefix=/home/web/php4 \
  --with-config-file-path=/home/web/php4 \
  --with-apache=../apache_1.3.12 \
  --with-mysql \
  --enable-track-vars \
  --enable-bcmath \
  --enable-ftp

and changing php_reentrancy this way (it's  the output of diff -c):

  ====

*** php_reentrancy.h.orig      Thu May 18 16:34:21 2000
--- php_reentrancy.h    Sun Jun 25 02:40:57 2000
***************
*** 33,54 ****
  #define HAVE_CTIME 1


! #ifdef PHP_HPUX_TIME_R
! #undef HAVE_LOCALTIME_R
! #undef HAVE_ASCTIME_R
! #undef HAVE_CTIME_R
! #undef HAVE_GMTIME_R
! #endif

  #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


  #if !defined(HAVE_CTIME_R) && defined(HAVE_CTIME)
--- 33,58 ----
  #define HAVE_CTIME 1


! //#ifdef PHP_HPUX_TIME_R
! //#undef HAVE_LOCALTIME_R
! //#undef HAVE_ASCTIME_R
! //#undef HAVE_CTIME_R
! //#undef HAVE_GMTIME_R
! //#endif

  #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
+ #ifdef PHP_HPUX_TIME_R
+ 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
+ #endif


  #if !defined(HAVE_CTIME_R) && defined(HAVE_CTIME)
***************
*** 55,65 ****
--- 59,73 ----
  #define PHP_NEED_REENTRANCY 1
  PHPAPI char *php_ctime_r(const time_t *clock, char *buf);
  #else
+ #ifdef PHP_HPUX_TIME_R
+ PHPAPI char *php_ctime_r(const time_t *clock, char *buf);
+ #else
  #define php_ctime_r ctime_r
  #ifdef MISSING_CTIME_R_DECL
  char *ctime_r(const time_t *clock, char *buf);
  #endif
  #endif
+ #endif


  #if !defined(HAVE_ASCTIME_R) && defined(HAVE_ASCTIME)
***************
*** 66,76 ****
--- 74,88 ----
  #define PHP_NEED_REENTRANCY 1
  PHPAPI char *php_asctime_r(const struct tm *tm, char *buf);
  #else
+ #ifdef PHP_HPUX_TIME_R
+ PHPAPI char *php_asctime_r(const struct tm *tm, char *buf);
+ #else
  #define php_asctime_r asctime_r
  #ifdef MISSING_ASCTIME_R_DECL
  char *asctime_r(const struct tm *tm, char *buf);
  #endif
  #endif
+ #endif


  #if !defined(HAVE_GMTIME_R) && defined(HAVE_GMTIME)
***************
*** 77,85 ****
--- 89,101 ----
  #define PHP_NEED_REENTRANCY 1
  PHPAPI struct tm *php_gmtime_r(const time_t *const timep, struct tm *p_tm);
  #else
+ #ifdef PHP_HPUX_TIME_R
+ PHPAPI struct tm *php_gmtime_r(const time_t *const timep, struct tm *p_tm);
+ #else
  #define php_gmtime_r gmtime_r
  #ifdef MISSING_GMTIME_R_DECL
  struct tm *php_gmtime_r(const time_t *const timep, struct tm *p_tm);
+ #endif
  #endif
  #endif

  =====

I think if configure would set -D_REENTRANT always for HP-UX (whether threads are there or not) and with the above patch for php_reentrancy.h this should work for HP-UX 10.xx regardless whether there are threads or not and always for 11.xx.

regards,
Thomas Wolfram
mailto:thomas@wolfram.net

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-07-11 15:07 UTC] sas at cvs dot php dot net
Has been fixed in PHP 4.0.1. Thank you for your detailed report.
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Fri Oct 09 22:00:02 2026 UTC