alarmMemoryDefinition.h 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. /*
  2. ===============================================================================
  3. This C header file is part of the SoftFloat IEC/IEEE Floating-point
  4. Arithmetic Package, Release 2.
  5. Written by John R. Hauser. This work was made possible in part by the
  6. International Computer Science Institute, located at Suite 600, 1947 Center
  7. Street, Berkeley, California 94704. Funding was partially provided by the
  8. National Science Foundation under grant MIP-9311980. The original version
  9. of this code was written as part of a project to build a fixed-point vector
  10. processor in collaboration with the University of California at Berkeley,
  11. overseen by Profs. Nelson Morgan and John Wawrzynek. More information
  12. is available through the Web page
  13. http://www.jhauser.us/arithmetic/SoftFloat-2b/SoftFloat-source.txt
  14. THIS SOFTWARE IS DISTRIBUTED AS IS, FOR FREE. Although reasonable effort
  15. has been made to avoid it, THIS SOFTWARE MAY CONTAIN FAULTS THAT WILL AT
  16. TIMES RESULT IN INCORRECT BEHAVIOR. USE OF THIS SOFTWARE IS RESTRICTED TO
  17. PERSONS AND ORGANIZATIONS WHO CAN AND WILL TAKE FULL RESPONSIBILITY FOR ANY
  18. AND ALL LOSSES, COSTS, OR OTHER PROBLEMS ARISING FROM ITS USE.
  19. Derivative works are acceptable, even for commercial purposes, so long as
  20. (1) they include prominent notice that the work is derivative, and (2) they
  21. include prominent notice akin to these three paragraphs for those parts of
  22. this code that are retained.
  23. ===============================================================================
  24. */
  25. #ifndef __SOFTFLOAT_H__
  26. #define __SOFTFLOAT_H__
  27. /*
  28. -------------------------------------------------------------------------------
  29. The macro `FLOATX80' must be defined to enable the extended double-precision
  30. floating-point format `floatx80'. If this macro is not defined, the
  31. `floatx80' type will not be defined, and none of the functions that either
  32. input or output the `floatx80' type will be defined.
  33. -------------------------------------------------------------------------------
  34. */
  35. #ifdef CONFIG_FPE_NWFPE_XP
  36. #define FLOATX80
  37. #endif
  38. /*
  39. -------------------------------------------------------------------------------
  40. Software IEC/IEEE floating-point types.
  41. -------------------------------------------------------------------------------
  42. */
  43. typedef u32 float32;
  44. typedef u64 float64;
  45. typedef struct {
  46. #ifdef __ARMEB__
  47. u16 __padding;
  48. u16 high;
  49. #else
  50. u16 high;
  51. u16 __padding;
  52. #endif
  53. u64 low;
  54. } __attribute__ ((packed,aligned(4))) floatx80;
  55. /*
  56. -------------------------------------------------------------------------------
  57. Software IEC/IEEE floating-point underflow tininess-detection mode.
  58. -------------------------------------------------------------------------------
  59. */
  60. extern signed char float_detect_tininess;
  61. enum {
  62. float_tininess_after_rounding = 0,
  63. float_tininess_before_rounding = 1
  64. };
  65. /*
  66. -------------------------------------------------------------------------------
  67. Software IEC/IEEE floating-point rounding mode.
  68. -------------------------------------------------------------------------------
  69. */
  70. //extern int8 float_rounding_mode;
  71. enum {
  72. float_round_nearest_even = 0,
  73. float_round_to_zero = 1,
  74. float_round_down = 2,
  75. float_round_up = 3
  76. };
  77. /*
  78. -------------------------------------------------------------------------------
  79. Software IEC/IEEE floating-point exception flags.
  80. -------------------------------------------------------------------------------
  81. enum {
  82. float_flag_inexact = 1,
  83. float_flag_underflow = 2,
  84. float_flag_overflow = 4,
  85. float_flag_divbyzero = 8,
  86. float_flag_invalid = 16
  87. };
  88. ScottB: November 4, 1998
  89. Changed the enumeration to match the bit order in the FPA11.
  90. */
  91. enum {
  92. float_flag_invalid = 1,
  93. float_flag_divbyzero = 2,
  94. float_flag_overflow = 4,
  95. float_flag_underflow = 8,
  96. float_flag_inexact = 16
  97. };
  98. /*
  99. -------------------------------------------------------------------------------
  100. Routine to raise any or all of the software IEC/IEEE floating-point
  101. exception flags.
  102. -------------------------------------------------------------------------------
  103. */
  104. void float_raise( signed char );
  105. /*
  106. -------------------------------------------------------------------------------
  107. Software IEC/IEEE integer-to-floating-point conversion routines.
  108. -------------------------------------------------------------------------------
  109. */
  110. float32 int32_to_float32( struct roundingData *, signed int );
  111. float64 int32_to_float64( signed int );
  112. #ifdef FLOATX80
  113. floatx80 int32_to_floatx80( signed int );
  114. #endif
  115. /*
  116. -------------------------------------------------------------------------------
  117. Software IEC/IEEE single-precision conversion routines.
  118. -------------------------------------------------------------------------------
  119. */
  120. signed int float32_to_int32( struct roundingData *, float32 );
  121. signed int float32_to_int32_round_to_zero( float32 );
  122. float64 float32_to_float64( float32 );
  123. #ifdef FLOATX80
  124. floatx80 float32_to_floatx80( float32 );
  125. #endif
  126. /*
  127. -------------------------------------------------------------------------------
  128. Software IEC/IEEE single-precision operations.
  129. -------------------------------------------------------------------------------
  130. */
  131. float32 float32_round_to_int( struct roundingData*, float32 );
  132. float32 float32_add( struct roundingData *, float32, float32 );
  133. float32 float32_sub( struct roundingData *, float32, float32 );
  134. float32 float32_mul( struct roundingData *, float32, float32 );
  135. float32 float32_div( struct roundingData *, float32, float32 );
  136. float32 float32_rem( struct roundingData *, float32, float32 );
  137. float32 float32_sqrt( struct roundingData*, float32 );
  138. char float32_eq( float32, float32 );
  139. char float32_le( float32, float32 );
  140. char float32_lt( float32, float32 );
  141. char float32_eq_signaling( float32, float32 );
  142. char float32_le_quiet( float32, float32 );
  143. char float32_lt_quiet( float32, float32 );
  144. char float32_is_signaling_nan( float32 );
  145. /*
  146. -------------------------------------------------------------------------------
  147. Software IEC/IEEE double-precision conversion routines.
  148. -------------------------------------------------------------------------------
  149. */
  150. signed int float64_to_int32( struct roundingData *, float64 );
  151. signed int float64_to_int32_round_to_zero( float64 );
  152. float32 float64_to_float32( struct roundingData *, float64 );
  153. #ifdef FLOATX80
  154. floatx80 float64_to_floatx80( float64 );
  155. #endif
  156. /*
  157. -------------------------------------------------------------------------------
  158. Software IEC/IEEE double-precision operations.
  159. -------------------------------------------------------------------------------
  160. */
  161. float64 float64_round_to_int( struct roundingData *, float64 );