1*4afb647cSTimo Kreuzer 2*4afb647cSTimo Kreuzer /***********************************************************************************/ 3*4afb647cSTimo Kreuzer /** MIT License **/ 4*4afb647cSTimo Kreuzer /** ----------- **/ 5*4afb647cSTimo Kreuzer /** **/ 6*4afb647cSTimo Kreuzer /** Copyright (c) 2002-2019 Advanced Micro Devices, Inc. **/ 7*4afb647cSTimo Kreuzer /** **/ 8*4afb647cSTimo Kreuzer /** Permission is hereby granted, free of charge, to any person obtaining a copy **/ 9*4afb647cSTimo Kreuzer /** of this Software and associated documentaon files (the "Software"), to deal **/ 10*4afb647cSTimo Kreuzer /** in the Software without restriction, including without limitation the rights **/ 11*4afb647cSTimo Kreuzer /** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell **/ 12*4afb647cSTimo Kreuzer /** copies of the Software, and to permit persons to whom the Software is **/ 13*4afb647cSTimo Kreuzer /** furnished to do so, subject to the following conditions: **/ 14*4afb647cSTimo Kreuzer /** **/ 15*4afb647cSTimo Kreuzer /** The above copyright notice and this permission notice shall be included in **/ 16*4afb647cSTimo Kreuzer /** all copies or substantial portions of the Software. **/ 17*4afb647cSTimo Kreuzer /** **/ 18*4afb647cSTimo Kreuzer /** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR **/ 19*4afb647cSTimo Kreuzer /** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, **/ 20*4afb647cSTimo Kreuzer /** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE **/ 21*4afb647cSTimo Kreuzer /** AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER **/ 22*4afb647cSTimo Kreuzer /** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, **/ 23*4afb647cSTimo Kreuzer /** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN **/ 24*4afb647cSTimo Kreuzer /** THE SOFTWARE. **/ 25*4afb647cSTimo Kreuzer /***********************************************************************************/ 26*4afb647cSTimo Kreuzer 27*4afb647cSTimo Kreuzer #ifndef __LIBM_NEW_H__ 28*4afb647cSTimo Kreuzer #define __LIBM_NEW_H__ 29*4afb647cSTimo Kreuzer 30*4afb647cSTimo Kreuzer // Defines, protos, etc for *new* math funcs updated by AMD 11/2008 31*4afb647cSTimo Kreuzer // Old files will continue to include libm_util.h, libm.h, libm_inlines.h 32*4afb647cSTimo Kreuzer // until such time as these have all been refreshed w/ new versions. 33*4afb647cSTimo Kreuzer 34*4afb647cSTimo Kreuzer typedef float F32; 35*4afb647cSTimo Kreuzer typedef unsigned int U32; 36*4afb647cSTimo Kreuzer 37*4afb647cSTimo Kreuzer typedef double F64; 38*4afb647cSTimo Kreuzer typedef unsigned long long U64; 39*4afb647cSTimo Kreuzer 40*4afb647cSTimo Kreuzer union UT32_ 41*4afb647cSTimo Kreuzer { 42*4afb647cSTimo Kreuzer F32 f32; 43*4afb647cSTimo Kreuzer U32 u32; 44*4afb647cSTimo Kreuzer }; 45*4afb647cSTimo Kreuzer 46*4afb647cSTimo Kreuzer union UT64_ 47*4afb647cSTimo Kreuzer { 48*4afb647cSTimo Kreuzer F64 f64; 49*4afb647cSTimo Kreuzer U64 u64; 50*4afb647cSTimo Kreuzer 51*4afb647cSTimo Kreuzer F32 f32[2]; 52*4afb647cSTimo Kreuzer U32 u32[2]; 53*4afb647cSTimo Kreuzer }; 54*4afb647cSTimo Kreuzer 55*4afb647cSTimo Kreuzer typedef union UT32_ UT32; 56*4afb647cSTimo Kreuzer typedef union UT64_ UT64; 57*4afb647cSTimo Kreuzer 58*4afb647cSTimo Kreuzer #define SIGN_MASK_32 0x80000000 59*4afb647cSTimo Kreuzer #define MANTISSA_MASK_32 0x007fffff 60*4afb647cSTimo Kreuzer #define EXPONENT_MASK_32 0x7f800000 61*4afb647cSTimo Kreuzer #define QNAN_MASK_32 0x00400000 62*4afb647cSTimo Kreuzer 63*4afb647cSTimo Kreuzer #define INF_POS_32 0x7f800000 64*4afb647cSTimo Kreuzer #define INF_NEG_32 0xff800000 65*4afb647cSTimo Kreuzer #define QNAN_POS_32 0x7fc00000 66*4afb647cSTimo Kreuzer #define QNAN_NEG_32 0xffc00000 67*4afb647cSTimo Kreuzer #define IND_32 0xffc00000 68*4afb647cSTimo Kreuzer 69*4afb647cSTimo Kreuzer #define EXPONENT_FULL_32 0x7f800000 70*4afb647cSTimo Kreuzer #define SIGN_SET_32 0x80000000 71*4afb647cSTimo Kreuzer #define QNAN_SET_32 0x00400000 72*4afb647cSTimo Kreuzer 73*4afb647cSTimo Kreuzer #define INF_POS_64 0x7ff0000000000000 74*4afb647cSTimo Kreuzer #define INF_NEG_64 0xfff0000000000000 75*4afb647cSTimo Kreuzer 76*4afb647cSTimo Kreuzer #define MANTISSA_MASK_64 0x000fffffffffffff 77*4afb647cSTimo Kreuzer #define SIGN_MASK_64 0x8000000000000000 78*4afb647cSTimo Kreuzer #define IND_64 0xfff8000000000000 79*4afb647cSTimo Kreuzer #define QNAN_MASK_64 0x0008000000000000 80*4afb647cSTimo Kreuzer 81*4afb647cSTimo Kreuzer // constants for 'flags' argument of _handle_error and _handle_errorf 82*4afb647cSTimo Kreuzer #define AMD_F_INEXACT 0x00000010 83*4afb647cSTimo Kreuzer #define AMD_F_OVERFLOW 0x00000001 84*4afb647cSTimo Kreuzer #define AMD_F_UNDERFLOW 0x00000002 85*4afb647cSTimo Kreuzer #define AMD_F_DIVBYZERO 0x00000004 86*4afb647cSTimo Kreuzer #define AMD_F_INVALID 0x00000008 87*4afb647cSTimo Kreuzer 88*4afb647cSTimo Kreuzer // define the Microsoft specific error handling routine 89*4afb647cSTimo Kreuzer 90*4afb647cSTimo Kreuzer // Note to mainainers: 91*4afb647cSTimo Kreuzer // These prototypes may appear, at first glance, to differ from the versions 92*4afb647cSTimo Kreuzer // declared in libm_inlines.h and defined in libm_error.c. The third 93*4afb647cSTimo Kreuzer // parameter appears to have changed type from unsigned long to unsigned long 94*4afb647cSTimo Kreuzer // long. In fact they are the same because in both of the aforementioned 95*4afb647cSTimo Kreuzer // files, long has been #defined to __int64 in a most cowardly fashion. This 96*4afb647cSTimo Kreuzer // disgusts me. The buck stops here. - MAS 97*4afb647cSTimo Kreuzer 98*4afb647cSTimo Kreuzer double _handle_error( 99*4afb647cSTimo Kreuzer char *fname, 100*4afb647cSTimo Kreuzer int opcode, 101*4afb647cSTimo Kreuzer unsigned long long value, 102*4afb647cSTimo Kreuzer int type, 103*4afb647cSTimo Kreuzer int flags, 104*4afb647cSTimo Kreuzer int error, 105*4afb647cSTimo Kreuzer double arg1, 106*4afb647cSTimo Kreuzer double arg2, 107*4afb647cSTimo Kreuzer int nargs 108*4afb647cSTimo Kreuzer ); 109*4afb647cSTimo Kreuzer float _handle_errorf( 110*4afb647cSTimo Kreuzer char *fname, 111*4afb647cSTimo Kreuzer int opcode, 112*4afb647cSTimo Kreuzer unsigned long long value, 113*4afb647cSTimo Kreuzer int type, 114*4afb647cSTimo Kreuzer int flags, 115*4afb647cSTimo Kreuzer int error, 116*4afb647cSTimo Kreuzer float arg1, 117*4afb647cSTimo Kreuzer float arg2, 118*4afb647cSTimo Kreuzer int nargs 119*4afb647cSTimo Kreuzer ); 120*4afb647cSTimo Kreuzer 121*4afb647cSTimo Kreuzer #endif // __LIBM_NEW_H 122*4afb647cSTimo Kreuzer 123