Some SIGIO-removal fixes
authorshort <>
Thu, 14 Mar 2002 19:49:45 +0000 (19:49 +0000)
committershort <>
Thu, 14 Mar 2002 19:49:45 +0000 (19:49 +0000)
acconfig.h
common/devices/device.c
include/uccompat.h

index 590cc87..ebfa2da 100644 (file)
@@ -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 <unistd.h>
+extern void usleep_watchdevice(unsigned long usecs);
+#define usleep(usecs) usleep_watchdevice((usecs))
+#define sleep(secs)   usleep((secs)*1000000)
+
+
 #endif /* __CONFIG_H__ */
index 826eee4..a912a74 100644 (file)
@@ -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 ) {
index f4f2359..fa3a2b7 100644 (file)
@@ -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 */