From 47dd33ef5e67856eb012b82b7b16d44bd05166c8 Mon Sep 17 00:00:00 2001 From: short <> Date: Thu, 14 Mar 2002 19:49:45 +0000 Subject: [PATCH] Some SIGIO-removal fixes --- acconfig.h | 10 ++++++++++ common/devices/device.c | 15 +++++++++------ include/uccompat.h | 5 ----- 3 files changed, 19 insertions(+), 11 deletions(-) diff --git a/acconfig.h b/acconfig.h index 590cc87..ebfa2da 100644 --- a/acconfig.h +++ b/acconfig.h @@ -94,4 +94,14 @@ extern void live_disable(int how); #endif /* STACKCHECK */ +#ifdef USE_UNIX98PTYS +# define _XOPEN_SOURCE 500 +#endif +#define _BSD_SOURCE 1 +#include +extern void usleep_watchdevice(unsigned long usecs); +#define usleep(usecs) usleep_watchdevice((usecs)) +#define sleep(secs) usleep((secs)*1000000) + + #endif /* __CONFIG_H__ */ diff --git a/common/devices/device.c b/common/devices/device.c index 826eee4..a912a74 100644 --- a/common/devices/device.c +++ b/common/devices/device.c @@ -192,6 +192,9 @@ struct timeval target,timeout; target.tv_sec +=usecs/1000000 + (target.tv_usec/1000000); target.tv_usec%=1000000; + target.tv_usec+=1000000; + target.tv_sec --; + for (;;) FD_ZERO(&readfds); if (device_portfd>=0) @@ -202,13 +205,13 @@ struct timeval target,timeout; if (target.tv_sec < timeout.tv_sec) return; timeout.tv_sec =target.tv_sec - timeout.tv_sec; - if (target.tv_usec < timeout.tv_usec) { - target.tv_usec+=1000000; - if (target.tv_sec <= 0) - return; - target.tv_sec--; - } timeout.tv_usec=target.tv_usec - timeout.tv_usec; + if (timeout.tv_usec>=1000000) { + timeout.tv_usec-=1000000; + if (!timeout.tv_sec) + return; + timeout.tv_sec--; + } err=select((device_portfd<0 ? 0 : device_portfd+1),&readfds,NULL,NULL,&timeout); if ( err > 0 ) { diff --git a/include/uccompat.h b/include/uccompat.h index f4f2359..fa3a2b7 100644 --- a/include/uccompat.h +++ b/include/uccompat.h @@ -36,11 +36,6 @@ extern char * strrchr __P ((const char *, int)); extern pid_t getpid(void); extern int execv(const char *path, char *const argv[]); -extern void usleep_watchdevice(unsigned long usecs); -#define usleep(usecs) usleep_watchdevice((usecs)) -#define sleep(secs) usleep((secs)*1000000) - - #endif /* UCCOMPAT */ -- 1.8.3.1