Changeset a35b458 in mainline for uspace/lib/softfloat/mul.c


Ignore:
Timestamp:
2018-03-02T20:10:49Z (7 years ago)
Author:
Jiří Zárevúcky <zarevucky.jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
f1380b7
Parents:
3061bc1
git-author:
Jiří Zárevúcky <zarevucky.jiri@…> (2018-02-28 17:38:31)
git-committer:
Jiří Zárevúcky <zarevucky.jiri@…> (2018-03-02 20:10:49)
Message:

style: Remove trailing whitespace on _all_ lines, including empty ones, for particular file types.

Command used: tools/srepl '\s\+$' '' -- *.c *.h *.py *.sh *.s *.S *.ag

Currently, whitespace on empty lines is very inconsistent.
There are two basic choices: Either remove the whitespace, or keep empty lines
indented to the level of surrounding code. The former is AFAICT more common,
and also much easier to do automatically.

Alternatively, we could write script for automatic indentation, and use that
instead. However, if such a script exists, it's possible to use the indented
style locally, by having the editor apply relevant conversions on load/save,
without affecting remote repository. IMO, it makes more sense to adopt
the simpler rule.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/softfloat/mul.c

    r3061bc1 ra35b458  
    5151        uint64_t frac1, frac2;
    5252        int32_t exp;
    53        
     53
    5454        result.parts.sign = a.parts.sign ^ b.parts.sign;
    55        
     55
    5656        if (is_float32_nan(a) || is_float32_nan(b)) {
    5757                /* TODO: fix SigNaNs */
     
    6161                        return result;
    6262                }
    63                
     63
    6464                if (is_float32_signan(b)) { /* TODO: fix SigNaN */
    6565                        result.parts.fraction = b.parts.fraction;
     
    6767                        return result;
    6868                }
    69                
     69
    7070                /* set NaN as result */
    7171                result.bin = FLOAT32_NAN;
    7272                return result;
    7373        }
    74        
     74
    7575        if (is_float32_infinity(a)) {
    7676                if (is_float32_zero(b)) {
     
    7979                        return result;
    8080                }
    81                
     81
    8282                result.parts.fraction = a.parts.fraction;
    8383                result.parts.exp = a.parts.exp;
    8484                return result;
    8585        }
    86        
     86
    8787        if (is_float32_infinity(b)) {
    8888                if (is_float32_zero(a)) {
     
    9191                        return result;
    9292                }
    93                
     93
    9494                result.parts.fraction = b.parts.fraction;
    9595                result.parts.exp = b.parts.exp;
    9696                return result;
    9797        }
    98        
     98
    9999        /* exp is signed so we can easy detect underflow */
    100100        exp = a.parts.exp + b.parts.exp;
    101101        exp -= FLOAT32_BIAS;
    102        
     102
    103103        if (exp >= FLOAT32_MAX_EXPONENT) {
    104104                /* FIXME: overflow */
     
    108108                return result;
    109109        }
    110        
     110
    111111        if (exp < 0) {
    112112                /* FIXME: underflow */
     
    116116                return result;
    117117        }
    118        
     118
    119119        frac1 = a.parts.fraction;
    120120        if (a.parts.exp > 0) {
     
    123123                ++exp;
    124124        }
    125        
     125
    126126        frac2 = b.parts.fraction;
    127        
     127
    128128        if (b.parts.exp > 0) {
    129129                frac2 |= FLOAT32_HIDDEN_BIT_MASK;
     
    131131                ++exp;
    132132        }
    133        
     133
    134134        frac1 <<= 1; /* one bit space for rounding */
    135        
     135
    136136        frac1 = frac1 * frac2;
    137        
     137
    138138        /* round and return */
    139139        while ((exp < FLOAT32_MAX_EXPONENT) &&
     
    143143                frac1 >>= 1;
    144144        }
    145        
     145
    146146        /* rounding */
    147147        /* ++frac1; FIXME: not works - without it is ok */
    148148        frac1 >>= 1; /* shift off rounding space */
    149        
     149
    150150        if ((exp < FLOAT32_MAX_EXPONENT) &&
    151151            (frac1 >= (1 << (FLOAT32_FRACTION_SIZE + 1)))) {
     
    153153                frac1 >>= 1;
    154154        }
    155        
     155
    156156        if (exp >= FLOAT32_MAX_EXPONENT) {
    157157                /* TODO: fix overflow */
     
    161161                return result;
    162162        }
    163        
     163
    164164        exp -= FLOAT32_FRACTION_SIZE;
    165        
     165
    166166        if (exp <= FLOAT32_FRACTION_SIZE) {
    167167                /* denormalized number */
    168168                frac1 >>= 1; /* denormalize */
    169                
     169
    170170                while ((frac1 > 0) && (exp < 0)) {
    171171                        frac1 >>= 1;
    172172                        ++exp;
    173173                }
    174                
     174
    175175                if (frac1 == 0) {
    176176                        /* FIXME : underflow */
     
    180180                }
    181181        }
    182        
     182
    183183        result.parts.exp = exp;
    184184        result.parts.fraction = frac1 & ((1 << FLOAT32_FRACTION_SIZE) - 1);
    185        
     185
    186186        return result;
    187187}
     
    200200        uint64_t frac1, frac2;
    201201        int32_t exp;
    202        
     202
    203203        result.parts.sign = a.parts.sign ^ b.parts.sign;
    204        
     204
    205205        if (is_float64_nan(a) || is_float64_nan(b)) {
    206206                /* TODO: fix SigNaNs */
     
    219219                return result;
    220220        }
    221        
     221
    222222        if (is_float64_infinity(a)) {
    223223                if (is_float64_zero(b)) {
     
    230230                return result;
    231231        }
    232        
     232
    233233        if (is_float64_infinity(b)) {
    234234                if (is_float64_zero(a)) {
     
    241241                return result;
    242242        }
    243        
     243
    244244        /* exp is signed so we can easy detect underflow */
    245245        exp = a.parts.exp + b.parts.exp - FLOAT64_BIAS;
    246        
     246
    247247        frac1 = a.parts.fraction;
    248        
     248
    249249        if (a.parts.exp > 0) {
    250250                frac1 |= FLOAT64_HIDDEN_BIT_MASK;
     
    252252                ++exp;
    253253        }
    254        
     254
    255255        frac2 = b.parts.fraction;
    256        
     256
    257257        if (b.parts.exp > 0) {
    258258                frac2 |= FLOAT64_HIDDEN_BIT_MASK;
     
    260260                ++exp;
    261261        }
    262        
     262
    263263        frac1 <<= (64 - FLOAT64_FRACTION_SIZE - 1);
    264264        frac2 <<= (64 - FLOAT64_FRACTION_SIZE - 2);
    265        
     265
    266266        mul64(frac1, frac2, &frac1, &frac2);
    267        
     267
    268268        frac1 |= (frac2 != 0);
    269269        if (frac1 & (0x1ll << 62)) {
     
    271271                exp--;
    272272        }
    273        
     273
    274274        result = finish_float64(exp, frac1, result.parts.sign);
    275275        return result;
     
    289289        uint64_t frac1_hi, frac1_lo, frac2_hi, frac2_lo, tmp_hi, tmp_lo;
    290290        int32_t exp;
    291        
     291
    292292        result.parts.sign = a.parts.sign ^ b.parts.sign;
    293        
     293
    294294        if (is_float128_nan(a) || is_float128_nan(b)) {
    295295                /* TODO: fix SigNaNs */
     
    311311                return result;
    312312        }
    313        
     313
    314314        if (is_float128_infinity(a)) {
    315315                if (is_float128_zero(b)) {
     
    324324                return result;
    325325        }
    326        
     326
    327327        if (is_float128_infinity(b)) {
    328328                if (is_float128_zero(a)) {
     
    337337                return result;
    338338        }
    339        
     339
    340340        /* exp is signed so we can easy detect underflow */
    341341        exp = a.parts.exp + b.parts.exp - FLOAT128_BIAS - 1;
    342        
     342
    343343        frac1_hi = a.parts.frac_hi;
    344344        frac1_lo = a.parts.frac_lo;
    345        
     345
    346346        if (a.parts.exp > 0) {
    347347                or128(frac1_hi, frac1_lo,
     
    351351                ++exp;
    352352        }
    353        
     353
    354354        frac2_hi = b.parts.frac_hi;
    355355        frac2_lo = b.parts.frac_lo;
    356        
     356
    357357        if (b.parts.exp > 0) {
    358358                or128(frac2_hi, frac2_lo,
     
    362362                ++exp;
    363363        }
    364        
     364
    365365        lshift128(frac2_hi, frac2_lo,
    366366            128 - FLOAT128_FRACTION_SIZE, &frac2_hi, &frac2_lo);
    367        
     367
    368368        tmp_hi = frac1_hi;
    369369        tmp_lo = frac1_lo;
     
    372372        add128(frac1_hi, frac1_lo, tmp_hi, tmp_lo, &frac1_hi, &frac1_lo);
    373373        frac2_hi |= (frac2_lo != 0x0ll);
    374        
     374
    375375        if ((FLOAT128_HIDDEN_BIT_MASK_HI << 1) <= frac1_hi) {
    376376                frac2_hi >>= 1;
     
    381381                ++exp;
    382382        }
    383        
     383
    384384        result = finish_float128(exp, frac1_hi, frac1_lo, result.parts.sign, frac2_hi);
    385385        return result;
     
    392392        float32_u ua;
    393393        ua.val = a;
    394        
     394
    395395        float32_u ub;
    396396        ub.val = b;
    397        
     397
    398398        float32_u res;
    399399        res.data = mul_float32(ua.data, ub.data);
    400        
     400
    401401        return res.val;
    402402}
     
    406406        float32_u ua;
    407407        ua.val = a;
    408        
     408
    409409        float32_u ub;
    410410        ub.val = b;
    411        
     411
    412412        float32_u res;
    413413        res.data = mul_float32(ua.data, ub.data);
    414        
     414
    415415        return res.val;
    416416}
     
    424424        float64_u ua;
    425425        ua.val = a;
    426        
     426
    427427        float64_u ub;
    428428        ub.val = b;
    429        
     429
    430430        float64_u res;
    431431        res.data = mul_float64(ua.data, ub.data);
    432        
     432
    433433        return res.val;
    434434}
     
    438438        float64_u ua;
    439439        ua.val = a;
    440        
     440
    441441        float64_u ub;
    442442        ub.val = b;
    443        
     443
    444444        float64_u res;
    445445        res.data = mul_float64(ua.data, ub.data);
    446        
     446
    447447        return res.val;
    448448}
     
    456456        float128_u ua;
    457457        ua.val = a;
    458        
     458
    459459        float128_u ub;
    460460        ub.val = b;
    461        
     461
    462462        float128_u res;
    463463        res.data = mul_float128(ua.data, ub.data);
    464        
     464
    465465        return res.val;
    466466}
Note: See TracChangeset for help on using the changeset viewer.