| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
#if 0 |
| 15 |
#include "tclInt.h" |
| 16 |
#include "tclPort.h" |
| 17 |
|
| 18 |
#else |
| 19 |
#include "tkPort.h" |
| 20 |
#include "Lang.h" |
| 21 |
#endif |
| 22 |
#ifdef TCL_EVENT_IMPLEMENT |
| 23 |
|
| 24 |
#ifdef __CYGWIN__ |
| 25 |
# include <sys/time.h> |
| 26 |
#endif |
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
void |
| 45 |
Tcl_Sleep(ms) |
| 46 |
int ms; |
| 47 |
{ |
| 48 |
struct timeval delay; |
| 49 |
Tcl_Time before, after; |
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
Tcl_GetTime(&before); |
| 59 |
after = before; |
| 60 |
after.sec += ms/1000; |
| 61 |
after.usec += (ms%1000)*1000; |
| 62 |
if (after.usec > 1000000) { |
| 63 |
after.usec -= 1000000; |
| 64 |
after.sec += 1; |
| 65 |
} |
| 66 |
while (1) { |
| 67 |
delay.tv_sec = after.sec - before.sec; |
| 68 |
delay.tv_usec = after.usec - before.usec; |
| 69 |
if (delay.tv_usec < 0) { |
| 70 |
delay.tv_usec += 1000000; |
| 71 |
delay.tv_sec -= 1; |
| 72 |
} |
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
if ((((int) delay.tv_sec) < 0) |
| 80 |
|| ((delay.tv_usec == 0) && (delay.tv_sec == 0))) { |
| 81 |
break; |
| 82 |
} |
| 83 |
(void) select(0, (SELECT_MASK *) 0, (SELECT_MASK *) 0, |
| 84 |
(SELECT_MASK *) 0, &delay); |
| 85 |
Tcl_GetTime(&before); |
| 86 |
} |
| 87 |
} |
| 88 |
|
| 89 |
#endif |
| 90 |
|