about summary refs log tree commit diff
path: root/stdlib
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib')
-rw-r--r--stdlib/Makefile2
-rw-r--r--stdlib/erand48_r.c10
2 files changed, 9 insertions, 3 deletions
diff --git a/stdlib/Makefile b/stdlib/Makefile
index 2eb1843a4a..0076ad4fff 100644
--- a/stdlib/Makefile
+++ b/stdlib/Makefile
@@ -21,7 +21,7 @@
 #
 subdir	:= stdlib
 
-headers	:= stdlib.h alloca.h monetary.h fmtmsg.h
+headers	:= stdlib.h alloca.h monetary.h fmtmsg.h ucontext.h sys/ucontext.h
 
 routines	:=							      \
 	atof atoi atol atoll						      \
diff --git a/stdlib/erand48_r.c b/stdlib/erand48_r.c
index b3f8b634e3..85393b79f6 100644
--- a/stdlib/erand48_r.c
+++ b/stdlib/erand48_r.c
@@ -42,12 +42,18 @@ __erand48_r (xsubi, buffer, result)
   temp.ieee.exponent = IEEE754_DOUBLE_BIAS;
   temp.ieee.mantissa0 = (xsubi[2] << 4) | (xsubi[1] >> 12);
   temp.ieee.mantissa1 = ((xsubi[1] & 0xfff) << 20) | (xsubi[0] << 4);
-  /* Please note the lower 4 bits of mantissa1 are always 0.  */
-  *result = temp.d - 1.0;
+#elif USHRT_MAX == 2147483647
+  temp.ieee.negative = 0;
+  temp.ieee.exponent = IEEE754_DOUBLE_BIAS;
+  temp.ieee.mantissa0 = (xsubi[1] << 4) | (xsubi[0] >> 28);
+  temp.ieee.mantissa1 = ((xsubi[0] & 0xfffffff) << 4);
 #else
 # error Unsupported size of short int
 #endif
 
+  /* Please note the lower 4 bits of mantissa1 are always 0.  */
+  *result = temp.d - 1.0;
+
   return 0;
 }
 weak_alias (__erand48_r, erand48_r)