Subversion Repositories HelenOS-historic

Rev

Rev 542 | Rev 647 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. /*
  2.  * Copyright (C) 2005 Josef Cejka
  3.  * All rights reserved.
  4.  *
  5.  * Redistribution and use in source and binary forms, with or without
  6.  * modification, are permitted provided that the following conditions
  7.  * are met:
  8.  *
  9.  * - Redistributions of source code must retain the above copyright
  10.  *   notice, this list of conditions and the following disclaimer.
  11.  * - Redistributions in binary form must reproduce the above copyright
  12.  *   notice, this list of conditions and the following disclaimer in the
  13.  *   documentation and/or other materials provided with the distribution.
  14.  * - The name of the author may not be used to endorse or promote products
  15.  *   derived from this software without specific prior written permission.
  16.  *
  17.  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
  18.  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  19.  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  20.  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
  21.  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  22.  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  23.  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  24.  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  25.  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  26.  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  27.  */
  28.  
  29. #ifndef __SOFTFLOAT_H__
  30. #define __SOFTFLOAT_H__
  31.  
  32.  
  33. typedef union {
  34.     float f;
  35.     struct  {
  36.         #ifdef __BIG_ENDIAN__
  37.         __u32 sign:1;
  38.         __u32 exp:8;
  39.         __u32 mantisa:23;
  40.         #elif defined __LITTLE_ENDIAN__
  41.         __u32 mantisa:23;
  42.         __u32 exp:8;
  43.         __u32 sign:1;
  44.         #else
  45.         #error "Unknown endians."
  46.         #endif
  47.         } parts __attribute__ ((packed));
  48.     } float32;
  49.    
  50. typedef union {
  51.     double d;
  52.     struct  {
  53.         #ifdef __BIG_ENDIAN__
  54.         __u64 sign:1;
  55.         __u64 exp:11;
  56.         __u64 mantisa:52;
  57.         #elif defined __LITTLE_ENDIAN__
  58.         __u64 mantisa:52;
  59.         __u64 exp:11;
  60.         __u64 sign:1;
  61.         #else
  62.         #error "Unknown endians."
  63.         #endif
  64.         } parts __attribute__ ((packed));
  65.     } float64;
  66.  
  67. #define FLOAT32_MAX 0x7f800000
  68. #define FLOAT32_MIN 0xff800000
  69. #define FLOAT64_MAX
  70. #define FLOAT64_MIN
  71.  
  72. #define FLOAT32_BIAS 0xF7
  73. #define FLOAT64_BIAS 0x3FF
  74. #define FLOAT80_BIAS 0x3FFF
  75.  
  76.  
  77.  
  78. float __addsf3(float a, float b);
  79. double __adddf3(double a, double b);
  80. long double __addtf3(long double a, long double b);
  81. long double __addxf3(long double a, long double b);
  82.  
  83. float __subsf3(float a, float b);
  84. double __subdf3(double a, double b);
  85. long double __subtf3(long double a, long double b);
  86. long double __subxf3(long double a, long double b);
  87.  
  88. float __mulsf3(float a, float b);
  89. double __muldf3(double a, double b);
  90. long double __multf3(long double a, long double b);
  91. long double __mulxf3(long double a, long double b);
  92.  
  93. float __divsf3(float a, float b);
  94. double __divdf3(double a, double b);
  95. long double __divtf3(long double a, long double b);
  96. long double __divxf3(long double a, long double b);
  97.  
  98. float __negsf2(float a);
  99. double __negdf2(double a);
  100. long double __negtf2(long double a);
  101. long double __negxf2(long double a);
  102.  
  103. double __extendsfdf2(float a);
  104. long double __extendsftf2(float a);
  105. long double __extendsfxf2(float a);
  106. long double __extenddftf2(double a);
  107. long double __extenddfxf2(double a);
  108.  
  109. double __truncxfdf2(long double a);
  110. double __trunctfdf2(long double a);
  111. float __truncxfsf2(long double a);
  112. float __trunctfsf2(long double a);
  113. float __truncdfsf2(double a);
  114.  
  115. int __fixsfsi(float a);
  116. int __fixdfsi(double a);
  117. int __fixtfsi(long double a);
  118. int __fixxfsi(long double a);
  119.  
  120. long __fixsfdi(float a);
  121. long __fixdfdi(double a);
  122. long __fixtfdi(long double a);
  123. long __fixxfdi(long double a);
  124.  
  125. long long __fixsfti(float a);
  126. long long __fixdfti(double a);
  127. long long __fixtfti(long double a);
  128. long long __fixxfti(long double a);
  129.  
  130. unsigned int __fixunssfsi(float a);
  131. unsigned int __fixunsdfsi(double a);
  132. unsigned int __fixunstfsi(long double a);
  133. unsigned int __fixunsxfsi(long double a);
  134.  
  135. unsigned long __fixunssfdi(float a);
  136. unsigned long __fixunsdfdi(double a);
  137. unsigned long __fixunstfdi(long double a);
  138. unsigned long __fixunsxfdi(long double a);
  139.  
  140. unsigned long long __fixunssfti(float a);
  141. unsigned long long __fixunsdfti(double a);
  142. unsigned long long __fixunstfti(long double a);
  143. unsigned long long __fixunsxfti(long double a);
  144.  
  145. float __floatsisf(int i);
  146. double __floatsidf(int i);
  147. long double __floatsitf(int i);
  148. long double __floatsixf(int i);
  149.  
  150. float __floatdisf(long i);
  151. double __floatdidf(long i);
  152. long double __floatditf(long i);
  153. long double __floatdixf(long i);
  154.  
  155. float __floattisf(long long i);
  156. double __floattidf(long long i);
  157. long double __floattitf(long long i);
  158. long double __floattixf(long long i);
  159.  
  160. int __cmpsf2(float a, float b);
  161. int __cmpdf2(double a, double b);
  162. int __cmptf2(long double a, long double b);
  163.  
  164. int __unordsf2(float a, float b);
  165. int __unorddf2(double a, double b);
  166. int __unordtf2(long double a, long double b);
  167.  
  168. int __eqsf2(float a, float b);
  169. int __eqdf2(double a, double b);
  170. int __eqtf2(long double a, long double b);
  171.  
  172. int __nesf2(float a, float b);
  173. int __nedf2(double a, double b);
  174. int __netf2(long double a, long double b);
  175.  
  176. int __gesf2(float a, float b);
  177. int __gedf2(double a, double b);
  178. int __getf2(long double a, long double b);
  179.  
  180. int __ltsf2(float a, float b);
  181. int __ltdf2(double a, double b);
  182. int __lttf2(long double a, long double b);
  183. int __lesf2(float a, float b);
  184. int __ledf2(double a, double b);
  185. int __letf2(long double a, long double b);
  186.  
  187. int __gtsf2(float a, float b);
  188. int __gtdf2(double a, double b);
  189. int __gttf2(long double a, long double b);
  190.  
  191.  
  192. #endif
  193.  
  194.