mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00
implement usleep for win32
This commit is contained in:
parent
37f135ceef
commit
dd60413c61
2 changed files with 12 additions and 29 deletions
|
@ -103,7 +103,10 @@
|
||||||
#undef HAVE_SOLID
|
#undef HAVE_SOLID
|
||||||
#undef HAVE_LINK
|
#undef HAVE_LINK
|
||||||
#undef HAVE_SYMLINK
|
#undef HAVE_SYMLINK
|
||||||
#undef HAVE_USLEEP
|
|
||||||
|
/* its in win32/time.c */
|
||||||
|
#define HAVE_USLEEP 1
|
||||||
|
|
||||||
#define HAVE_GETCWD 1
|
#define HAVE_GETCWD 1
|
||||||
#define HAVE_POSIX_READDIR_R 1
|
#define HAVE_POSIX_READDIR_R 1
|
||||||
#define NEED_ISBLANK 1
|
#define NEED_ISBLANK 1
|
||||||
|
|
36
win32/time.c
36
win32/time.c
|
@ -126,39 +126,19 @@ PHPAPI int gettimeofday(struct timeval *time_Info, struct timezone *timezone_Inf
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* this usleep isnt exactly accurate but should do ok */
|
|
||||||
void usleep(unsigned int useconds)
|
void usleep(unsigned int useconds)
|
||||||
{
|
{
|
||||||
struct timeval tnow, tthen, t0;
|
HANDLE timer;
|
||||||
|
LARGE_INTEGER due;
|
||||||
|
|
||||||
gettimeofday(&tthen, NULL);
|
due.QuadPart = -useconds * 1000;
|
||||||
t0 = tthen;
|
timer = CreateWaitableTimer(NULL, TRUE, NULL);
|
||||||
tthen.tv_usec += useconds;
|
|
||||||
while (tthen.tv_usec > 1000000) {
|
SetWaitableTimer(timer, &due, 0, NULL, NULL, 0);
|
||||||
tthen.tv_usec -= 1000000;
|
WaitForSingleObject(timer, INFINITE);
|
||||||
tthen.tv_sec++;
|
CloseHandle(timer);
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef HAVE_SETITIMER
|
#ifdef HAVE_SETITIMER
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue