]> code.delx.au - gnu-emacs/blobdiff - src/sysdep.c
(random, srandom): Check HAVE_LRAND48, not HAVE_RAND48.
[gnu-emacs] / src / sysdep.c
index c6a3b4f7a82e228bb6186102dd876e0c5178f2a7..004a0b95676cfda9d2e80053b0a530bf593d3f2d 100644 (file)
@@ -279,6 +279,11 @@ init_baud_rate ()
       sg.c_cflag = B9600;
       tcgetattr (input_fd, &sg);
       ospeed = cfgetospeed (&sg);
+#if defined (USE_GETOBAUD) && defined (getobaud)
+      /* m88k-motorola-sysv3 needs this (ghazi@noc.rutgers.edu) 9/1/94. */
+      if (ospeed == 0)
+        ospeed = getobaud (sg.c_cflag);
+#endif
 #else /* neither VMS nor TERMIOS */
 #ifdef HAVE_TERMIO
       struct termio sg;
@@ -2609,18 +2614,25 @@ bcmp (b1, b2, length)   /* This could be a macro! */
 long
 random ()
 {
-#ifdef HAVE_RAND48
-  return rand48 ();
+#ifdef HAVE_LRAND48
+  return lrand48 ();
 #else
-  /* Arrange to return a range centered on zero.  */
-  return (rand () << 15) + rand () - (1 << 29);
+/* The BSD rand returns numbers in the range of 0 to 2e31 - 1,
+   with unusable least significant bits.  The USG rand returns
+   numbers in the range of 0 to 2e15 - 1, all usable.  Let us
+   build a usable 30 bit number from either.  */
+#ifdef USG
+  return (rand () << 15) + rand ();
+#else
+  return (rand () & 0x3fff8000) + (rand () >> 16);
+#endif
 #endif
 }
 
 srandom (arg)
      int arg;
 {
-#ifdef HAVE_RAND48
+#ifdef HAVE_LRAND48
   return srand48 ();
 #else
   srand (arg);