about summary refs log tree commit diff
path: root/stdlib
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib')
-rw-r--r--stdlib/a64l.c6
-rw-r--r--stdlib/seed48_r.c20
-rw-r--r--stdlib/srand48_r.c16
-rw-r--r--stdlib/stdlib.h20
4 files changed, 45 insertions, 17 deletions
diff --git a/stdlib/a64l.c b/stdlib/a64l.c
index 11ecd6a054..9d462c77f3 100644
--- a/stdlib/a64l.c
+++ b/stdlib/a64l.c
@@ -19,12 +19,12 @@
 
 #include <stdlib.h>
 
-long
+long int
 a64l (string)
      const char *string;
 {
-  int cnt;
-  long result = 0l;
+  size_t cnt;
+  long int result = 0l;
 
   for (cnt = 0; cnt < 6; ++cnt)
     {
diff --git a/stdlib/seed48_r.c b/stdlib/seed48_r.c
index fe4a0a8b3c..186d96cdd3 100644
--- a/stdlib/seed48_r.c
+++ b/stdlib/seed48_r.c
@@ -29,7 +29,25 @@ seed48_r (seed16v, buffer)
   memcpy (buffer->old_X, buffer->X, sizeof (buffer->X));
 
   /* Install new state.  */
-  memcpy (buffer->X, seed16v, sizeof (buffer->X));
+#if USHRT_MAX == 0xffffU
+  buffer->X[2] = seed16v[2];
+  buffer->X[1] = seed16v[1];
+  buffer->X[0] = seed16v[0];
+
+  buffer->a[2] = 0x5;
+  buffer->a[1] = 0xdeec;
+  buffer->a[0] = 0xe66d;
+#else
+  buffer->X[2] = (seed16v[2] << 16) | seed16v[1];
+  buffer->X[1] = seed16v[0] << 16;
+  buffer->X[0] = 0;
+
+  buffer->a[2] = 0x5deecUL;
+  buffer->a[1] = 0xe66d0000UL;
+  buffer->a[0] = 0;
+#endif
+  buffer->c = 0xb;
+  buffer->init = 1;
 
   return 0;
 }
diff --git a/stdlib/srand48_r.c b/stdlib/srand48_r.c
index 80cc7eb6c8..042c669950 100644
--- a/stdlib/srand48_r.c
+++ b/stdlib/srand48_r.c
@@ -22,22 +22,32 @@
 
 int
 srand48_r (seedval, buffer)
-     long seedval;
+     long int seedval;
      struct drand48_data *buffer;
 {
   /* The standards say we only have 32 bits.  */
-  if (sizeof (long) > 4)
+  if (sizeof (long int) > 4)
     seedval &= 0xffffffffl;
 
-#if (USHRT_MAX == 0xffffU)
+#if USHRT_MAX == 0xffffU
   buffer->X[2] = seedval >> 16;
   buffer->X[1] = seedval & 0xffffl;
   buffer->X[0] = 0x330e;
+
+  buffer->a[2] = 0x5;
+  buffer->a[1] = 0xdeec;
+  buffer->a[0] = 0xe66d;
 #else
   buffer->X[2] = seedval;
   buffer->X[1] = 0x330e0000UL;
   buffer->X[0] = 0;
+
+  buffer->a[2] = 0x5deecUL;
+  buffer->a[1] = 0xe66d0000UL;
+  buffer->a[0] = 0;
 #endif
+  buffer->c = 0xb;
+  buffer->init = 1;
 
   return 0;
 }
diff --git a/stdlib/stdlib.h b/stdlib/stdlib.h
index cc86d38361..4e60201bad 100644
--- a/stdlib/stdlib.h
+++ b/stdlib/stdlib.h
@@ -310,15 +310,15 @@ extern double drand48 __P ((void));
 extern double erand48 __P ((unsigned short int __xsubi[3]));
 
 /* Return non-negative, long integer in [0,2^31).  */
-extern long lrand48 __P ((void));
-extern long nrand48 __P ((unsigned short int __xsubi[3]));
+extern long int lrand48 __P ((void));
+extern long int nrand48 __P ((unsigned short int __xsubi[3]));
 
 /* Return signed, long integers in [-2^31,2^31).  */
-extern long mrand48 __P ((void));
-extern long jrand48 __P ((unsigned short int __xsubi[3]));
+extern long int mrand48 __P ((void));
+extern long int jrand48 __P ((unsigned short int __xsubi[3]));
 
 /* Seed random number generator.  */
-extern void srand48 __P ((long __seedval));
+extern void srand48 __P ((long int __seedval));
 extern unsigned short int *seed48 __P ((unsigned short int __seed16v[3]));
 extern void lcong48 __P ((unsigned short int __param[7]));
 
@@ -339,17 +339,17 @@ extern int erand48_r __P ((unsigned short int __xsubi[3],
 			   struct drand48_data *__buffer, double *__result));
 
 /* Return non-negative, long integer in [0,2^31).  */
-extern int lrand48_r __P ((struct drand48_data *__buffer, long *__result));
+extern int lrand48_r __P ((struct drand48_data *__buffer, long int *__result));
 extern int nrand48_r __P ((unsigned short int __xsubi[3],
-			   struct drand48_data *__buffer, long *__result));
+			   struct drand48_data *__buffer, long int *__result));
 
 /* Return signed, long integers in [-2^31,2^31).  */
-extern int mrand48_r __P ((struct drand48_data *__buffer, long *__result));
+extern int mrand48_r __P ((struct drand48_data *__buffer, long int *__result));
 extern int jrand48_r __P ((unsigned short int __xsubi[3],
-			   struct drand48_data *__buffer, long *__result));
+			   struct drand48_data *__buffer, long int *__result));
 
 /* Seed random number generator.  */
-extern int srand48_r __P ((long __seedval, struct drand48_data *__buffer));
+extern int srand48_r __P ((long int __seedval, struct drand48_data *__buffer));
 extern int seed48_r __P ((unsigned short int __seed16v[3],
 			  struct drand48_data *__buffer));
 extern int lcong48_r __P ((unsigned short int __param[7],