pajoye Mon Jan 19 02:35:22 2009 UTC
Modified files: (Branch: PHP_5_3)
/php-src/ext/standard basic_functions.c
/php-src/win32/build config.w32.h.in
/php-src/win32 time.c time.h unistd.h
Log:
- MFH:
- add nanosleep
- expose nanosleep and usleep
- [DOC] time_ nanosleep and time_ sleep_ until available on windows
- change nanosleep signature to match posix one
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/basic_functions.c?r1=1.725.2.31.2.64.2.85&r2=1.725.2.31.2.64.2.86&diff_format=u
Index: php-src/ext/standard/basic_functions.c
diff -u php-src/ext/standard/basic_functions.c:1.725.2.31.2.64.2.85
php-src/ext/standard/basic_functions.c:1.725.2.31.2.64.2.86
--- php-src/ext/standard/basic_functions.c:1.725.2.31.2.64.2.85 Fri Jan 16
01:01:04 2009
+++ php-src/ext/standard/basic_functions.c Mon Jan 19 02:35:21 2009
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: basic_functions.c,v 1.725.2.31.2.64.2.85 2009/01/16 01:01:04 pajoye
Exp $ */
+/* $Id: basic_functions.c,v 1.725.2.31.2.64.2.86 2009/01/19 02:35:21 pajoye
Exp $ */
#include "php.h"
#include "php_streams.h"
@@ -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;
http://cvs.php.net/viewvc.cgi/php-src/win32/build/config.w32.h.in?r1=1.7.2.4.2.3.2.7&r2=1.7.2.4.2.3.2.8&diff_format=u
Index: php-src/win32/build/config.w32.h.in
diff -u php-src/win32/build/config.w32.h.in:1.7.2.4.2.3.2.7
php-src/win32/build/config.w32.h.in:1.7.2.4.2.3.2.8
--- php-src/win32/build/config.w32.h.in:1.7.2.4.2.3.2.7 Wed Dec 31 19:47:13 2008
+++ php-src/win32/build/config.w32.h.in Mon Jan 19 02:35:21 2009
@@ -1,6 +1,6 @@
/*
Build Configuration Template for Win32.
- $Id: config.w32.h.in,v 1.7.2.4.2.3.2.7 2008/12/31 19:47:13 pajoye Exp $
+ $Id: config.w32.h.in,v 1.7.2.4.2.3.2.8 2009/01/19 02:35:21 pajoye Exp $
*/
/* Define the minimum supported version */
@@ -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
http://cvs.php.net/viewvc.cgi/php-src/win32/time.c?r1=1.10.6.2&r2=1.10.6.3&diff_format=u
Index: php-src/win32/time.c
diff -u php-src/win32/time.c:1.10.6.2 php-src/win32/time.c:1.10.6.3
--- php-src/win32/time.c:1.10.6.2 Thu Aug 14 23:29:25 2008
+++ php-src/win32/time.c Mon Jan 19 02:35:21 2009
@@ -11,7 +11,7 @@
*
*****************************************************************************/
-/* $Id: time.c,v 1.10.6.2 2008/08/14 23:29:25 kalle Exp $ */
+/* $Id: time.c,v 1.10.6.3 2009/01/19 02:35:21 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.9.8.1&diff_format=u
Index: php-src/win32/time.h
diff -u php-src/win32/time.h:1.9 php-src/win32/time.h:1.9.8.1
--- php-src/win32/time.h:1.9 Tue Feb 18 13:34:52 2003
+++ php-src/win32/time.h Mon Jan 19 02:35:22 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.2.30.1&diff_format=u
Index: php-src/win32/unistd.h
diff -u php-src/win32/unistd.h:1.2 php-src/win32/unistd.h:1.2.30.1
--- php-src/win32/unistd.h:1.2 Thu Jun 28 23:28:25 2001
+++ php-src/win32/unistd.h Mon Jan 19 02:35:22 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