Changeset a35b458 in mainline for uspace/lib/softfloat/div.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/div.c

    r3061bc1 ra35b458  
    5353        int32_t aexp, bexp, cexp;
    5454        uint64_t afrac, bfrac, cfrac;
    55        
     55
    5656        result.parts.sign = a.parts.sign ^ b.parts.sign;
    57        
     57
    5858        if (is_float32_nan(a)) {
    5959                if (is_float32_signan(a)) {
     
    6363                return a;
    6464        }
    65        
     65
    6666        if (is_float32_nan(b)) {
    6767                if (is_float32_signan(b)) {
     
    7171                return b;
    7272        }
    73        
     73
    7474        if (is_float32_infinity(a)) {
    7575                if (is_float32_infinity(b)) {
     
    8383                return result;
    8484        }
    85        
     85
    8686        if (is_float32_infinity(b)) {
    8787                if (is_float32_zero(a)) {
     
    9696                return result;
    9797        }
    98        
     98
    9999        if (is_float32_zero(b)) {
    100100                if (is_float32_zero(a)) {
     
    108108                return result;
    109109        }
    110        
     110
    111111        afrac = a.parts.fraction;
    112112        aexp = a.parts.exp;
    113113        bfrac = b.parts.fraction;
    114114        bexp = b.parts.exp;
    115        
     115
    116116        /* denormalized numbers */
    117117        if (aexp == 0) {
     
    121121                        return result;
    122122                }
    123                
     123
    124124                /* normalize it*/
    125125                afrac <<= 1;
     
    130130                }
    131131        }
    132        
     132
    133133        if (bexp == 0) {
    134134                bfrac <<= 1;
     
    139139                }
    140140        }
    141        
     141
    142142        afrac = (afrac | FLOAT32_HIDDEN_BIT_MASK) << (32 - FLOAT32_FRACTION_SIZE - 1);
    143143        bfrac = (bfrac | FLOAT32_HIDDEN_BIT_MASK) << (32 - FLOAT32_FRACTION_SIZE);
    144        
     144
    145145        if (bfrac <= (afrac << 1)) {
    146146                afrac >>= 1;
    147147                aexp++;
    148148        }
    149        
     149
    150150        cexp = aexp - bexp + FLOAT32_BIAS - 2;
    151        
     151
    152152        cfrac = (afrac << 32) / bfrac;
    153153        if ((cfrac & 0x3F) == 0) {
    154154                cfrac |= (bfrac * cfrac != afrac << 32);
    155155        }
    156        
     156
    157157        /* pack and round */
    158        
     158
    159159        /* find first nonzero digit and shift result and detect possibly underflow */
    160160        while ((cexp > 0) && (cfrac) && (!(cfrac & (FLOAT32_HIDDEN_BIT_MASK << 7)))) {
     
    163163                /* TODO: fix underflow */
    164164        }
    165        
     165
    166166        cfrac += (0x1 << 6); /* FIXME: 7 is not sure*/
    167        
     167
    168168        if (cfrac & (FLOAT32_HIDDEN_BIT_MASK << 7)) {
    169169                ++cexp;
    170170                cfrac >>= 1;
    171171        }
    172        
     172
    173173        /* check overflow */
    174174        if (cexp >= FLOAT32_MAX_EXPONENT) {
     
    178178                return result;
    179179        }
    180        
     180
    181181        if (cexp < 0) {
    182182                /* FIXME: underflow */
     
    194194                result.parts.exp = (uint32_t) cexp;
    195195        }
    196        
     196
    197197        result.parts.fraction = ((cfrac >> 6) & (~FLOAT32_HIDDEN_BIT_MASK));
    198        
     198
    199199        return result;
    200200}
     
    215215        uint64_t remlo, remhi;
    216216        uint64_t tmplo, tmphi;
    217        
     217
    218218        result.parts.sign = a.parts.sign ^ b.parts.sign;
    219        
     219
    220220        if (is_float64_nan(a)) {
    221221                if (is_float64_signan(b)) {
     
    223223                        return b;
    224224                }
    225                
     225
    226226                if (is_float64_signan(a)) {
    227227                        // FIXME: SigNaN
     
    230230                return a;
    231231        }
    232        
     232
    233233        if (is_float64_nan(b)) {
    234234                if (is_float64_signan(b)) {
     
    238238                return b;
    239239        }
    240        
     240
    241241        if (is_float64_infinity(a)) {
    242242                if (is_float64_infinity(b) || is_float64_zero(b)) {
     
    250250                return result;
    251251        }
    252        
     252
    253253        if (is_float64_infinity(b)) {
    254254                if (is_float64_zero(a)) {
     
    263263                return result;
    264264        }
    265        
     265
    266266        if (is_float64_zero(b)) {
    267267                if (is_float64_zero(a)) {
     
    275275                return result;
    276276        }
    277        
     277
    278278        afrac = a.parts.fraction;
    279279        aexp = a.parts.exp;
    280280        bfrac = b.parts.fraction;
    281281        bexp = b.parts.exp;
    282        
     282
    283283        /* denormalized numbers */
    284284        if (aexp == 0) {
     
    288288                        return result;
    289289                }
    290                
     290
    291291                /* normalize it*/
    292292                aexp++;
     
    297297                }
    298298        }
    299        
     299
    300300        if (bexp == 0) {
    301301                bexp++;
     
    306306                }
    307307        }
    308        
     308
    309309        afrac = (afrac | FLOAT64_HIDDEN_BIT_MASK) << (64 - FLOAT64_FRACTION_SIZE - 2);
    310310        bfrac = (bfrac | FLOAT64_HIDDEN_BIT_MASK) << (64 - FLOAT64_FRACTION_SIZE - 1);
    311        
     311
    312312        if (bfrac <= (afrac << 1)) {
    313313                afrac >>= 1;
    314314                aexp++;
    315315        }
    316        
     316
    317317        cexp = aexp - bexp + FLOAT64_BIAS - 2;
    318        
     318
    319319        cfrac = div128est(afrac, 0x0ll, bfrac);
    320        
     320
    321321        if ((cfrac & 0x1FF) <= 2) {
    322322                mul64(bfrac, cfrac, &tmphi, &tmplo);
    323323                sub128(afrac, 0x0ll, tmphi, tmplo, &remhi, &remlo);
    324                
     324
    325325                while ((int64_t) remhi < 0) {
    326326                        cfrac--;
     
    329329                cfrac |= (remlo != 0);
    330330        }
    331        
     331
    332332        /* round and shift */
    333333        result = finish_float64(cexp, cfrac, result.parts.sign);
     
    351351        uint64_t rem_hihi, rem_hilo, rem_lohi, rem_lolo;
    352352        uint64_t tmp_hihi, tmp_hilo, tmp_lohi, tmp_lolo;
    353        
     353
    354354        result.parts.sign = a.parts.sign ^ b.parts.sign;
    355        
     355
    356356        if (is_float128_nan(a)) {
    357357                if (is_float128_signan(b)) {
     
    359359                        return b;
    360360                }
    361                
     361
    362362                if (is_float128_signan(a)) {
    363363                        // FIXME: SigNaN
     
    366366                return a;
    367367        }
    368        
     368
    369369        if (is_float128_nan(b)) {
    370370                if (is_float128_signan(b)) {
     
    374374                return b;
    375375        }
    376        
     376
    377377        if (is_float128_infinity(a)) {
    378378                if (is_float128_infinity(b) || is_float128_zero(b)) {
     
    388388                return result;
    389389        }
    390        
     390
    391391        if (is_float128_infinity(b)) {
    392392                if (is_float128_zero(a)) {
     
    403403                return result;
    404404        }
    405        
     405
    406406        if (is_float128_zero(b)) {
    407407                if (is_float128_zero(a)) {
     
    417417                return result;
    418418        }
    419        
     419
    420420        afrac_hi = a.parts.frac_hi;
    421421        afrac_lo = a.parts.frac_lo;
     
    424424        bfrac_lo = b.parts.frac_lo;
    425425        bexp = b.parts.exp;
    426        
     426
    427427        /* denormalized numbers */
    428428        if (aexp == 0) {
     
    433433                        return result;
    434434                }
    435                
     435
    436436                /* normalize it*/
    437437                aexp++;
     
    445445                }
    446446        }
    447        
     447
    448448        if (bexp == 0) {
    449449                bexp++;
     
    457457                }
    458458        }
    459        
     459
    460460        or128(afrac_hi, afrac_lo,
    461461            FLOAT128_HIDDEN_BIT_MASK_HI, FLOAT128_HIDDEN_BIT_MASK_LO,
     
    468468        lshift128(bfrac_hi, bfrac_lo,
    469469            (128 - FLOAT128_FRACTION_SIZE - 1), &bfrac_hi, &bfrac_lo);
    470        
     470
    471471        if (le128(bfrac_hi, bfrac_lo, afrac_hi, afrac_lo)) {
    472472                rshift128(afrac_hi, afrac_lo, 1, &afrac_hi, &afrac_lo);
    473473                aexp++;
    474474        }
    475        
     475
    476476        cexp = aexp - bexp + FLOAT128_BIAS - 2;
    477        
     477
    478478        cfrac_hi = div128est(afrac_hi, afrac_lo, bfrac_hi);
    479        
     479
    480480        mul128(bfrac_hi, bfrac_lo, 0x0ll, cfrac_hi,
    481481            &tmp_lolo /* dummy */, &tmp_hihi, &tmp_hilo, &tmp_lohi);
    482        
     482
    483483        /* sub192(afrac_hi, afrac_lo, 0,
    484484         *     tmp_hihi, tmp_hilo, tmp_lohi
     
    489489        }
    490490        rem_lohi = -tmp_lohi;
    491        
     491
    492492        while ((int64_t) rem_hihi < 0) {
    493493                --cfrac_hi;
     
    500500                }
    501501        }
    502        
     502
    503503        cfrac_lo = div128est(rem_hilo, rem_lohi, bfrac_lo);
    504        
     504
    505505        if ((cfrac_lo & 0x3FFF) <= 4) {
    506506                mul128(bfrac_hi, bfrac_lo, 0x0ll, cfrac_lo,
    507507                    &tmp_hihi /* dummy */, &tmp_hilo, &tmp_lohi, &tmp_lolo);
    508                
     508
    509509                /* sub192(rem_hilo, rem_lohi, 0,
    510510                 *     tmp_hilo, tmp_lohi, tmp_lolo,
     
    515515                }
    516516                rem_lolo = -tmp_lolo;
    517                
     517
    518518                while ((int64_t) rem_hilo < 0) {
    519519                        --cfrac_lo;
     
    526526                        }
    527527                }
    528                
     528
    529529                cfrac_lo |= ((rem_hilo | rem_lohi | rem_lolo) != 0 );
    530530        }
    531        
     531
    532532        shift_out = cfrac_lo << (64 - (128 - FLOAT128_FRACTION_SIZE - 1));
    533533        rshift128(cfrac_hi, cfrac_lo, (128 - FLOAT128_FRACTION_SIZE - 1),
    534534            &cfrac_hi, &cfrac_lo);
    535        
     535
    536536        result = finish_float128(cexp, cfrac_hi, cfrac_lo, result.parts.sign, shift_out);
    537537        return result;
     
    544544        float32_u ua;
    545545        ua.val = a;
    546        
     546
    547547        float32_u ub;
    548548        ub.val = b;
    549        
     549
    550550        float32_u res;
    551551        res.data = div_float32(ua.data, ub.data);
    552        
     552
    553553        return res.val;
    554554}
     
    558558        float32_u ua;
    559559        ua.val = a;
    560        
     560
    561561        float32_u ub;
    562562        ub.val = b;
    563        
     563
    564564        float32_u res;
    565565        res.data = div_float32(ua.data, ub.data);
    566        
     566
    567567        return res.val;
    568568}
     
    576576        float64_u ua;
    577577        ua.val = a;
    578        
     578
    579579        float64_u ub;
    580580        ub.val = b;
    581        
     581
    582582        float64_u res;
    583583        res.data = div_float64(ua.data, ub.data);
    584        
     584
    585585        return res.val;
    586586}
     
    590590        float64_u ua;
    591591        ua.val = a;
    592        
     592
    593593        float64_u ub;
    594594        ub.val = b;
    595        
     595
    596596        float64_u res;
    597597        res.data = div_float64(ua.data, ub.data);
    598        
     598
    599599        return res.val;
    600600}
     
    608608        float128_u ua;
    609609        ua.val = a;
    610        
     610
    611611        float128_u ub;
    612612        ub.val = b;
    613        
     613
    614614        float128_u res;
    615615        res.data = div_float128(ua.data, ub.data);
    616        
     616
    617617        return res.val;
    618618}
Note: See TracChangeset for help on using the changeset viewer.