summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoland McGrath <roland@gnu.org>1995-02-22 05:47:15 +0000
committerRoland McGrath <roland@gnu.org>1995-02-22 05:47:15 +0000
commit50843ff068aae5b1ff58581eddd3bd107e99114b (patch)
tree0c72d59f78d63861d4a901fafd90cf6c3c822193
parent23ad311df0e01caa58b54afb8ae999a3ffc1ba7a (diff)
downloadglibc-50843ff068aae5b1ff58581eddd3bd107e99114b.tar.gz
Wed Feb 22 00:44:41 1995 Roland McGrath <roland@churchy.gnu.ai.mit.edu>
* sysdeps/mach/hurd/i386/sigreturn.c: Restore the FPU state. * stdlib/random.c (__srandom): Change algorithm used to populate the state array. (randtbl): Recomputed with new algorithm.
-rw-r--r--ChangeLog8
-rw-r--r--stdlib/random.c26
-rw-r--r--sysdeps/generic/signame.c19
-rw-r--r--sysdeps/generic/signame.h12
-rw-r--r--sysdeps/mach/hurd/i386/sigreturn.c7
5 files changed, 57 insertions, 15 deletions
diff --git a/ChangeLog b/ChangeLog
index 929fb46a0d..903f7e970f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
+Wed Feb 22 00:44:41 1995 Roland McGrath <roland@churchy.gnu.ai.mit.edu>
+
+ * sysdeps/mach/hurd/i386/sigreturn.c: Restore the FPU state.
+
Tue Feb 21 21:53:30 1995 Roland McGrath <roland@churchy.gnu.ai.mit.edu>
+ * stdlib/random.c (__srandom): Change algorithm used to populate
+ the state array.
+ (randtbl): Recomputed with new algorithm.
+
* sysdeps/sparc/Makefile [subdir=crypt] (crypt): Reset only if set
to original value of `crypt'.
* sysdeps/unix/sysv/sysv4/solaris2/sparc/Makefile [subdir=crypt]
diff --git a/stdlib/random.c b/stdlib/random.c
index fb32b36b87..473a5b13d3 100644
--- a/stdlib/random.c
+++ b/stdlib/random.c
@@ -122,12 +122,14 @@ static int seps[MAX_TYPES] = { SEP_0, SEP_1, SEP_2, SEP_3, SEP_4 };
static long int randtbl[DEG_3 + 1] =
{
TYPE_3,
- -851904987, -43806228, -2029755270, 1390239686, -1912102820,
- -485608943, 1969813258, -1590463333, -1944053249, 455935928, 508023712,
- -1714531963, 1800685987, -2015299881, 654595283, -1149023258,
- -1470005550, -1143256056, -1325577603, -1568001885, 1275120390,
- -607508183, -205999574, -1696891592, 1492211999, -1528267240,
- -952028296, -189082757, 362343714, 1424981831, 2039449641,
+
+ -1726662223, 379960547, 1735697613, 1040273694, 1313901226,
+ 1627687941, -179304937, -2073333483, 1780058412, -1989503057,
+ -615974602, 344556628, 939512070, -1249116260, 1507946756,
+ -812545463, 154635395, 1388815473, -1926676823, 525320961,
+ -1009028674, 968117788, -123449607, 1284210865, 435012392,
+ -2017506339, -911064859, -370259173, 1132637927, 1398500161,
+ -205601318,
};
/* FPTR and RPTR are two pointers into the state info, a front and a rear
@@ -179,11 +181,19 @@ DEFUN(__srandom, (x), unsigned int x)
{
register long int i;
for (i = 1; i < rand_deg; ++i)
- state[i] = (1103515145 * state[i - 1]) + 12345;
+ {
+ /* This does:
+ state[i] = (16807 * state[i - 1]) % 2147483647;
+ but avoids overflowing 31 bits. */
+ long int hi = state[i - 1] / 127773;
+ long int lo = state[i - 1] % 127773;
+ long int test = 16807 * lo - 2836 * hi;
+ state[i] = test + (test < 0 ? 2147483647 : 0);
+ }
fptr = &state[rand_sep];
rptr = &state[0];
for (i = 0; i < 10 * rand_deg; ++i)
- (void) __random();
+ (void) __random ();
}
}
diff --git a/sysdeps/generic/signame.c b/sysdeps/generic/signame.c
index 5f8deab3ad..40e72e0e4c 100644
--- a/sysdeps/generic/signame.c
+++ b/sysdeps/generic/signame.c
@@ -1,5 +1,5 @@
/* Convert between signal names and numbers.
- Copyright (C) 1990, 1992, 1993 Free Software Foundation, Inc.
+ Copyright (C) 1990, 1992, 1993, 1995 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -273,3 +273,20 @@ psignal (signal, message)
fprintf (stderr, "%s: %s\n", message, sys_siglist[signal]);
}
#endif
+
+#ifndef HAVE_STRSIGNAL
+/* Return the string associated with the signal number. */
+
+char *
+strsignal (signal)
+ int signal;
+{
+ static char buf[] = "Signal 12345678901234567890";
+
+ if (signal > 0 || signal < NSIG)
+ return sys_siglist[signal];
+
+ sprintf (buf, "Signal %d", signal);
+ return buf;
+}
+#endif
diff --git a/sysdeps/generic/signame.h b/sysdeps/generic/signame.h
index 2bd1637cfc..3ff6d9a303 100644
--- a/sysdeps/generic/signame.h
+++ b/sysdeps/generic/signame.h
@@ -1,5 +1,5 @@
/* Convert between signal names and numbers.
- Copyright (C) 1990, 1992, 1993 Free Software Foundation, Inc.
+ Copyright (C) 1990, 1992, 1993, 1995 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -29,7 +29,7 @@ char *sig_abbrev (int number);
signal by that name. */
int sig_number (const char *abbrev);
-/* Avoid conflicts with a system header file that might define these two. */
+/* Avoid conflicts with a system header file that might define these three. */
#ifndef HAVE_PSIGNAL
/* Print to standard error the name of SIGNAL, preceded by MESSAGE and
@@ -37,6 +37,11 @@ int sig_number (const char *abbrev);
void psignal (int signal, const char *message);
#endif
+#ifndef HAVE_STRSIGNAL
+/* Return the name of SIGNAL. */
+char *strsignal (int signal);
+#endif
+
#if !defined (HAVE_SYS_SIGLIST)
/* Names for signals from 0 to NSIG-1. */
extern const char *sys_siglist[];
@@ -50,6 +55,9 @@ int sig_number ();
#if !defined (HAVE_SYS_SIGLIST) && !defined (HAVE_PSIGNAL)
void psignal ();
#endif
+#ifndef HAVE_STRSIGNAL
+char *strsignal (int signal);
+#endif
#if !defined (HAVE_SYS_SIGLIST)
extern char *sys_siglist[];
#endif
diff --git a/sysdeps/mach/hurd/i386/sigreturn.c b/sysdeps/mach/hurd/i386/sigreturn.c
index df8960669f..19ba1d472c 100644
--- a/sysdeps/mach/hurd/i386/sigreturn.c
+++ b/sysdeps/mach/hurd/i386/sigreturn.c
@@ -80,10 +80,9 @@ __sigreturn (struct sigcontext *scp)
*reply_port = scp->sc_reply_port;
if (scp->sc_fpused)
- {
- /* XXX should restore FPU state here XXX roland needs 387 manual */
- /* abort (); */
- }
+ /* Restore the FPU state. Mach conveniently stores the state
+ in the format the i387 `frstor' instruction uses to restore it. */
+ asm volatile ("frstor %0" : : "m" (scp->sc_fpsave));
{
/* There are convenient instructions to pop state off the stack, so we