summaryrefslogtreecommitdiff
path: root/win32/time.c
diff options
context:
space:
mode:
authorWez Furlong <wez@php.net>2003-11-29 22:48:42 +0000
committerWez Furlong <wez@php.net>2003-11-29 22:48:42 +0000
commitdd60413c6198273c27097567913c0b2c75a7e67c (patch)
tree531ee6dfbda4cf4f72fff0a6c6c1b7f4ab24f15e /win32/time.c
parent37f135ceeffa522ec558cfac07bd53b98f5867e6 (diff)
downloadphp-git-dd60413c6198273c27097567913c0b2c75a7e67c.tar.gz
implement usleep for win32
Diffstat (limited to 'win32/time.c')
-rw-r--r--win32/time.c38
1 files changed, 9 insertions, 29 deletions
diff --git a/win32/time.c b/win32/time.c
index 9f07fab862..f77dfd2ff8 100644
--- a/win32/time.c
+++ b/win32/time.c
@@ -126,38 +126,18 @@ PHPAPI int gettimeofday(struct timeval *time_Info, struct timezone *timezone_Inf
return 0;
}
-
-/* this usleep isnt exactly accurate but should do ok */
void usleep(unsigned int useconds)
{
-struct timeval tnow, tthen, t0;
-
- gettimeofday(&tthen, NULL);
- t0 = tthen;
- tthen.tv_usec += useconds;
- while (tthen.tv_usec > 1000000) {
- tthen.tv_usec -= 1000000;
- tthen.tv_sec++;
- }
-
- if (useconds > 10000) {
- useconds -= 10000;
- Sleep(useconds/1000);
- }
-
- while (1) {
- gettimeofday(&tnow, NULL);
- if (tnow.tv_sec > tthen.tv_sec) {
- break;
- }
- if (tnow.tv_sec == tthen.tv_sec) {
- if (tnow.tv_usec > tthen.tv_usec) {
- break;
- }
- }
- }
-}
+ HANDLE timer;
+ LARGE_INTEGER due;
+
+ due.QuadPart = -useconds * 1000;
+ timer = CreateWaitableTimer(NULL, TRUE, NULL);
+ SetWaitableTimer(timer, &due, 0, NULL, NULL, 0);
+ WaitForSingleObject(timer, INFINITE);
+ CloseHandle(timer);
+}
#ifdef HAVE_SETITIMER