wez Sat Nov 29 17:48:43 2003 EDT
Modified files:
/php-src/main config.w32.h
/php-src/win32 time.c
Log:
implement usleep for win32
Index: php-src/main/config.w32.h
diff -u php-src/main/config.w32.h:1.80 php-src/main/config.w32.h:1.81
--- php-src/main/config.w32.h:1.80 Thu Nov 13 05:32:04 2003
+++ php-src/main/config.w32.h Sat Nov 29 17:48:41 2003
@@ -2,7 +2,7 @@
Build Configuration for Win32.
This has only been tested with MS VisualC++ 6 (and later).
- $Id: config.w32.h,v 1.80 2003/11/13 10:32:04 edink Exp $
+ $Id: config.w32.h,v 1.81 2003/11/29 22:48:41 wez Exp $
*/
/* Default PHP / PEAR directories */
@@ -103,7 +103,10 @@
#undef HAVE_SOLID
#undef HAVE_LINK
#undef HAVE_SYMLINK
-#undef HAVE_USLEEP
+
+/* its in win32/time.c */
+#define HAVE_USLEEP 1
+
#define HAVE_GETCWD 1
#define HAVE_POSIX_READDIR_R 1
#define NEED_ISBLANK 1
Index: php-src/win32/time.c
diff -u php-src/win32/time.c:1.6 php-src/win32/time.c:1.7
--- php-src/win32/time.c:1.6 Sun Jun 23 19:22:33 2002
+++ php-src/win32/time.c Sat Nov 29 17:48:42 2003
@@ -11,7 +11,7 @@
*
*****************************************************************************/
-/* $Id: time.c,v 1.6 2002/06/23 23:22:33 edink Exp $ */
+/* $Id: time.c,v 1.7 2003/11/29 22:48:42 wez Exp $ */
/**
*
@@ -126,38 +126,18 @@
return 0;
}
-
-/* this usleep isnt exactly accurate but should do ok */
void usleep(unsigned int useconds)
{
-struct timeval tnow, tthen, t0;
+ HANDLE timer;
+ LARGE_INTEGER due;
- 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;
- }
- }
- }
-}
+ due.QuadPart = -useconds * 1000;
+ timer = CreateWaitableTimer(NULL, TRUE, NULL);
+ SetWaitableTimer(timer, &due, 0, NULL, NULL, 0);
+ WaitForSingleObject(timer, INFINITE);
+ CloseHandle(timer);
+}
#ifdef HAVE_SETITIMER
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php