Changeset aa59fa0 in mainline for softfloat/generic/conversion.c


Ignore:
Timestamp:
2006-03-16T00:32:41Z (19 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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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       
Note: See TracChangeset for help on using the changeset viewer.