Fixup fromcvs/togit conversion
[minix-pkgsrc.git] / benchmarks / zelibm / patches / patch-ac
blob872b17b7933ad31051ea3d830632bdd51c98086e
1 $NetBSD: patch-ac,v 1.1.1.1 2005/07/27 17:06:53 drochner Exp $
3 --- zerandom.c.orig     1998-11-24 05:08:12.000000000 +0000
4 +++ zerandom.c
5 @@ -3,7 +3,11 @@
6     As a special restriction the file must not be used in this or a modified
7     form on Microsoft and Be systems.  */
8  
9 +#ifdef __linux__
10  #include <ieee754.h>
11 +#else
12 +#include <machine/ieee.h>
13 +#endif
14  #include <stdlib.h>
16  #include "zelibm.h"
17 @@ -15,15 +19,28 @@ zerandom (double low, double high)
18    /* Get two 31 bit random numbers for the initial mantissa.  */
19    unsigned int r1 = random ();
20    unsigned int r2 = random ();
21 +#ifdef __linux__
22    union ieee754_double u;
23 +#else
24 +  union ieee_double_u u;
25 +#endif
26    double res;
28 +#ifdef __linux__
29    u.ieee.negative = 0;
30    u.ieee.exponent = IEEE754_DOUBLE_BIAS - 1;
31    u.ieee.mantissa0 = r1 >> 1;
32    u.ieee.mantissa1 = r2 | r1 << 31;
34    res = low + 2 * (u.d - 0.5) * (high - low);
35 +#else
36 +  u.dblu_dbl.dbl_sign = 0;
37 +  u.dblu_dbl.dbl_exp = DBL_EXP_BIAS - 1;
38 +  u.dblu_dbl.dbl_frach = r1 >> 1;
39 +  u.dblu_dbl.dbl_fracl = r2 | r1 << 31;
41 +  res = low + 2 * (u.dblu_d - 0.5) * (high - low);
42 +#endif
44    while (res > high)
45      res /= 2.0;