Changeset aa59fa0 in mainline for softfloat/generic


Ignore:
Timestamp:
2006-03-16T00:32:41Z (20 years ago)
Author:
Josef Cejka <malyzelenyhnus@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
585819d
Parents:
69cdeec
Message:

SoftFloat integrated into HelenOS uspace.

Location:
softfloat/generic
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • softfloat/generic/add.c

    r69cdeec raa59fa0  
    3636{
    3737        int expdiff;
    38         __u32 exp1, exp2,frac1, frac2;
     38        uint32_t exp1, exp2,frac1, frac2;
    3939       
    4040        expdiff = a.parts.exp - b.parts.exp;
     
    144144{
    145145        int expdiff;
    146         __u32 exp1, exp2;
    147         __u64 frac1, frac2;
     146        uint32_t exp1, exp2;
     147        uint64_t frac1, frac2;
    148148       
    149149        expdiff = ((int )a.parts.exp) - b.parts.exp;
  • softfloat/generic/common.c

    r69cdeec raa59fa0  
    5757 * @return valied float64
    5858 */
    59 float64 finishFloat64(__s32 cexp, __u64 cfrac, char sign)
     59float64 finishFloat64(int32_t cexp, uint64_t cfrac, char sign)
    6060{
    6161        float64 result;
     
    109109        }
    110110
    111         result.parts.exp = (__u32)cexp;
     111        result.parts.exp = (uint32_t)cexp;
    112112       
    113113        result.parts.fraction = ((cfrac >>(64 - FLOAT64_FRACTION_SIZE - 2 ) ) & (~FLOAT64_HIDDEN_BIT_MASK));
     
    119119 * @param i
    120120 */
    121 int countZeroes64(__u64 i)
     121int countZeroes64(uint64_t i)
    122122{
    123123        int j;
     
    134134 * @param i
    135135 */
    136 int countZeroes32(__u32 i)
     136int countZeroes32(uint32_t i)
    137137{
    138138        int j;
     
    149149 * @param i
    150150 */
    151 int countZeroes8(__u8 i)
     151int countZeroes8(uint8_t i)
    152152{
    153153        return zeroTable[i];
     
    158158 * @param fraction part with hidden bit shifted to 30. bit
    159159 */
    160 void roundFloat32(__s32 *exp, __u32 *fraction)
     160void roundFloat32(int32_t *exp, uint32_t *fraction)
    161161{
    162162        /* rounding - if first bit after fraction is set then round up */
     
    183183 * @param fraction part with hidden bit shifted to 62. bit
    184184 */
    185 void roundFloat64(__s32 *exp, __u64 *fraction)
     185void roundFloat64(int32_t *exp, uint64_t *fraction)
    186186{
    187187        /* rounding - if first bit after fraction is set then round up */
  • softfloat/generic/conversion.c

    r69cdeec raa59fa0  
    3535{
    3636        float64 result;
    37         __u64 frac;
     37        uint64_t frac;
    3838       
    3939        result.parts.sign = a.parts.sign;
     
    7474{
    7575        float32 result;
    76         __s32 exp;
    77         __u64 frac;
     76        int32_t exp;
     77        uint64_t frac;
    7878       
    7979        result.parts.sign = a.parts.sign;
     
    8484               
    8585                if (isFloat64SigNaN(a)) {
    86                         result.parts.fraction = 0x800000; /* set first bit of fraction nonzero */
     86                        result.parts.fraction = 0x400000; /* set first bit of fraction nonzero */
    8787                        return result;
    8888                }
     
    145145 * @return unsigned integer
    146146 */
    147 static __u32 _float32_to_uint32_helper(float32 a)
    148 {
    149         __u32 frac;
     147static uint32_t _float32_to_uint32_helper(float32 a)
     148{
     149        uint32_t frac;
    150150       
    151151        if (a.parts.exp < FLOAT32_BIAS) {
     
    173173 *      - now its the biggest or the smallest int
    174174 */
    175 __u32 float32_to_uint32(float32 a)
     175uint32_t float32_to_uint32(float32 a)
    176176{
    177177        if (isFloat32NaN(a)) {
     
    193193 *      - now its the biggest or the smallest int
    194194 */
    195 __s32 float32_to_int32(float32 a)
     195int32_t float32_to_int32(float32 a)
    196196{
    197197        if (isFloat32NaN(a)) {
     
    213213 * @return unsigned integer
    214214 */
    215 static __u64 _float64_to_uint64_helper(float64 a)
    216 {
    217         __u64 frac;
     215static uint64_t _float64_to_uint64_helper(float64 a)
     216{
     217        uint64_t frac;
    218218       
    219219        if (a.parts.exp < FLOAT64_BIAS) {
     
    241241 *      - now its the biggest or the smallest int
    242242 */
    243 __u64 float64_to_uint64(float64 a)
     243uint64_t float64_to_uint64(float64 a)
    244244{
    245245        if (isFloat64NaN(a)) {
     
    261261 *      - now its the biggest or the smallest int
    262262 */
    263 __s64 float64_to_int64(float64 a)
     263int64_t float64_to_int64(float64 a)
    264264{
    265265        if (isFloat64NaN(a)) {
     
    284284 * @return unsigned integer
    285285 */
    286 static __u64 _float32_to_uint64_helper(float32 a)
    287 {
    288         __u64 frac;
     286static uint64_t _float32_to_uint64_helper(float32 a)
     287{
     288        uint64_t frac;
    289289       
    290290        if (a.parts.exp < FLOAT32_BIAS) {
     
    312312 *      - now its the biggest or the smallest int
    313313 */
    314 __u64 float32_to_uint64(float32 a)
     314uint64_t float32_to_uint64(float32 a)
    315315{
    316316        if (isFloat32NaN(a)) {
     
    332332 *      - now its the biggest or the smallest int
    333333 */
    334 __s64 float32_to_int64(float32 a)
     334int64_t float32_to_int64(float32 a)
    335335{
    336336        if (isFloat32NaN(a)) {
     
    352352 *      - now its the biggest or the smallest int
    353353 */
    354 __u32 float64_to_uint32(float64 a)
     354uint32_t float64_to_uint32(float64 a)
    355355{
    356356        if (isFloat64NaN(a)) {
     
    365365        }
    366366       
    367         return (__u32)_float64_to_uint64_helper(a);     
     367        return (uint32_t)_float64_to_uint64_helper(a); 
    368368}
    369369
     
    372372 *      - now its the biggest or the smallest int
    373373 */
    374 __s32 float64_to_int32(float64 a)
     374int32_t float64_to_int32(float64 a)
    375375{
    376376        if (isFloat64NaN(a)) {
     
    384384                return MAX_INT32;
    385385        }
    386         return (__s32)_float64_to_uint64_helper(a);
     386        return (int32_t)_float64_to_uint64_helper(a);
    387387}       
    388388
     
    391391 *
    392392 */
    393 float32 uint32_to_float32(__u32 i)
     393float32 uint32_to_float32(uint32_t i)
    394394{
    395395        int counter;
    396         __s32 exp;
     396        int32_t exp;
    397397        float32 result;
    398398       
     
    423423}
    424424
    425 float32 int32_to_float32(__s32 i)
     425float32 int32_to_float32(int32_t i)
    426426{
    427427        float32 result;
    428428
    429429        if (i < 0) {
    430                 result = uint32_to_float32((__u32)(-i));
    431         } else {
    432                 result = uint32_to_float32((__u32)i);
     430                result = uint32_to_float32((uint32_t)(-i));
     431        } else {
     432                result = uint32_to_float32((uint32_t)i);
    433433        }
    434434       
     
    439439
    440440
    441 float32 uint64_to_float32(__u64 i)
     441float32 uint64_to_float32(uint64_t i)
    442442{
    443443        int counter;
    444         __s32 exp;
     444        int32_t exp;
     445        int32_t j;
    445446        float32 result;
    446447       
     
    463464                i >>= 1 + 32 - counter;
    464465        }
    465 
    466         roundFloat32(&exp, &i);
    467 
    468         result.parts.fraction = i >> 7;
     466       
     467        j = (uint32_t)i;
     468        roundFloat32(&exp, &j);
     469
     470        result.parts.fraction = j >> 7;
    469471        result.parts.exp = exp;
    470472        return result;
    471473}
    472474
    473 float32 int64_to_float32(__s64 i)
     475float32 int64_to_float32(int64_t i)
    474476{
    475477        float32 result;
    476478
    477479        if (i < 0) {
    478                 result = uint64_to_float32((__u64)(-i));
    479         } else {
    480                 result = uint64_to_float32((__u64)i);
     480                result = uint64_to_float32((uint64_t)(-i));
     481        } else {
     482                result = uint64_to_float32((uint64_t)i);
    481483        }
    482484       
     
    490492 *
    491493 */
    492 float64 uint32_to_float64(__u32 i)
     494float64 uint32_to_float64(uint32_t i)
    493495{
    494496        int counter;
    495         __s32 exp;
     497        int32_t exp;
    496498        float64 result;
    497         __u64 frac;
     499        uint64_t frac;
    498500       
    499501        result.parts.sign = 0;
     
    520522}
    521523
    522 float64 int32_to_float64(__s32 i)
     524float64 int32_to_float64(int32_t i)
    523525{
    524526        float64 result;
    525527
    526528        if (i < 0) {
    527                 result = uint32_to_float64((__u32)(-i));
    528         } else {
    529                 result = uint32_to_float64((__u32)i);
     529                result = uint32_to_float64((uint32_t)(-i));
     530        } else {
     531                result = uint32_to_float64((uint32_t)i);
    530532        }
    531533       
     
    536538
    537539
    538 float64 uint64_to_float64(__u64 i)
     540float64 uint64_to_float64(uint64_t i)
    539541{
    540542        int counter;
    541         __s32 exp;
     543        int32_t exp;
    542544        float64 result;
    543545       
     
    567569}
    568570
    569 float64 int64_to_float64(__s64 i)
     571float64 int64_to_float64(int64_t i)
    570572{
    571573        float64 result;
    572574
    573575        if (i < 0) {
    574                 result = uint64_to_float64((__u64)(-i));
    575         } else {
    576                 result = uint64_to_float64((__u64)i);
     576                result = uint64_to_float64((uint64_t)(-i));
     577        } else {
     578                result = uint64_to_float64((uint64_t)i);
    577579        }
    578580       
  • softfloat/generic/div.c

    r69cdeec raa59fa0  
    3838{
    3939        float32 result;
    40         __s32 aexp, bexp, cexp;
    41         __u64 afrac, bfrac, cfrac;
     40        int32_t aexp, bexp, cexp;
     41        uint64_t afrac, bfrac, cfrac;
    4242       
    4343        result.parts.sign = a.parts.sign ^ b.parts.sign;
     
    181181               
    182182        } else {
    183                 result.parts.exp = (__u32)cexp;
     183                result.parts.exp = (uint32_t)cexp;
    184184        }
    185185       
     
    192192{
    193193        float64 result;
    194         __s64 aexp, bexp, cexp;
    195         __u64 afrac, bfrac, cfrac;
    196         __u64 remlo, remhi;
     194        int64_t aexp, bexp, cexp;
     195        uint64_t afrac, bfrac, cfrac;
     196        uint64_t remlo, remhi;
    197197       
    198198        result.parts.sign = a.parts.sign ^ b.parts.sign;
     
    307307                remlo = - remlo;
    308308               
    309                 while ((__s64) remhi < 0) {
     309                while ((int64_t) remhi < 0) {
    310310                        cfrac--;
    311311                        remlo += bfrac;
     
    321321}
    322322
    323 __u64 divFloat64estim(__u64 a, __u64 b)
     323uint64_t divFloat64estim(uint64_t a, uint64_t b)
    324324{
    325         __u64 bhi;
    326         __u64 remhi, remlo;
    327         __u64 result;
     325        uint64_t bhi;
     326        uint64_t remhi, remlo;
     327        uint64_t result;
    328328       
    329329        if ( b <= a ) {
     
    339339
    340340        b <<= 32;
    341         while ( (__s64) remhi < 0 ) {
     341        while ( (int64_t) remhi < 0 ) {
    342342                        result -= 0x1ll << 32; 
    343343                        remlo += b;
  • softfloat/generic/mul.c

    r69cdeec raa59fa0  
    3838{
    3939        float32 result;
    40         __u64 frac1, frac2;
    41         __s32 exp;
     40        uint64_t frac1, frac2;
     41        int32_t exp;
    4242
    4343        result.parts.sign = a.parts.sign ^ b.parts.sign;
     
    174174{
    175175        float64 result;
    176         __u64 frac1, frac2;
    177         __s32 exp;
     176        uint64_t frac1, frac2;
     177        int32_t exp;
    178178
    179179        result.parts.sign = a.parts.sign ^ b.parts.sign;
     
    258258 * @param hi higher part of result
    259259 */
    260 void mul64integers(__u64 a,__u64 b, __u64 *lo, __u64 *hi)
     260void mul64integers(uint64_t a,uint64_t b, uint64_t *lo, uint64_t *hi)
    261261{
    262         __u64 low, high, middle1, middle2;
    263         __u32 alow, blow;
     262        uint64_t low, high, middle1, middle2;
     263        uint32_t alow, blow;
    264264
    265265        alow = a & 0xFFFFFFFF;
     
    269269        b >>= 32;
    270270       
    271         low = ((__u64)alow) * blow;
     271        low = ((uint64_t)alow) * blow;
    272272        middle1 = a * blow;
    273273        middle2 = alow * b;
     
    275275
    276276        middle1 += middle2;
    277         high += (((__u64)(middle1 < middle2)) << 32) + (middle1 >> 32);
     277        high += (((uint64_t)(middle1 < middle2)) << 32) + (middle1 >> 32);
    278278        middle1 <<= 32;
    279279        low += middle1;
  • softfloat/generic/softfloat.c

    r69cdeec raa59fa0  
    3939#include<other.h>
    4040
    41 #include<arch.h>
    42 #include<types.h>
    4341#include<functions.h>
    4442
     
    485483}
    486484
    487 float __mulsc3(float a, float b, float c, float d)
    488 {
    489 /* TODO: */
    490 }
    491 
    492 float __divsc3(float a, float b, float c, float d)
    493 {
    494 /* TODO: */
    495 }
    496 
  • softfloat/generic/sub.c

    r69cdeec raa59fa0  
    3636{
    3737        int expdiff;
    38         __u32 exp1, exp2, frac1, frac2;
     38        uint32_t exp1, exp2, frac1, frac2;
    3939        float32 result;
    4040
     
    147147{
    148148        int expdiff;
    149         __u32 exp1, exp2;
    150         __u64 frac1, frac2;
     149        uint32_t exp1, exp2;
     150        uint64_t frac1, frac2;
    151151        float64 result;
    152152
Note: See TracChangeset for help on using the changeset viewer.