00001 /* 00002 * $QNXLicenseC: 00003 * Copyright 2007, 2009, QNX Software Systems. All Rights Reserved. 00004 * 00005 * You must obtain a written license from and pay applicable license fees to QNX 00006 * Software Systems before you may reproduce, modify or distribute this software, 00007 * or any work that includes all or part of this software. Free development 00008 * licenses are available for evaluation and non-commercial purposes. For more 00009 * information visit http://licensing.qnx.com or email licensing@qnx.com. 00010 * 00011 * This file may contain contributions from others. Please review this entire 00012 * file for other proprietary rights or license notices, as well as the QNX 00013 * Development Suite License Guide at http://licensing.qnx.com/license-guide/ 00014 * for other information. 00015 * $ 00016 */ 00017 00018 /* 00019 =============================================================================== 00020 00021 This C source file is part of the SoftFloat IEC/IEEE Floating-point 00022 Arithmetic Package, Release 2. 00023 00024 Written by John R. Hauser. This work was made possible in part by the 00025 International Computer Science Institute, located at Suite 600, 1947 Center 00026 Street, Berkeley, California 94704. Funding was partially provided by the 00027 National Science Foundation under grant MIP-9311980. The original version 00028 of this code was written as part of a project to build a fixed-point vector 00029 processor in collaboration with the University of California at Berkeley, 00030 overseen by Profs. Nelson Morgan and John Wawrzynek. More information 00031 is available through the web page `http://HTTP.CS.Berkeley.EDU/~jhauser/ 00032 arithmetic/softfloat.html'. 00033 00034 THIS SOFTWARE IS DISTRIBUTED AS IS, FOR FREE. Although reasonable effort 00035 has been made to avoid it, THIS SOFTWARE MAY CONTAIN FAULTS THAT WILL AT 00036 TIMES RESULT IN INCORRECT BEHAVIOR. USE OF THIS SOFTWARE IS RESTRICTED TO 00037 PERSONS AND ORGANIZATIONS WHO CAN AND WILL TAKE FULL RESPONSIBILITY FOR ANY 00038 AND ALL LOSSES, COSTS, OR OTHER PROBLEMS ARISING FROM ITS USE. 00039 00040 Derivative works are acceptable, even for commercial purposes, so long as 00041 (1) they include prominent notice that the work is derivative, and (2) they 00042 include prominent notice akin to these three paragraphs for those parts of 00043 this code that are retained. 00044 00045 =============================================================================== 00046 */ 00047 #ifndef __FP_CONFIG_H__ 00048 #define __FP_CONFIG_H__ 00049 00050 /* 00051 ------------------------------------------------------------------------------- 00052 One of the macros `BIGENDIAN' or `LITTLEENDIAN' must be defined. 00053 ------------------------------------------------------------------------------- 00054 */ 00055 #include <gulliver.h> 00056 00057 /* 00058 ------------------------------------------------------------------------------- 00059 The macro `BITS64' can be defined to indicate that 64-bit integer types are 00060 supported by the compiler. 00061 ------------------------------------------------------------------------------- 00062 */ 00063 #define BITS64 00064 00065 /* 00066 ------------------------------------------------------------------------------- 00067 The macro `FLOATX80' must be defined to enable the extended double-precision 00068 floating-point format `floatx80'. If this macro is not defined, the 00069 `floatx80' type will not be defined, and none of the functions that either 00070 input or output the `floatx80' type will be defined. The same applies to 00071 the `FLOAT128' macro and the quadruple-precision format `float128'. 00072 ------------------------------------------------------------------------------- 00073 #define FLOATX80 00074 #define FLOAT128 00075 */ 00076 00077 00078 /* 00079 ------------------------------------------------------------------------------- 00080 Each of the following `typedef's defines the most convenient type that holds 00081 integers of at least as many bits as specified. For example, `uint8' should 00082 be the most convenient type that can hold unsigned integers of as many as 00083 8 bits. The `flag' type must be able to hold either a 0 or 1. For most 00084 implementations of C, `flag', `uint8', and `int8' should all be `typedef'ed 00085 to the same as `int'. 00086 ------------------------------------------------------------------------------- 00087 */ 00088 #include <inttypes.h> 00089 00090 typedef uint8_t flag; 00091 typedef uint8_t uint8; 00092 typedef int8_t int8; 00093 typedef uint16_t uint16; 00094 typedef int16_t int16; 00095 typedef uint32_t uint32; 00096 typedef int32_t int32; 00097 #ifdef BITS64 00098 typedef uint64_t uint64; 00099 typedef int64_t int64; 00100 #endif 00101 00102 /* 00103 ------------------------------------------------------------------------------- 00104 Each of the following `typedef's defines a type that holds integers 00105 of _exactly_ the number of bits specified. For instance, for most 00106 implementation of C, `bits16' and `sbits16' should be `typedef'ed to 00107 `unsigned short int' and `signed short int' (or `short int'), respectively. 00108 ------------------------------------------------------------------------------- 00109 */ 00110 typedef uint8_t bits8; 00111 typedef int8_t sbits8; 00112 typedef uint16_t bits16; 00113 typedef int16_t sbits16; 00114 typedef uint32_t bits32; 00115 typedef int32_t sbits32; 00116 #ifdef BITS64 00117 typedef uint64_t bits64; 00118 typedef int64_t sbits64; 00119 #endif 00120 00121 /* 00122 ------------------------------------------------------------------------------- 00123 Software IEC/IEEE floating-point types. 00124 ------------------------------------------------------------------------------- 00125 */ 00126 typedef uint32_t float32; 00127 typedef uint64_t float64; 00128 00129 #ifdef FLOATX80 00130 typedef struct { 00131 uint64_t low; 00132 uint16_t high; 00133 } floatx80; 00134 #endif 00135 #ifdef FLOAT128 00136 typedef struct { 00137 uint64_t low, high; 00138 } float128; 00139 #endif 00140 00141 00142 /* 00143 ------------------------------------------------------------------------------- 00144 The `LIT64' macro takes as its argument a textual integer literal and if 00145 necessary ``marks'' the literal as having a 64-bit integer type. For 00146 example, the Gnu C Compiler (`gcc') requires that 64-bit literals be 00147 appended with the letters `LL' standing for `long long', which is `gcc's 00148 name for the 64-bit integer type. Some compilers may allow `LIT64' to be 00149 defined as the identity macro: `#define LIT64( a ) a'. 00150 ------------------------------------------------------------------------------- 00151 */ 00152 #ifdef BITS64 00153 #define LIT64( a ) UINT64_C(a) 00154 #endif 00155 00156 /* 00157 ------------------------------------------------------------------------------- 00158 The macro `INLINE' can be used before functions that should be inlined. If 00159 a compiler does not support explicit inlining, this macro should be defined 00160 to be `static'. 00161 ------------------------------------------------------------------------------- 00162 */ 00163 #define INLINE static 00164 00165 /* 00166 ------------------------------------------------------------------------------- 00167 Software IEC/IEEE floating-point underflow tininess-detection mode. 00168 ------------------------------------------------------------------------------- 00169 */ 00170 enum { 00171 float_tininess_after_rounding = 0, 00172 float_tininess_before_rounding = 1 00173 }; 00174 00175 /* 00176 ------------------------------------------------------------------------------- 00177 Software IEC/IEEE floating-point rounding mode. 00178 ------------------------------------------------------------------------------- 00179 */ 00180 /* These have been set to map w/ the MIPS values in FCR31 */ 00181 enum { 00182 float_round_nearest_even = 0, 00183 float_round_down = 3, 00184 float_round_up = 2, 00185 float_round_to_zero = 1 00186 }; 00187 00188 /* 00189 ------------------------------------------------------------------------------- 00190 Software IEC/IEEE floating-point exception flags. 00191 ------------------------------------------------------------------------------- 00192 */ 00193 /* These have been set to map w/ the MIPS values in FCR31 */ 00194 enum { 00195 float_flag_inexact = 1, 00196 float_flag_underflow = 2, 00197 float_flag_overflow = 4, 00198 float_flag_divbyzero = 8, 00199 float_flag_invalid = 16 00200 }; 00201 00202 /* 00203 ------------------------------------------------------------------------------- 00204 Environment flags to operate under (rounding, exception, tininess) 00205 ------------------------------------------------------------------------------- 00206 */ 00207 typedef struct _run_options{ 00208 flag float_detect_tininess; 00209 flag float_rounding_mode; 00210 flag float_exception_flags; 00211 flag floatx80_rounding_precision; //Pads to 4 bytes if not used 00212 } run_options; 00213 00214 #endif 00215 00216 __SRCVERSION( "$URL: http://svn.ott.qnx.com/product/trunk/lib/ieee754/softfloat/fp-config.h $ $Rev: 223578 $" )