diff options
author | andreas_kupries <akupries@shaw.ca> | 2005-01-21 22:24:43 (GMT) |
---|---|---|
committer | andreas_kupries <akupries@shaw.ca> | 2005-01-21 22:24:43 (GMT) |
commit | f11befd3bbce6f1f7a8cd43bb51bf6126ba125bf (patch) | |
tree | 403c7dfd1bf849fa476cb6ccaf3a2231eaca625a /unix/tclUnixEvent.c | |
parent | 2587836dd5f442ad7f95eb68cd40e56545b72663 (diff) | |
download | tcl-f11befd3bbce6f1f7a8cd43bb51bf6126ba125bf.zip tcl-f11befd3bbce6f1f7a8cd43bb51bf6126ba125bf.tar.gz tcl-f11befd3bbce6f1f7a8cd43bb51bf6126ba125bf.tar.bz2 |
* generic/tclStubInit.c: Regenerated the stubs support code from
* generic/tclDecls.h: the modified tcl.decls (TIP #233, see below).
* doc/GetTime.3: Implemented TIP #233, i.e. the
* generic/tcl.decls: 'Virtualization of Tcl's Sense of Time'.
* generic/tcl.h: Declared, implemented, and documented the
* generic/tclInt.h: specified new API functions. Moved the
* unix/tclUnixEvent.c: native (OS) access to time information
* unix/tclUnixNotfy.c: into standard handler functions. Inserted
* unix/tclUnixTime.c: hooks calling on the handlers where native
* win/tclWinNotify.c: access was done before, and where scaling
* win/tclWinTime.c: between domains (real/virtual) is required.
Diffstat (limited to 'unix/tclUnixEvent.c')
-rw-r--r-- | unix/tclUnixEvent.c | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/unix/tclUnixEvent.c b/unix/tclUnixEvent.c index 98ab452..036c898 100644 --- a/unix/tclUnixEvent.c +++ b/unix/tclUnixEvent.c @@ -8,10 +8,10 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclUnixEvent.c,v 1.5 2004/04/06 22:25:56 dgp Exp $ + * RCS: @(#) $Id: tclUnixEvent.c,v 1.6 2005/01/21 22:25:35 andreas_kupries Exp $ */ -#include "tclPort.h" +#include "tclInt.h" /* *---------------------------------------------------------------------- @@ -34,7 +34,7 @@ Tcl_Sleep(ms) int ms; /* Number of milliseconds to sleep. */ { struct timeval delay; - Tcl_Time before, after; + Tcl_Time before, after, vdelay; /* * The only trick here is that select appears to return early @@ -52,13 +52,23 @@ Tcl_Sleep(ms) after.sec += 1; } while (1) { - delay.tv_sec = after.sec - before.sec; - delay.tv_usec = after.usec - before.usec; - if (delay.tv_usec < 0) { - delay.tv_usec += 1000000; - delay.tv_sec -= 1; + /* TIP #233: Scale from virtual time to real-time for select */ + + vdelay.sec = after.sec - before.sec; + vdelay.usec = after.usec - before.usec; + + if (vdelay.usec < 0) { + vdelay.usec += 1000000; + vdelay.sec -= 1; } + if ((vdelay.sec != 0) || (vdelay.usec != 0)) { + (*tclScaleTimeProcPtr) (&vdelay, tclTimeClientData); + } + + delay.tv_sec = vdelay.sec; + delay.tv_usec = vdelay.usec; + /* * Special note: must convert delay.tv_sec to int before comparing * to zero, since delay.tv_usec is unsigned on some platforms. |