POK
|
00001 /* 00002 * POK header 00003 * 00004 * The following file is a part of the POK project. Any modification should 00005 * made according to the POK licence. You CANNOT use this file or a part of 00006 * this file is this part of a file for your own project 00007 * 00008 * For more information on the POK licence, please see our LICENCE FILE 00009 * 00010 * Please follow the coding guidelines described in doc/CODING_GUIDELINES 00011 * 00012 * Copyright (c) 2007-2009 POK team 00013 * 00014 * Created by julien on Fri Jan 30 13:44:27 2009 00015 */ 00016 00017 /* 00018 * ==================================================== 00019 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. 00020 * 00021 * Developed at SunPro, a Sun Microsystems, Inc. business. 00022 * Permission to use, copy, modify, and distribute this 00023 * software is freely granted, provided that this notice 00024 * is preserved. 00025 * ==================================================== 00026 */ 00027 00028 /* 00029 * from: @(#)fdlibm.h 5.1 93/09/24 00030 * $NetBSD: math_private.h,v 1.13 2008/04/26 23:49:50 christos Exp $ 00031 */ 00032 00033 #ifdef POK_NEEDS_LIBMATH 00034 00035 #ifndef _MATH_PRIVATE_H_ 00036 #define _MATH_PRIVATE_H_ 00037 00038 #include <types.h> 00039 00040 #define _IEEE_LIBM 1 00041 00042 #define _LIB_VERSION 1 00043 #define _POSIX_ 1 00044 #define _SVID_ 2 00045 #define _IEEE_ 3 00046 00047 extern int signgam; 00048 00049 #define __P(protos) protos /* full-blown ANSI C */ 00050 00051 00052 /* The original fdlibm code used statements like: 00053 n0 = ((*(int*)&one)>>29)^1; * index of high word * 00054 ix0 = *(n0+(int*)&x); * high word of x * 00055 ix1 = *((1-n0)+(int*)&x); * low word of x * 00056 to dig two 32 bit words out of the 64 bit IEEE floating point 00057 value. That is non-ANSI, and, moreover, the gcc instruction 00058 scheduler gets it wrong. We instead use the following macros. 00059 Unlike the original code, we determine the endianness at compile 00060 time, not at run time; I don't see much benefit to selecting 00061 endianness at run time. */ 00062 00063 /* A union which permits us to convert between a double and two 32 bit 00064 ints. */ 00065 00066 /* 00067 * The ARM ports are little endian except for the FPA word order which is 00068 * big endian. 00069 */ 00070 /* 00071 #if (BYTE_ORDER == BIG_ENDIAN) || (defined(__arm__) && !defined(__VFP_FP__)) 00072 00073 typedef union 00074 { 00075 double value; 00076 struct 00077 { 00078 uint32_t msw; 00079 uint32_t lsw; 00080 } parts; 00081 } ieee_double_shape_type; 00082 00083 #endif 00084 */ 00085 #if (BYTE_ORDER == LITTLE_ENDIAN) && \ 00086 !(defined(__arm__) && !defined(__VFP_FP__)) 00087 typedef union 00088 { 00089 double value; 00090 struct 00091 { 00092 uint32_t lsw; 00093 uint32_t msw; 00094 } parts; 00095 } ieee_double_shape_type; 00096 #endif 00097 00098 /* Get two 32 bit ints from a double. */ 00099 00100 #define EXTRACT_WORDS(ix0,ix1,d) \ 00101 do { \ 00102 ieee_double_shape_type ew_u; \ 00103 ew_u.value = (d); \ 00104 (ix0) = ew_u.parts.msw; \ 00105 (ix1) = ew_u.parts.lsw; \ 00106 } while (/*CONSTCOND*/0) 00107 00108 /* Get the more significant 32 bit int from a double. */ 00109 00110 #define GET_HIGH_WORD(i,d) \ 00111 do { \ 00112 ieee_double_shape_type gh_u; \ 00113 gh_u.value = (d); \ 00114 (i) = gh_u.parts.msw; \ 00115 } while (/*CONSTCOND*/0) 00116 00117 /* Get the less significant 32 bit int from a double. */ 00118 00119 #define GET_LOW_WORD(i,d) \ 00120 do { \ 00121 ieee_double_shape_type gl_u; \ 00122 gl_u.value = (d); \ 00123 (i) = gl_u.parts.lsw; \ 00124 } while (/*CONSTCOND*/0) 00125 00126 /* Set a double from two 32 bit ints. */ 00127 00128 #define INSERT_WORDS(d,ix0,ix1) \ 00129 do { \ 00130 ieee_double_shape_type iw_u; \ 00131 iw_u.parts.msw = (ix0); \ 00132 iw_u.parts.lsw = (ix1); \ 00133 (d) = iw_u.value; \ 00134 } while (/*CONSTCOND*/0) 00135 00136 /* Set the more significant 32 bits of a double from an int. */ 00137 00138 #define SET_HIGH_WORD(d,v) \ 00139 do { \ 00140 ieee_double_shape_type sh_u; \ 00141 sh_u.value = (d); \ 00142 sh_u.parts.msw = (v); \ 00143 (d) = sh_u.value; \ 00144 } while (/*CONSTCOND*/0) 00145 00146 /* Set the less significant 32 bits of a double from an int. */ 00147 00148 #define SET_LOW_WORD(d,v) \ 00149 do { \ 00150 ieee_double_shape_type sl_u; \ 00151 sl_u.value = (d); \ 00152 sl_u.parts.lsw = (v); \ 00153 (d) = sl_u.value; \ 00154 } while (/*CONSTCOND*/0) 00155 00156 /* A union which permits us to convert between a float and a 32 bit 00157 int. */ 00158 00159 typedef union 00160 { 00161 float value; 00162 uint32_t word; 00163 } ieee_float_shape_type; 00164 00165 /* Get a 32 bit int from a float. */ 00166 00167 #define GET_FLOAT_WORD(i,d) \ 00168 do { \ 00169 ieee_float_shape_type gf_u; \ 00170 gf_u.value = (d); \ 00171 (i) = gf_u.word; \ 00172 } while (/*CONSTCOND*/0) 00173 00174 /* Set a float from a 32 bit int. */ 00175 00176 #define SET_FLOAT_WORD(d,i) \ 00177 do { \ 00178 ieee_float_shape_type sf_u; \ 00179 sf_u.word = (i); \ 00180 (d) = sf_u.value; \ 00181 } while (/*CONSTCOND*/0) 00182 00183 /* ieee style elementary functions */ 00184 extern double __ieee754_sqrt __P((double)); 00185 extern double __ieee754_acos __P((double)); 00186 extern double __ieee754_acosh __P((double)); 00187 extern double __ieee754_log __P((double)); 00188 extern double __ieee754_atanh __P((double)); 00189 extern double __ieee754_asin __P((double)); 00190 extern double __ieee754_atan2 __P((double,double)); 00191 extern double __ieee754_exp __P((double)); 00192 extern double __ieee754_cosh __P((double)); 00193 extern double __ieee754_fmod __P((double,double)); 00194 extern double __ieee754_pow __P((double,double)); 00195 extern double __ieee754_lgamma_r __P((double,int *)); 00196 extern double __ieee754_gamma_r __P((double,int *)); 00197 extern double __ieee754_lgamma __P((double)); 00198 extern double __ieee754_gamma __P((double)); 00199 extern double __ieee754_log10 __P((double)); 00200 extern double __ieee754_log2 __P((double)); 00201 extern double __ieee754_sinh __P((double)); 00202 extern double __ieee754_hypot __P((double,double)); 00203 extern double __ieee754_j0 __P((double)); 00204 extern double __ieee754_j1 __P((double)); 00205 extern double __ieee754_y0 __P((double)); 00206 extern double __ieee754_y1 __P((double)); 00207 extern double __ieee754_jn __P((int,double)); 00208 extern double __ieee754_yn __P((int,double)); 00209 extern double __ieee754_remainder __P((double,double)); 00210 extern int32_t __ieee754_rem_pio2 __P((double,double*)); 00211 extern double __ieee754_scalb __P((double,double)); 00212 00213 /* fdlibm kernel function */ 00214 extern double __kernel_standard __P((double,double,int)); 00215 extern double __kernel_sin __P((double,double,int)); 00216 extern double __kernel_cos __P((double,double)); 00217 extern double __kernel_tan __P((double,double,int)); 00218 extern int __kernel_rem_pio2 __P((double*,double*,int,int,int,const int*)); 00219 00220 00221 /* ieee style elementary float functions */ 00222 extern float __ieee754_sqrtf __P((float)); 00223 extern float __ieee754_acosf __P((float)); 00224 extern float __ieee754_acoshf __P((float)); 00225 extern float __ieee754_logf __P((float)); 00226 extern float __ieee754_atanhf __P((float)); 00227 extern float __ieee754_asinf __P((float)); 00228 extern float __ieee754_atan2f __P((float,float)); 00229 extern float __ieee754_expf __P((float)); 00230 extern float __ieee754_coshf __P((float)); 00231 extern float __ieee754_fmodf __P((float,float)); 00232 extern float __ieee754_powf __P((float,float)); 00233 extern float __ieee754_lgammaf_r __P((float,int *)); 00234 extern float __ieee754_gammaf_r __P((float,int *)); 00235 extern float __ieee754_lgammaf __P((float)); 00236 extern float __ieee754_gammaf __P((float)); 00237 extern float __ieee754_log10f __P((float)); 00238 extern float __ieee754_log2f __P((float)); 00239 extern float __ieee754_sinhf __P((float)); 00240 extern float __ieee754_hypotf __P((float,float)); 00241 extern float __ieee754_j0f __P((float)); 00242 extern float __ieee754_j1f __P((float)); 00243 extern float __ieee754_y0f __P((float)); 00244 extern float __ieee754_y1f __P((float)); 00245 extern float __ieee754_jnf __P((int,float)); 00246 extern float __ieee754_ynf __P((int,float)); 00247 extern float __ieee754_remainderf __P((float,float)); 00248 extern int32_t __ieee754_rem_pio2f __P((float,float*)); 00249 extern float __ieee754_scalbf __P((float,float)); 00250 00251 /* float versions of fdlibm kernel functions */ 00252 extern float __kernel_sinf __P((float,float,int)); 00253 extern float __kernel_cosf __P((float,float)); 00254 extern float __kernel_tanf __P((float,float,int)); 00255 extern int __kernel_rem_pio2f __P((float*,float*,int,int,int,const int*)); 00256 00257 00258 #endif /* _MATH_PRIVATE_H_ */ 00259 00260 #endif 00261