pajoye          Mon Jan 19 02:29:24 2009 UTC

  Modified files:              
    /php-src/win32      time.c time.h unistd.h 
  Log:
  - add nanosleep
  - expose nanosleep and usleep
  - [DOC] time_ nanosleep and time_ sleep_ until available on windows
  
http://cvs.php.net/viewvc.cgi/php-src/win32/time.c?r1=1.12&r2=1.13&diff_format=u
Index: php-src/win32/time.c
diff -u php-src/win32/time.c:1.12 php-src/win32/time.c:1.13
--- php-src/win32/time.c:1.12   Thu Aug 14 23:21:32 2008
+++ php-src/win32/time.c        Mon Jan 19 02:29:24 2009
@@ -11,7 +11,7 @@
  *
  *****************************************************************************/
 
-/* $Id: time.c,v 1.12 2008/08/14 23:21:32 kalle Exp $ */
+/* $Id: time.c,v 1.13 2009/01/19 02:29:24 pajoye Exp $ */
 
  /**
   *
@@ -127,7 +127,7 @@
        return 0;
 }
 
-void usleep(unsigned int useconds)
+PHPAPI int usleep(unsigned int useconds)
 {
        HANDLE timer;
        LARGE_INTEGER due;
@@ -138,6 +138,17 @@
        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 */
http://cvs.php.net/viewvc.cgi/php-src/win32/time.h?r1=1.9&r2=1.10&diff_format=u
Index: php-src/win32/time.h
diff -u php-src/win32/time.h:1.9 php-src/win32/time.h:1.10
--- php-src/win32/time.h:1.9    Tue Feb 18 13:34:52 2003
+++ php-src/win32/time.h        Mon Jan 19 02:29:24 2009
@@ -28,6 +28,14 @@
        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 setitimer(int which, const struct itimerval *value,
                                         struct itimerval *ovalue);
 
+PHPAPI int nanosleep( const struct timespec * rqtp, struct timespec * rmtp );
+
 #endif
http://cvs.php.net/viewvc.cgi/php-src/win32/unistd.h?r1=1.2&r2=1.3&diff_format=u
Index: php-src/win32/unistd.h
diff -u php-src/win32/unistd.h:1.2 php-src/win32/unistd.h:1.3
--- php-src/win32/unistd.h:1.2  Thu Jun 28 23:28:25 2001
+++ php-src/win32/unistd.h      Mon Jan 19 02:29:24 2009
@@ -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


Reply via email to