changeset 2648:0a8d853dfebb

* systime.h: Doc fix. (EMACS_SET_USECS): Remember that a `usec' is a microsecond, not a millisecond. What's three orders of magnitude between friends? * dispnew.c (Fsit_for, Fsleep_for): Remember to multiply the `milliseconds' argument by 1000 to get microseconds. * dispnew.c (Fsleep_for, Fsit_for): Allow SECONDS to be a floating point value. * dispnew.c (getenv): Extern declaration deleted; this is done in config.h.
author Jim Blandy <jimb@redhat.com>
date Tue, 04 May 1993 02:28:10 +0000
parents 425c4138af31
children 3a9fb5d6d259
files src/dispnew.c
diffstat 1 files changed, 34 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/src/dispnew.c	Tue May 04 02:26:53 1993 +0000
+++ b/src/dispnew.c	Tue May 04 02:28:10 1993 +0000
@@ -1794,22 +1794,32 @@
 
 DEFUN ("sleep-for", Fsleep_for, Ssleep_for, 1, 2, 0,
   "Pause, without updating display, for SECONDS seconds.\n\
-Optional second arg MILLISECONDS specifies an additional wait period,\n\
-in milliseconds.\n\
-\(Not all operating systems support milliseconds.)")
+SECONDS may be a floating-point value, meaning that you can wait for a\n\
+fraction of a second.  Optional second arg MILLISECONDS specifies an\n\
+additional wait period, in milliseconds; this may be useful if your\n\
+Emacs was built without floating point support.\n\
+\(Not all operating systems support waiting for a fraction of a second.)")
   (seconds, milliseconds)
      Lisp_Object seconds, milliseconds;
 {
   int sec, usec;
 
-  CHECK_NUMBER (seconds, 0);
-  sec = XINT (seconds);
-  
   if (NILP (milliseconds))
     XSET (milliseconds, Lisp_Int, 0);
   else
     CHECK_NUMBER (milliseconds, 1);
-  usec = XINT (milliseconds);
+  usec = XINT (milliseconds) * 1000;
+
+#ifdef LISP_FLOAT_TYPE
+  {
+    double duration = extract_float (seconds);
+    sec = (int) duration;
+    usec += (duration - sec) * 1000000;
+  }
+#else
+  CHECK_NUMBER (seconds, 0);
+  sec = XINT (seconds);
+#endif
 
 #ifndef EMACS_HAS_USECS
   if (sec == 0 && usec != 0)
@@ -1934,9 +1944,11 @@
 
 DEFUN ("sit-for", Fsit_for, Ssit_for, 1, 3, 0,
   "Perform redisplay, then wait for SECONDS seconds or until input is available.\n\
-Optional second arg MILLISECONDS specifies an additional wait period, in\n\
-milliseconds.\n\
-\(Not all operating systems support milliseconds.)\n\
+SECONDS may be a floating-point value, meaning that you can wait for a\n\
+fraction of a second.  Optional second arg MILLISECONDS specifies an\n\
+additional wait period, in milliseconds; this may be useful if your\n\
+Emacs was built without floating point support.\n\
+\(Not all operating systems support waiting for a fraction of a second.)\n\
 Optional third arg non-nil means don't redisplay, just wait for input.\n\
 Redisplay is preempted as always if input arrives, and does not happen\n\
 if input is available before it starts.\n\
@@ -1946,14 +1958,22 @@
 {
   int sec, usec;
 
-  CHECK_NUMBER (seconds, 0);
-  sec = XINT (seconds);
-
   if (NILP (milliseconds))
     XSET (milliseconds, Lisp_Int, 0);
   else
     CHECK_NUMBER (milliseconds, 1);
-  usec = XINT (milliseconds);
+  usec = XINT (milliseconds) * 1000;
+
+#ifdef LISP_FLOAT_TYPE
+  {
+    double duration = extract_float (seconds);
+    sec = (int) duration;
+    usec += (duration - sec) * 1000000;
+  }
+#else
+  CHECK_NUMBER (seconds, 0);
+  sec = XINT (seconds);
+#endif
 
 #ifndef EMACS_HAS_USECS
   if (usec != 0 && sec == 0)