RE: [PHP-DEV] PHP 4.0 Bug #8728 Updated: Patch: usleep() working on win32 platforms

From: Date: Mon, 15 Jan 2001 23:48:40 +0000
Subject: RE: [PHP-DEV] PHP 4.0 Bug #8728 Updated: Patch: usleep() working on win32 platforms
Groups: php.dev 
Request: Send a blank email to php-dev+get-44193@lists.php.net to get a copy of this message
well, AFAIK the usleep function is (mainly) useful to release cpu time for other tasks. the performance counter is probably more accurate but does consume a lot of cpu power without sleeping... -c -----Original Message----- From: Sean R. Bright [mailto:elixer@erols.com] Sent: lundi 15 janvier 2001 15:46 To: christophe@winamp.com; php-dev@lists.php.net Subject: RE: [PHP-DEV] PHP 4.0 Bug #8728 Updated: Patch: usleep() working on win32 platforms Christophe: I could be wrong but I would assume that the Performance counter allows more flexibility then Sleep() does by the simple fact that it doesn't suspend execution. Am I wrong? Sean > -----Original Message----- > From: christophe@winamp.com [mailto:christophe@winamp.com] > Sent: Monday, January 15, 2001 6:40 PM > To: php-dev@lists.php.net > Subject: [PHP-DEV] PHP 4.0 Bug #8728 Updated: Patch: usleep() > working on > win32 platforms > > > ID: 8728 > User Update by: christophe@winamp.com > Status: Open > Bug Type: Feature/Change Request > Description: Patch: usleep() working on win32 platforms > > oops... my previous patch was incorrect, let me start over: > in main/config.w32.h, line 93: /* Define if you have the > usleep function. */ #undef HAVE_USLEEP change it to: /* > Define if you have the usleep function. */ #define > HAVE_USLEEP 1 in win32/time.c, line 53: void > usleep(unsigned int useconds) { __int64 mstimer, freq; > long now, then; if > (QueryPerformanceFrequency((LARGE_INTEGER *) & freq)) { > QueryPerformanceCounter((LARGE_INTEGER *) & mstimer); > now = (long) (((__int64) (mstimer * .8)) % 0x0FFFFFFF); > then = now + useconds; while (now < > then) { > QueryPerformanceCounter((LARGE_INTEGER *) & mstimer); > now = (long) (((__int64) (mstimer * .8)) % > 0x0FFFFFFF); } } else { > /*workaround for systems without performance counter > this is actualy a millisecond sleep */ > Sleep((int) (useconds / 1000)); } } change it to: > void usleep(unsigned int useconds) { #if 0 __int64 > mstimer, freq; long now, then; if > (QueryPerformanceFrequency((LARGE_INTEGER *) & freq)) { > QueryPerformanceCounter((LARGE_INTEGER *) & mstimer); > now = (long) (((__int64) (mstimer * .8)) % 0x0FFFFFFF); > then = now + useconds; while (now < > then) { > QueryPerformanceCounter((LARGE_INTEGER *) & mstimer); > now = (long) (((__int64) (mstimer * .8)) % > 0x0FFFFFFF); } } else { > /*workaround for systems without performance counter > this is actualy a millisecond sleep */ > Sleep((int) (useconds / 1000)); } #else Sleep((DWORD) > useconds); #endif } and now it works great :) can someone > reflect this patch in the cvs tree? -Christophe Thibault > Nullsoft (www.nullsoft.com/www.winamp.com) > > Previous Comments: > -------------------------------------------------------------- > ------------- > > [2001-01-15 18:22:56] christophe@winamp.com > usleep exists on Win32 as the Sleep command (it takes a > millisecond value as parameter) so here is the patch for > making the usleep() php function to work on win32 platforms: > in main/win95nt.h, line 27: #define php_sleep(t) > Sleep(t*1000) add the following line so it looks like: > #define php_sleep(t) Sleep(t*1000) #define usleep(t) > Sleep(t) and in config.w32.h, line 93: /* Define if you > have the usleep function. */ #undef HAVE_USLEEP change it > to: /* Define if you have the usleep function. */ #define > HAVE_USLEEP 1 -Christophe Thibault Nullsoft (www.nullsoft.com/www.winamp.com) --------------------------------------------------------------------------- Full Bug description available at: http://bugs.php.net/?id=8728 -- PHP Development Mailing List <http://www.php.net/> To unsubscribe, e-mail: php-dev-unsubscribe@lists.php.net For additional commands, e-mail: php-dev-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net -- PHP Development Mailing List <http://www.php.net/> To unsubscribe, e-mail: php-dev-unsubscribe@lists.php.net For additional commands, e-mail: php-dev-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.dev (#44193) next »