]> granicus.if.org Git - php/commitdiff
make microtime and gettimeofday unavailable instead of return false return
authorMarcus Boerger <helly@php.net>
Tue, 29 Oct 2002 23:35:49 +0000 (23:35 +0000)
committerMarcus Boerger <helly@php.net>
Tue, 29 Oct 2002 23:35:49 +0000 (23:35 +0000)
false in case needed library function is unavailable.

ext/standard/basic_functions.c
ext/standard/microtime.c
ext/standard/microtime.h

index 97e93650d7e20bf2e0490241ff95853206aede72..17b2f471c6f60fb30dc2208598a70673a30bfc01 100644 (file)
@@ -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)
index f5b1ab157832cf1529c88dc1f818d1eb8b10c863..efc1fd1c78b49c6c55510607ff49f8654d2f617c 100644 (file)
@@ -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
index 9ce3825104032de2eea426e2535a81898de62253..a2d1d242c94c330c7bf01c5d4798cae56ef418e8 100644 (file)
 #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 */