diff options
author | Marcus Boerger <helly@php.net> | 2002-10-29 23:35:49 +0000 |
---|---|---|
committer | Marcus Boerger <helly@php.net> | 2002-10-29 23:35:49 +0000 |
commit | 6f8bfd148aeb387b9de3df0d4f36ba522236d941 (patch) | |
tree | e6062711b920ffb7c7006ba9a8405c7d2e8fb2bb /ext | |
parent | a24534a1ed1a38024fba0c5fe5374effb7432d0b (diff) | |
download | php-git-6f8bfd148aeb387b9de3df0d4f36ba522236d941.tar.gz |
make microtime and gettimeofday unavailable instead of return false return
false in case needed library function is unavailable.
Diffstat (limited to 'ext')
-rw-r--r-- | ext/standard/basic_functions.c | 2 | ||||
-rw-r--r-- | ext/standard/microtime.c | 16 | ||||
-rw-r--r-- | ext/standard/microtime.h | 4 |
3 files changed, 15 insertions, 7 deletions
diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c index 97e93650d7..17b2f471c6 100644 --- a/ext/standard/basic_functions.c +++ b/ext/standard/basic_functions.c @@ -508,8 +508,10 @@ function_entry basic_functions[] = { PHP_FE(getopt, NULL) #endif +#ifdef HAVE_GETTIMEOFDAY PHP_FE(microtime, NULL) PHP_FE(gettimeofday, NULL) +#endif #ifdef HAVE_GETRUSAGE PHP_FE(getrusage, NULL) diff --git a/ext/standard/microtime.c b/ext/standard/microtime.c index f5b1ab1578..efc1fd1c78 100644 --- a/ext/standard/microtime.c +++ b/ext/standard/microtime.c @@ -53,9 +53,9 @@ /* {{{ proto string microtime(void) Returns a string containing the current time in seconds and microseconds */ +#ifdef HAVE_GETTIMEOFDAY PHP_FUNCTION(microtime) { -#ifdef HAVE_GETTIMEOFDAY struct timeval tp; long sec = 0L; double msec = 0.0; @@ -68,17 +68,18 @@ PHP_FUNCTION(microtime) if (msec >= 1.0) msec -= (long) msec; snprintf(ret, 100, "%.8f %ld", msec, sec); RETVAL_STRING(ret,1); - } else -#endif + } else { RETURN_FALSE; + } } +#endif /* }}} */ /* {{{ proto array gettimeofday(void) Returns the current time as array */ +#ifdef HAVE_GETTIMEOFDAY PHP_FUNCTION(gettimeofday) { -#ifdef HAVE_GETTIMEOFDAY struct timeval tp; struct timezone tz; @@ -95,10 +96,11 @@ PHP_FUNCTION(gettimeofday) #endif add_assoc_long(return_value, "dsttime", tz.tz_dsttime); return; - } else -#endif - RETURN_FALSE; + } else { + RETURN_FALSE; + } } +#endif /* }}} */ #ifdef HAVE_GETRUSAGE diff --git a/ext/standard/microtime.h b/ext/standard/microtime.h index 9ce3825104..a2d1d242c9 100644 --- a/ext/standard/microtime.h +++ b/ext/standard/microtime.h @@ -21,8 +21,12 @@ #ifndef MICROTIME_H #define MICROTIME_H +#ifdef HAVE_GETTIMEOFDAY PHP_FUNCTION(microtime); PHP_FUNCTION(gettimeofday); +#endif +#ifdef HAVE_GETRUSAGE PHP_FUNCTION(getrusage); +#endif #endif /* MICROTIME_H */ |