diff src/io.c @ 153:e57b2d131e6c

fix
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Thu, 17 Jan 2019 20:14:15 +0900
parents 80f4ec9a3420
children f524c0c95559
line wrap: on
line diff
--- a/src/io.c	Thu Jan 17 16:54:05 2019 +0900
+++ b/src/io.c	Thu Jan 17 20:14:15 2019 +0900
@@ -29,6 +29,7 @@
 #include<ctype.h>
 #include<signal.h>
 #include<sys/time.h>
+#include<strings.h>
 
 #include <unistd.h>
 #include <fcntl.h>
@@ -123,6 +124,17 @@
 #define pmem(a)  (&mem[a])
 #endif
 
+#if _POSIX_SOURCE>=200809L
+
+void usleep(long usec)
+{
+    struct timespec rdtp;
+    bzero(&rdtp,sizeof(struct timespec));
+    rdtp.tv_nsec = usec*1000;
+    nanosleep(&rdtp,0);
+}
+
+#endif
 
 extern int bpskip ;
 extern int stkskip ;
@@ -400,7 +412,8 @@
         newterm.c_cc[VMIN] = 1;
         newterm.c_cc[VINTR] = escchar;
         tcsetattr(0, TCSAFLUSH, &newterm);
-        fcntl(0, F_SETFL, tflags | O_NDELAY); /* Make input from stdin non-blocking */
+        // fcntl(0, F_SETFL, tflags | O_NDELAY); /* Make input from stdin non-blocking */
+        fcntl(0, F_SETFL, tflags | O_NONBLOCK); /* Make input from stdin non-blocking */
         signal(SIGALRM, timehandler);
         timercontrol.it_interval.tv_sec = 0;
         timercontrol.it_interval.tv_usec = timer_usec;