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


Ignore:
Timestamp:
2018-03-02T20:10:49Z (8 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/sub.c

    r3061bc1 ra35b458  
    5252        uint32_t exp1, exp2, frac1, frac2;
    5353        float32 result;
    54        
     54
    5555        result.bin = 0;
    56        
     56
    5757        expdiff = a.parts.exp - b.parts.exp;
    5858        if ((expdiff < 0 ) || ((expdiff == 0) &&
     
    6262                                // TODO: fix SigNaN
    6363                        }
    64                        
     64
    6565                        return b;
    6666                }
    67                
     67
    6868                if (b.parts.exp == FLOAT32_MAX_EXPONENT) {
    6969                        /* num -(+-inf) = -+inf */
     
    7171                        return b;
    7272                }
    73                
     73
    7474                result.parts.sign = !a.parts.sign;
    75                
     75
    7676                frac1 = b.parts.fraction;
    7777                exp1 = b.parts.exp;
     
    8484                                // TODO: fix SigNaN
    8585                        }
    86                        
     86
    8787                        return a;
    8888                }
    89                
     89
    9090                if (a.parts.exp == FLOAT32_MAX_EXPONENT) {
    9191                        if (b.parts.exp == FLOAT32_MAX_EXPONENT) {
     
    9595                                return result;
    9696                        }
    97                        
     97
    9898                        return a;
    9999                }
    100                
     100
    101101                result.parts.sign = a.parts.sign;
    102                
     102
    103103                frac1 = a.parts.fraction;
    104104                exp1 = a.parts.exp;
     
    106106                exp2 = b.parts.exp;
    107107        }
    108        
     108
    109109        if (exp1 == 0) {
    110110                /* both are denormalized */
     
    114114                        return result;
    115115                }
    116                
     116
    117117                result.parts.exp = 0;
    118118                return result;
    119119        }
    120        
     120
    121121        /* add hidden bit */
    122122        frac1 |= FLOAT32_HIDDEN_BIT_MASK;
    123        
     123
    124124        if (exp2 == 0) {
    125125                /* denormalized */
     
    129129                frac2 |= FLOAT32_HIDDEN_BIT_MASK;
    130130        }
    131        
     131
    132132        /* create some space for rounding */
    133133        frac1 <<= 6;
    134134        frac2 <<= 6;
    135        
     135
    136136        if (expdiff > FLOAT32_FRACTION_SIZE + 1)
    137137                goto done;
    138        
     138
    139139        frac1 = frac1 - (frac2 >> expdiff);
    140        
     140
    141141done:
    142142        /* TODO: find first nonzero digit and shift result and detect possibly underflow */
     
    146146                /* TODO: fix underflow - frac1 == 0 does not necessary means underflow... */
    147147        }
    148        
     148
    149149        /* rounding - if first bit after fraction is set then round up */
    150150        frac1 += 0x20;
    151        
     151
    152152        if (frac1 & (FLOAT32_HIDDEN_BIT_MASK << 7)) {
    153153                ++exp1;
    154154                frac1 >>= 1;
    155155        }
    156        
     156
    157157        /* Clear hidden bit and shift */
    158158        result.parts.fraction = ((frac1 >> 6) & (~FLOAT32_HIDDEN_BIT_MASK));
    159159        result.parts.exp = exp1;
    160        
     160
    161161        return result;
    162162}
     
    176176        uint64_t frac1, frac2;
    177177        float64 result;
    178        
     178
    179179        result.bin = 0;
    180        
     180
    181181        expdiff = a.parts.exp - b.parts.exp;
    182182        if ((expdiff < 0 ) ||
     
    186186                                // TODO: fix SigNaN
    187187                        }
    188                        
     188
    189189                        return b;
    190190                }
    191                
     191
    192192                if (b.parts.exp == FLOAT64_MAX_EXPONENT) {
    193193                        /* num -(+-inf) = -+inf */
     
    195195                        return b;
    196196                }
    197                
     197
    198198                result.parts.sign = !a.parts.sign;
    199                
     199
    200200                frac1 = b.parts.fraction;
    201201                exp1 = b.parts.exp;
     
    208208                                // TODO: fix SigNaN
    209209                        }
    210                        
     210
    211211                        return a;
    212212                }
    213                
     213
    214214                if (a.parts.exp == FLOAT64_MAX_EXPONENT) {
    215215                        if (b.parts.exp == FLOAT64_MAX_EXPONENT) {
     
    219219                                return result;
    220220                        }
    221                        
     221
    222222                        return a;
    223223                }
    224                
     224
    225225                result.parts.sign = a.parts.sign;
    226                
     226
    227227                frac1 = a.parts.fraction;
    228228                exp1 = a.parts.exp;
     
    230230                exp2 = b.parts.exp;
    231231        }
    232        
     232
    233233        if (exp1 == 0) {
    234234                /* both are denormalized */
     
    238238                        return result;
    239239                }
    240                
     240
    241241                result.parts.exp = 0;
    242242                return result;
    243243        }
    244        
     244
    245245        /* add hidden bit */
    246246        frac1 |= FLOAT64_HIDDEN_BIT_MASK;
    247        
     247
    248248        if (exp2 == 0) {
    249249                /* denormalized */
     
    253253                frac2 |= FLOAT64_HIDDEN_BIT_MASK;
    254254        }
    255        
     255
    256256        /* create some space for rounding */
    257257        frac1 <<= 6;
    258258        frac2 <<= 6;
    259        
     259
    260260        if (expdiff > FLOAT64_FRACTION_SIZE + 1)
    261261                goto done;
    262        
     262
    263263        frac1 = frac1 - (frac2 >> expdiff);
    264        
     264
    265265done:
    266266        /* TODO: find first nonzero digit and shift result and detect possibly underflow */
     
    270270                /* TODO: fix underflow - frac1 == 0 does not necessary means underflow... */
    271271        }
    272        
     272
    273273        /* rounding - if first bit after fraction is set then round up */
    274274        frac1 += 0x20;
    275        
     275
    276276        if (frac1 & (FLOAT64_HIDDEN_BIT_MASK << 7)) {
    277277                ++exp1;
    278278                frac1 >>= 1;
    279279        }
    280        
     280
    281281        /* Clear hidden bit and shift */
    282282        result.parts.fraction = ((frac1 >> 6) & (~FLOAT64_HIDDEN_BIT_MASK));
    283283        result.parts.exp = exp1;
    284        
     284
    285285        return result;
    286286}
     
    300300        uint64_t frac1_hi, frac1_lo, frac2_hi, frac2_lo, tmp_hi, tmp_lo;
    301301        float128 result;
    302        
     302
    303303        result.bin.hi = 0;
    304304        result.bin.lo = 0;
    305        
     305
    306306        expdiff = a.parts.exp - b.parts.exp;
    307307        if ((expdiff < 0 ) || ((expdiff == 0) &&
     
    311311                                // TODO: fix SigNaN
    312312                        }
    313                        
     313
    314314                        return b;
    315315                }
    316                
     316
    317317                if (b.parts.exp == FLOAT128_MAX_EXPONENT) {
    318318                        /* num -(+-inf) = -+inf */
     
    320320                        return b;
    321321                }
    322                
     322
    323323                result.parts.sign = !a.parts.sign;
    324                
     324
    325325                frac1_hi = b.parts.frac_hi;
    326326                frac1_lo = b.parts.frac_lo;
     
    335335                                // TODO: fix SigNaN
    336336                        }
    337                        
     337
    338338                        return a;
    339339                }
    340                
     340
    341341                if (a.parts.exp == FLOAT128_MAX_EXPONENT) {
    342342                        if (b.parts.exp == FLOAT128_MAX_EXPONENT) {
     
    349349                        return a;
    350350                }
    351                
     351
    352352                result.parts.sign = a.parts.sign;
    353                
     353
    354354                frac1_hi = a.parts.frac_hi;
    355355                frac1_lo = a.parts.frac_lo;
     
    359359                exp2 = b.parts.exp;
    360360        }
    361        
     361
    362362        if (exp1 == 0) {
    363363                /* both are denormalized */
     
    369369                        return result;
    370370                }
    371                
     371
    372372                result.parts.exp = 0;
    373373                return result;
    374374        }
    375        
     375
    376376        /* add hidden bit */
    377377        or128(frac1_hi, frac1_lo,
    378378            FLOAT128_HIDDEN_BIT_MASK_HI, FLOAT128_HIDDEN_BIT_MASK_LO,
    379379            &frac1_hi, &frac1_lo);
    380        
     380
    381381        if (exp2 == 0) {
    382382                /* denormalized */
     
    388388                    &frac2_hi, &frac2_lo);
    389389        }
    390        
     390
    391391        /* create some space for rounding */
    392392        lshift128(frac1_hi, frac1_lo, 6, &frac1_hi, &frac1_lo);
    393393        lshift128(frac2_hi, frac2_lo, 6, &frac2_hi, &frac2_lo);
    394        
     394
    395395        if (expdiff > FLOAT128_FRACTION_SIZE + 1)
    396396                goto done;
    397        
     397
    398398        rshift128(frac2_hi, frac2_lo, expdiff, &tmp_hi, &tmp_lo);
    399399        sub128(frac1_hi, frac1_lo, tmp_hi, tmp_lo, &frac1_hi, &frac1_lo);
    400        
     400
    401401done:
    402402        /* TODO: find first nonzero digit and shift result and detect possibly underflow */
     
    408408                lshift128(frac1_hi, frac1_lo, 1, &frac1_hi, &frac1_lo);
    409409                /* TODO: fix underflow - frac1 == 0 does not necessary means underflow... */
    410                
     410
    411411                lshift128(FLOAT128_HIDDEN_BIT_MASK_HI, FLOAT128_HIDDEN_BIT_MASK_LO, 6,
    412412                    &tmp_hi, &tmp_lo);
    413413                and128(frac1_hi, frac1_lo, tmp_hi, tmp_lo, &tmp_hi, &tmp_lo);
    414414        }
    415        
     415
    416416        /* rounding - if first bit after fraction is set then round up */
    417417        add128(frac1_hi, frac1_lo, 0x0ll, 0x20ll, &frac1_hi, &frac1_lo);
    418        
     418
    419419        lshift128(FLOAT128_HIDDEN_BIT_MASK_HI, FLOAT128_HIDDEN_BIT_MASK_LO, 7,
    420420           &tmp_hi, &tmp_lo);
     
    424424                rshift128(frac1_hi, frac1_lo, 1, &frac1_hi, &frac1_lo);
    425425        }
    426        
     426
    427427        /* Clear hidden bit and shift */
    428428        rshift128(frac1_hi, frac1_lo, 6, &frac1_hi, &frac1_lo);
     
    432432        result.parts.frac_hi = tmp_hi;
    433433        result.parts.frac_lo = tmp_lo;
    434        
     434
    435435        result.parts.exp = exp1;
    436        
     436
    437437        return result;
    438438}
     
    444444        float32_u ua;
    445445        ua.val = a;
    446        
     446
    447447        float32_u ub;
    448448        ub.val = b;
    449        
     449
    450450        float32_u res;
    451        
     451
    452452        if (ua.data.parts.sign != ub.data.parts.sign) {
    453453                ub.data.parts.sign = !ub.data.parts.sign;
     
    455455        } else
    456456                res.data = sub_float32(ua.data, ub.data);
    457        
     457
    458458        return res.val;
    459459}
     
    463463        float32_u ua;
    464464        ua.val = a;
    465        
     465
    466466        float32_u ub;
    467467        ub.val = b;
    468        
     468
    469469        float32_u res;
    470        
     470
    471471        if (ua.data.parts.sign != ub.data.parts.sign) {
    472472                ub.data.parts.sign = !ub.data.parts.sign;
     
    474474        } else
    475475                res.data = sub_float32(ua.data, ub.data);
    476        
     476
    477477        return res.val;
    478478}
     
    486486        float64_u ua;
    487487        ua.val = a;
    488        
     488
    489489        float64_u ub;
    490490        ub.val = b;
    491        
     491
    492492        float64_u res;
    493        
     493
    494494        if (ua.data.parts.sign != ub.data.parts.sign) {
    495495                ub.data.parts.sign = !ub.data.parts.sign;
     
    497497        } else
    498498                res.data = sub_float64(ua.data, ub.data);
    499        
     499
    500500        return res.val;
    501501}
     
    505505        float64_u ua;
    506506        ua.val = a;
    507        
     507
    508508        float64_u ub;
    509509        ub.val = b;
    510        
     510
    511511        float64_u res;
    512        
     512
    513513        if (ua.data.parts.sign != ub.data.parts.sign) {
    514514                ub.data.parts.sign = !ub.data.parts.sign;
     
    516516        } else
    517517                res.data = sub_float64(ua.data, ub.data);
    518        
     518
    519519        return res.val;
    520520}
     
    528528        float128_u ua;
    529529        ua.val = a;
    530        
     530
    531531        float128_u ub;
    532532        ub.val = b;
    533        
     533
    534534        float128_u res;
    535        
     535
    536536        if (ua.data.parts.sign != ub.data.parts.sign) {
    537537                ub.data.parts.sign = !ub.data.parts.sign;
     
    539539        } else
    540540                res.data = sub_float128(ua.data, ub.data);
    541        
     541
    542542        return res.val;
    543543}
Note: See TracChangeset for help on using the changeset viewer.