Home | History | Annotate | Line # | Download | only in softfloat
qp.c revision 1.2
      1 /* $NetBSD: qp.c,v 1.2 2002/03/27 03:41:54 jmc Exp $ */
      2 
      3 #include <sys/cdefs.h>
      4 #include <memory.h>
      5 
      6 #include "milieu.h"
      7 #include "softfloat.h"
      8 
      9 
     10 void _Qp_add(float128 *c, float128 *a, float128 *b);
     11 
     12 void _Qp_add(float128 *c, float128 *a, float128 *b)
     13 {
     14 	 *c =  float128_add(*a, *b);
     15 }
     16 
     17 
     18 int _Qp_cmp(float128 *a, float128 *b);
     19 
     20 int _Qp_cmp(float128 *a, float128 *b)
     21 {
     22 
     23 	if (float128_eq(*a, *b))
     24 		return 0;
     25 
     26 	if (float128_le(*a, *b))
     27 		return 1;
     28 
     29 	return 2;
     30 }
     31 
     32 
     33 /*
     34  * XXX
     35  */
     36 int _Qp_cmpe(float128 *a, float128 *b);
     37 
     38 int _Qp_cmpe(float128 *a, float128 *b)
     39 {
     40 	return _Qp_cmp(a, b);
     41 }
     42 
     43 
     44 void _Qp_div(float128 *c, float128 *a, float128 *b);
     45 
     46 void _Qp_div(float128 *c, float128 *a, float128 *b)
     47 {
     48 	*c = float128_div(*a, *b);
     49 }
     50 
     51 
     52 void _Qp_dtoq(float128 *c, double a);
     53 
     54 void _Qp_dtoq(float128 *c, double a)
     55 {
     56 	float64 _b;
     57 	memcpy (&_b, &a, sizeof(float64));
     58 	*c = float64_to_float128(b);
     59 }
     60 
     61 
     62 
     63 int _Qp_feq(float128 *a, float128 *b);
     64 
     65 int _Qp_feq(float128 *a, float128 *b)
     66 {
     67 	return float128_eq(*a, *b);
     68 }
     69 
     70 
     71 int _Qp_fge(float128 *a, float128 *b);
     72 
     73 int _Qp_fge(float128 *a, float128 *b)
     74 {
     75 	return float128_le(*b, *a);
     76 }
     77 
     78 
     79 int _Qp_fgt(float128 *a, float128 *b);
     80 
     81 int _Qp_fgt(float128 *a, float128 *b)
     82 {
     83 	return float128_lt(*b, *a);
     84 }
     85 
     86 
     87 int _Qp_fle(float128 *a, float128 *b);
     88 
     89 int _Qp_fle(float128 *a, float128 *b)
     90 {
     91 	return float128_le(*a, *b);
     92 }
     93 
     94 
     95 int _Qp_flt(float128 *a, float128 *b);
     96 
     97 int _Qp_flt(float128 *a, float128 *b)
     98 {
     99 	return float128_lt(*a, *b);
    100 }
    101 
    102 
    103 int _Qp_fne(float128 *a, float128 *b);
    104 
    105 int _Qp_fne(float128 *a, float128 *b)
    106 {
    107 	return !float128_eq(*a, *b);
    108 }
    109 
    110 
    111 void _Qp_itoq(float128 *c, int a);
    112 
    113 void _Qp_itoq(float128 *c, int a)
    114 {
    115 	*c = int32_to_float128(a);
    116 }
    117 
    118 
    119 
    120 void _Qp_mul(float128 *c, float128 *a, float128 *b);
    121 
    122 void _Qp_mul(float128 *c, float128 *a, float128 *b)
    123 {
    124 	*c = float128_mul(*a, *b);
    125 }
    126 
    127 
    128 /*
    129  * XXX easy way to do this, softfloat function
    130  */
    131 void _Qp_neg(float128 *c, float128 *a);
    132 
    133 static float128 __zero = {0x4034000000000000, 0x00000000};
    134 
    135 void _Qp_neg(float128 *c, float128 *a)
    136 {
    137 	*c = float128_sub(__zero, *a);
    138 }
    139 
    140 
    141 
    142 double _Qp_qtod(float128 *a);
    143 
    144 double _Qp_qtod(float128 *a)
    145 {
    146 	float64 _c;
    147 	double c;
    148 
    149 	_c = float128_to_float64(*a);
    150 
    151 	memcpy(&c, &_c, sizeof(double));
    152 
    153 	return c;
    154 }
    155 
    156 
    157 int _Qp_qtoi(float128 *a);
    158 
    159 int _Qp_qtoi(float128 *a)
    160 {
    161 	return float128_to_int32(*a);
    162 }
    163 
    164 
    165 float _Qp_qtos(float128 *a);
    166 
    167 float _Qp_qtos(float128 *a)
    168 {
    169 	float c;
    170 	float32 _c;
    171 
    172 	_c = float128_to_float32(*a);
    173 
    174 	memcpy(&c, &_c, sizeof(_c));
    175 
    176 	return c;
    177 }
    178 
    179 
    180 unsigned int _Qp_qtoui(float128 *a);
    181 
    182 unsigned int _Qp_qtoui(float128 *a)
    183 {
    184 	return (unsigned int)float128_to_int32(*a);
    185 }
    186 
    187 
    188 
    189 unsigned long _Qp_qtoux(float128 *a);
    190 
    191 unsigned long _Qp_qtoux(float128 *a)
    192 {
    193 	return (unsigned long)float128_to_int64(*a);
    194 }
    195 
    196 
    197 
    198 long _Qp_qtox(float128 *a);
    199 
    200 long _Qp_qtox(float128 *a)
    201 {
    202 	return (long)float128_to_int64(*a);
    203 }
    204 
    205 
    206 void _Qp_sqrt(float128 *c, float128 *a);
    207 
    208 void _Qp_sqrt(float128 *c, float128 *a)
    209 {
    210 	*c = float128_sqrt(*a);
    211 }
    212 
    213 
    214 void _Qp_stoq(float128 *c, float a);
    215 
    216 void _Qp_stoq(float128 *c, float a)
    217 {
    218 	float32 _a;
    219 
    220 	memcpy(&_a, &a, sizeof(a));
    221 
    222 	*c = float32_to_float128(_a);
    223 }
    224 
    225 
    226 void _Qp_sub(float128 *c, float128 *a, float128 *b);
    227 
    228 void _Qp_sub(float128 *c, float128 *a, float128 *b)
    229 {
    230 	*c = float128_sub(*a, *b);
    231 }
    232 
    233 
    234 void _Qp_uitoq(float128 *c, unsigned int a);
    235 
    236 void _Qp_uitoq(float128 *c, unsigned int a)
    237 {
    238 	*c = int32_to_float128(a);
    239 }
    240 
    241 
    242 void _Qp_uxtoq(float128 *c, unsigned long a);
    243 
    244 void _Qp_uxtoq(float128 *c, unsigned long a)
    245 {
    246 	*c = int64_to_float128(a);
    247 }
    248 
    249 
    250 void _Qp_xtoq(float128 *c, long a);
    251 
    252 void _Qp_xtoq(float128 *c, long a)
    253 {
    254 	*c = int64_to_float128(a);
    255 }
    256