diff options
| author | Pierre Joye <pajoye@php.net> | 2009-01-19 02:35:22 +0000 | 
|---|---|---|
| committer | Pierre Joye <pajoye@php.net> | 2009-01-19 02:35:22 +0000 | 
| commit | 274dad3b830e7bfcd676a856550eff4c3fa36200 (patch) | |
| tree | 562f797fb8cf439da9dc996817bbcf4cb4c03787 | |
| parent | e77326fabaa6952ba9660bc3e34b57c3351bb0a6 (diff) | |
| download | php-git-274dad3b830e7bfcd676a856550eff4c3fa36200.tar.gz | |
- MFH:
 - add nanosleep
 - expose nanosleep and usleep
 - [DOC] time_ nanosleep and time_ sleep_ until available on windows
 - change nanosleep signature to match posix one
| -rw-r--r-- | ext/standard/basic_functions.c | 1 | ||||
| -rw-r--r-- | win32/build/config.w32.h.in | 1 | ||||
| -rw-r--r-- | win32/time.c | 13 | ||||
| -rw-r--r-- | win32/time.h | 10 | ||||
| -rw-r--r-- | win32/unistd.h | 2 | 
5 files changed, 25 insertions, 2 deletions
| diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c index 271486bf20..a0dcb73279 100644 --- a/ext/standard/basic_functions.c +++ b/ext/standard/basic_functions.c @@ -39,6 +39,7 @@  #ifdef PHP_WIN32  #include "win32/php_win32_globals.h" +#include "win32/time.h"  #endif  typedef struct yy_buffer_state *YY_BUFFER_STATE; diff --git a/win32/build/config.w32.h.in b/win32/build/config.w32.h.in index 8377ccd088..ae0e1a4391 100644 --- a/win32/build/config.w32.h.in +++ b/win32/build/config.w32.h.in @@ -53,6 +53,7 @@  /* its in win32/time.c */  #define HAVE_USLEEP 1 +#define HAVE_NANOSLEEP 1  #define HAVE_GETHOSTNAME 1  #define HAVE_GETCWD 1 diff --git a/win32/time.c b/win32/time.c index 816eb63b14..808ce8d5bd 100644 --- a/win32/time.c +++ b/win32/time.c @@ -127,7 +127,7 @@ PHPAPI int gettimeofday(struct timeval *time_Info, struct timezone *timezone_Inf  	return 0;  } -void usleep(unsigned int useconds) +PHPAPI int usleep(unsigned int useconds)  {  	HANDLE timer;  	LARGE_INTEGER due; @@ -138,6 +138,17 @@ void usleep(unsigned int useconds)  	SetWaitableTimer(timer, &due, 0, NULL, NULL, 0);  	WaitForSingleObject(timer, INFINITE);  	CloseHandle(timer); +	return 0; +} + +PHPAPI int nanosleep( const struct timespec * rqtp, struct timespec * rmtp ) +{ +	if (rqtp->tv_nsec > 999999999) { +		/* The time interval specified 1,000,000 or more microseconds. */ +		errno = EINVAL; +		return -1; +	} +	return usleep( rqtp->tv_sec * 1000000 + rqtp->tv_nsec / 1000  );  }  #if 0 /* looks pretty ropey in here */ diff --git a/win32/time.h b/win32/time.h index 5c52e7837e..f841a2b601 100644 --- a/win32/time.h +++ b/win32/time.h @@ -28,6 +28,14 @@ struct itimerval {  	struct timeval it_value;	/* current value */  }; +#ifndef timespec +struct timespec +{ +	time_t   tv_sec;   /* seconds */ +	long     tv_nsec;  /* nanoseconds */ +}; +#endif +  #define ITIMER_REAL    0		/*generates sigalrm */  #define ITIMER_VIRTUAL 1		/*generates sigvtalrm */  #define ITIMER_VIRT    1		/*generates sigvtalrm */ @@ -40,4 +48,6 @@ PHPAPI extern int gettimeofday(struct timeval *time_Info, struct timezone *timez  PHPAPI extern int setitimer(int which, const struct itimerval *value,  					 struct itimerval *ovalue); +PHPAPI int nanosleep( const struct timespec * rqtp, struct timespec * rmtp ); +  #endif diff --git a/win32/unistd.h b/win32/unistd.h index 96e0aedc13..0b9446149c 100644 --- a/win32/unistd.h +++ b/win32/unistd.h @@ -1,4 +1,4 @@  #ifndef _PHP_WIN32_UNISTD_H  #define _PHP_WIN32_UNISTD_H -void usleep(unsigned int useconds); +PHPAPI int usleep(unsigned int useconds);  #endif | 
