1919/* $Id$ */ 
2020
2121#include  "php.h" 
22- #include  "zend_exceptions.h" 
2322#include  "hrtime.h" 
2423
2524/* {{{ */ 
3534#elif  PHP_HRTIME_PLATFORM_WINDOWS 
3635
3736# define  WIN32_LEAN_AND_MEAN 
38- # include  <windows.h> 
3937
4038static  uint64_t  _timer_freq  =  0 ;
4139static  double  _timer_int  =  .0 ;
@@ -116,9 +114,13 @@ PHP_MINIT_FUNCTION(hrtime)
116114static  zend_always_inline  php_hrtime_t  _timer_current (void )
117115{/*{{{*/ 
118116#if  PHP_HRTIME_PLATFORM_WINDOWS 
119- 	uint64_t  cur ;
120- 	QueryPerformanceCounter ((LARGE_INTEGER * ) & cur );
121- 	return  (php_hrtime_t )((double )cur  *  _timer_int  *  (double )NANO_IN_SEC );
117+ 	uint64_t  cur  =  0 ;
118+ 	LARGE_INTEGER  lt ;
119+ 	if  (QueryPerformanceCounter (& lt )) {
120+ 		cur  =  lt .QuadPart ;
121+ 		return  (php_hrtime_t )((double )cur  *  _timer_int  *  (double )NANO_IN_SEC );
122+ 	}
123+ 	return  0 ;
122124#elif  PHP_HRTIME_PLATFORM_APPLE 
123125	return  (php_hrtime_t )mach_absolute_time () *  _timerlib_info .numer  / _timerlib_info .denom ;
124126#elif  PHP_HRTIME_PLATFORM_POSIX 
@@ -160,7 +162,7 @@ static zend_always_inline php_hrtime_t _timer_current(void)
160162	} while (0)
161163#endif 
162164
163- /* {{{ proto mixed hrtime([bool get_as_numu  = false]) 
165+ /* {{{ proto mixed hrtime([bool get_as_number  = false]) 
164166	Returns an array of integers in form [seconds, nanoseconds] counted 
165167	from an arbitrary point in time. If an optional boolean argument is 
166168	passed, returns an integer on 64-bit platforms or float on 32-bit 
@@ -176,16 +178,15 @@ PHP_FUNCTION(hrtime)
176178		Z_PARAM_BOOL (get_as_num )
177179	ZEND_PARSE_PARAMETERS_END ();
178180
179- 	if  (!get_as_num ) {
180- 		/* TODO On 32-bit care about millenium bug. */ 
181+ 	if  (UNEXPECTED (get_as_num )) {
182+ 		PHP_RETURN_HRTIME (t );
183+ 	} else  {
181184		array_init (return_value );
182185		add_next_index_long (return_value , (zend_long )(t  / (php_hrtime_t )NANO_IN_SEC ));
183186		add_next_index_long (return_value , (zend_long )(t  % (php_hrtime_t )NANO_IN_SEC ));
184- 	} else  {
185- 		PHP_RETURN_HRTIME (t );
186187	}
187188#else 
188- 	RETURN_LONG ( 0 ); 
189+ 	RETURN_FALSE 
189190#endif 
190191}
191192/* }}} */ 
0 commit comments