[581] | 1 | /* |
---|
| 2 | * ==================================================== |
---|
| 3 | * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
---|
| 4 | * |
---|
| 5 | * Developed at SunPro, a Sun Microsystems, Inc. business. |
---|
| 6 | * Permission to use, copy, modify, and distribute this |
---|
| 7 | * software is freely granted, provided that this notice |
---|
| 8 | * is preserved. |
---|
| 9 | * ==================================================== |
---|
| 10 | */ |
---|
| 11 | |
---|
| 12 | /* Modified for GIET-VM static OS at UPMC, France 2015. |
---|
| 13 | */ |
---|
| 14 | |
---|
| 15 | #ifndef _MATH_PRIVATE_H_ |
---|
| 16 | #define _MATH_PRIVATE_H_ |
---|
| 17 | |
---|
[588] | 18 | typedef unsigned int u_int32_t; |
---|
[581] | 19 | |
---|
[588] | 20 | typedef int int32_t; |
---|
[581] | 21 | |
---|
| 22 | /* The original fdlibm code used statements like: |
---|
| 23 | n0 = ((*(int*)&one)>>29)^1; * index of high word * |
---|
| 24 | ix0 = *(n0+(int*)&x); * high word of x * |
---|
| 25 | ix1 = *((1-n0)+(int*)&x); * low word of x * |
---|
| 26 | to dig two 32 bit words out of the 64 bit IEEE floating point |
---|
| 27 | value. That is non-ANSI, and, moreover, the gcc instruction |
---|
| 28 | scheduler gets it wrong. We instead use the following macros. |
---|
| 29 | Unlike the original code, we determine the endianness at compile |
---|
| 30 | time, not at run time; I don't see much benefit to selecting |
---|
| 31 | endianness at run time. */ |
---|
| 32 | |
---|
| 33 | /* A union which permits us to convert between a double and two 32 bit |
---|
| 34 | ints. */ |
---|
| 35 | |
---|
| 36 | /* |
---|
| 37 | * Math on arm is special (read: stupid): |
---|
| 38 | * For FPA, float words are always big-endian. |
---|
| 39 | * For VFP, float words follow the memory system mode. |
---|
| 40 | * For Maverick, float words are always little-endian. |
---|
| 41 | */ |
---|
| 42 | |
---|
| 43 | |
---|
| 44 | /* |
---|
| 45 | #if (__BYTE_ORDER == __BIG_ENDIAN) |
---|
| 46 | |
---|
| 47 | |
---|
| 48 | typedef union |
---|
| 49 | { |
---|
| 50 | double value; |
---|
| 51 | struct |
---|
| 52 | { |
---|
| 53 | u_int32_t msw; |
---|
| 54 | u_int32_t lsw; |
---|
| 55 | } parts; |
---|
| 56 | } ieee_double_shape_type; |
---|
| 57 | |
---|
| 58 | #else |
---|
| 59 | */ |
---|
| 60 | |
---|
| 61 | typedef union |
---|
| 62 | { |
---|
| 63 | double value; |
---|
| 64 | struct |
---|
| 65 | { |
---|
| 66 | u_int32_t lsw; |
---|
| 67 | u_int32_t msw; |
---|
| 68 | } parts; |
---|
| 69 | } ieee_double_shape_type; |
---|
| 70 | |
---|
| 71 | //#endif |
---|
| 72 | |
---|
| 73 | |
---|
| 74 | /* Get two 32 bit ints from a double. */ |
---|
| 75 | |
---|
| 76 | #define EXTRACT_WORDS(ix0,ix1,d) \ |
---|
| 77 | do { \ |
---|
| 78 | ieee_double_shape_type ew_u; \ |
---|
| 79 | ew_u.value = (d); \ |
---|
| 80 | (ix0) = ew_u.parts.msw; \ |
---|
| 81 | (ix1) = ew_u.parts.lsw; \ |
---|
| 82 | } while (0) |
---|
| 83 | |
---|
| 84 | /* Get the more significant 32 bit int from a double. */ |
---|
| 85 | |
---|
| 86 | #define GET_HIGH_WORD(i,d) \ |
---|
| 87 | do { \ |
---|
| 88 | ieee_double_shape_type gh_u; \ |
---|
| 89 | gh_u.value = (d); \ |
---|
| 90 | (i) = gh_u.parts.msw; \ |
---|
| 91 | } while (0) |
---|
| 92 | |
---|
| 93 | /* Get the less significant 32 bit int from a double. */ |
---|
| 94 | |
---|
| 95 | #define GET_LOW_WORD(i,d) \ |
---|
| 96 | do { \ |
---|
| 97 | ieee_double_shape_type gl_u; \ |
---|
| 98 | gl_u.value = (d); \ |
---|
| 99 | (i) = gl_u.parts.lsw; \ |
---|
| 100 | } while (0) |
---|
| 101 | |
---|
| 102 | /* Set a double from two 32 bit ints. */ |
---|
| 103 | |
---|
| 104 | #define INSERT_WORDS(d,ix0,ix1) \ |
---|
| 105 | do { \ |
---|
| 106 | ieee_double_shape_type iw_u; \ |
---|
| 107 | iw_u.parts.msw = (ix0); \ |
---|
| 108 | iw_u.parts.lsw = (ix1); \ |
---|
| 109 | (d) = iw_u.value; \ |
---|
| 110 | } while (0) |
---|
| 111 | |
---|
| 112 | /* Set the more significant 32 bits of a double from an int. */ |
---|
| 113 | |
---|
| 114 | #define SET_HIGH_WORD(d,v) \ |
---|
| 115 | do { \ |
---|
| 116 | ieee_double_shape_type sh_u; \ |
---|
| 117 | sh_u.value = (d); \ |
---|
| 118 | sh_u.parts.msw = (v); \ |
---|
| 119 | (d) = sh_u.value; \ |
---|
| 120 | } while (0) |
---|
| 121 | |
---|
| 122 | /* Set the less significant 32 bits of a double from an int. */ |
---|
| 123 | |
---|
| 124 | #define SET_LOW_WORD(d,v) \ |
---|
| 125 | do { \ |
---|
| 126 | ieee_double_shape_type sl_u; \ |
---|
| 127 | sl_u.value = (d); \ |
---|
| 128 | sl_u.parts.lsw = (v); \ |
---|
| 129 | (d) = sl_u.value; \ |
---|
| 130 | } while (0) |
---|
| 131 | |
---|
| 132 | int __ieee754_rem_pio2 (double,double*); |
---|
| 133 | double __ieee754_pow(double x, double y); |
---|
| 134 | //double __ieee754_sqrt(double x); |
---|
| 135 | |
---|
| 136 | int __kernel_rem_pio2(double *x, double *y, int e0, int nx, int prec, const int32_t *ipio2); |
---|
| 137 | double __kernel_sin (double,double,int); |
---|
| 138 | double __kernel_cos (double,double); |
---|
| 139 | |
---|
| 140 | |
---|
| 141 | #endif |
---|
| 142 | |
---|