]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Added BSD implementations of millisleep.
authorGuido van Rossum <guido@python.org>
Tue, 19 Feb 1991 12:27:35 +0000 (12:27 +0000)
committerGuido van Rossum <guido@python.org>
Tue, 19 Feb 1991 12:27:35 +0000 (12:27 +0000)
Modules/timemodule.c

index 28d4ff7f8867aa85a09d3ad2a4724defe6df2ef9..9ea1f870187090d8711130209d4eade176d8274f 100644 (file)
@@ -73,6 +73,10 @@ extern long sys_milli();
 #define millitimer sys_milli
 #endif /* AMOEBA */
 
+#ifdef BSD_TIME
+#define DO_MILLI
+#endif /* BSD_TIME */
+
 #ifdef DO_MILLI
 
 static object *
@@ -169,3 +173,33 @@ millitimer()
 }
 
 #endif /* THINK_C */
+
+
+#ifdef BSD_TIME
+
+#include <sys/types.h>
+#include <sys/time.h>
+
+static long
+millitimer()
+{
+       struct timeval t;
+       struct timezone tz;
+       if (gettimeofday(&t, &tz) != 0)
+               return -1;
+       return t.tv_sec*1000 + t.tv_usec/1000;
+       
+}
+
+static
+millisleep(msecs)
+       long msecs;
+{
+       struct timeval t;
+       t.tv_sec = msecs/1000;
+       t.tv_usec = (msecs%1000)*1000;
+       (void) select(0, (fd_set *)0, (fd_set *)0, (fd_set *)0, &t);
+}
+
+#endif /* BSD_TIME */
+