summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1991-02-19 12:27:35 (GMT)
committerGuido van Rossum <guido@python.org>1991-02-19 12:27:35 (GMT)
commit426035c54322ed474f97d722d07861825c826d41 (patch)
tree8f1c1db72c1df2e6ee7044479797f3db98053c12 /Modules
parent2d14e21382fe28d4fbb390254ad27d04555fac3b (diff)
downloadcpython-426035c54322ed474f97d722d07861825c826d41.zip
cpython-426035c54322ed474f97d722d07861825c826d41.tar.gz
cpython-426035c54322ed474f97d722d07861825c826d41.tar.bz2
Added BSD implementations of millisleep.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/timemodule.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/Modules/timemodule.c b/Modules/timemodule.c
index 28d4ff7..9ea1f87 100644
--- a/Modules/timemodule.c
+++ b/Modules/timemodule.c
@@ -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 */
+