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

    r3061bc1 ra35b458  
    4949        int expdiff;
    5050        uint32_t exp1, exp2, frac1, frac2;
    51        
     51
    5252        expdiff = a.parts.exp - b.parts.exp;
    5353        if (expdiff < 0) {
     
    5959                        return b;
    6060                }
    61                
     61
    6262                if (b.parts.exp == FLOAT32_MAX_EXPONENT) {
    6363                        return b;
    6464                }
    65                
     65
    6666                frac1 = b.parts.fraction;
    6767                exp1 = b.parts.exp;
     
    7676                        return (is_float32_nan(a) ? a : b);
    7777                }
    78                
     78
    7979                if (a.parts.exp == FLOAT32_MAX_EXPONENT) {
    8080                        return a;
    8181                }
    82                
     82
    8383                frac1 = a.parts.fraction;
    8484                exp1 = a.parts.exp;
     
    8686                exp2 = b.parts.exp;
    8787        }
    88        
     88
    8989        if (exp1 == 0) {
    9090                /* both are denormalized */
     
    9797                return a;
    9898        }
    99        
     99
    100100        frac1 |= FLOAT32_HIDDEN_BIT_MASK; /* add hidden bit */
    101101
     
    107107                frac2 |= FLOAT32_HIDDEN_BIT_MASK;
    108108        }
    109        
     109
    110110        /* create some space for rounding */
    111111        frac1 <<= 6;
    112112        frac2 <<= 6;
    113        
     113
    114114        if (expdiff < (FLOAT32_FRACTION_SIZE + 2)) {
    115115                frac2 >>= expdiff;
     
    120120                return a;
    121121        }
    122        
     122
    123123        if (frac1 & (FLOAT32_HIDDEN_BIT_MASK << 7)) {
    124124                ++exp1;
    125125                frac1 >>= 1;
    126126        }
    127        
     127
    128128        /* rounding - if first bit after fraction is set then round up */
    129129        frac1 += (0x1 << 5);
    130        
     130
    131131        if (frac1 & (FLOAT32_HIDDEN_BIT_MASK << 7)) {
    132132                /* rounding overflow */
     
    134134                frac1 >>= 1;
    135135        }
    136        
     136
    137137        if ((exp1 == FLOAT32_MAX_EXPONENT) || (exp2 > exp1)) {
    138138                /* overflow - set infinity as result */
     
    141141                return a;
    142142        }
    143        
     143
    144144        a.parts.exp = exp1;
    145        
     145
    146146        /* Clear hidden bit and shift */
    147147        a.parts.fraction = ((frac1 >> 6) & (~FLOAT32_HIDDEN_BIT_MASK));
     
    160160        uint32_t exp1, exp2;
    161161        uint64_t frac1, frac2;
    162        
     162
    163163        expdiff = ((int) a.parts.exp) - b.parts.exp;
    164164        if (expdiff < 0) {
     
    170170                        return b;
    171171                }
    172                
     172
    173173                /* b is infinity and a not */
    174174                if (b.parts.exp == FLOAT64_MAX_EXPONENT) {
    175175                        return b;
    176176                }
    177                
     177
    178178                frac1 = b.parts.fraction;
    179179                exp1 = b.parts.exp;
     
    188188                        return a;
    189189                }
    190                
     190
    191191                /* a is infinity and b not */
    192192                if (a.parts.exp == FLOAT64_MAX_EXPONENT) {
    193193                        return a;
    194194                }
    195                
     195
    196196                frac1 = a.parts.fraction;
    197197                exp1 = a.parts.exp;
     
    199199                exp2 = b.parts.exp;
    200200        }
    201        
     201
    202202        if (exp1 == 0) {
    203203                /* both are denormalized */
     
    210210                return a;
    211211        }
    212        
     212
    213213        /* add hidden bit - frac1 is sure not denormalized */
    214214        frac1 |= FLOAT64_HIDDEN_BIT_MASK;
     
    222222                frac2 |= FLOAT64_HIDDEN_BIT_MASK;
    223223        }
    224        
     224
    225225        /* create some space for rounding */
    226226        frac1 <<= 6;
    227227        frac2 <<= 6;
    228        
     228
    229229        if (expdiff < (FLOAT64_FRACTION_SIZE + 2)) {
    230230                frac2 >>= expdiff;
     
    235235                return a;
    236236        }
    237        
     237
    238238        if (frac1 & (FLOAT64_HIDDEN_BIT_MASK << 7)) {
    239239                ++exp1;
    240240                frac1 >>= 1;
    241241        }
    242        
     242
    243243        /* rounding - if first bit after fraction is set then round up */
    244244        frac1 += (0x1 << 5);
    245        
     245
    246246        if (frac1 & (FLOAT64_HIDDEN_BIT_MASK << 7)) {
    247247                /* rounding overflow */
     
    249249                frac1 >>= 1;
    250250        }
    251        
     251
    252252        if ((exp1 == FLOAT64_MAX_EXPONENT) || (exp2 > exp1)) {
    253253                /* overflow - set infinity as result */
     
    256256                return a;
    257257        }
    258        
     258
    259259        a.parts.exp = exp1;
    260260        /* Clear hidden bit and shift */
     
    400400
    401401        a.parts.exp = exp1;
    402        
     402
    403403        /* Clear hidden bit and shift */
    404404        rshift128(frac1_hi, frac1_lo, 6, &frac1_hi, &frac1_lo);
     
    419419        float32_u ua;
    420420        ua.val = a;
    421        
     421
    422422        float32_u ub;
    423423        ub.val = b;
    424        
     424
    425425        float32_u res;
    426        
     426
    427427        if (ua.data.parts.sign != ub.data.parts.sign) {
    428428                if (ua.data.parts.sign) {
     
    435435        } else
    436436                res.data = add_float32(ua.data, ub.data);
    437        
     437
    438438        return res.val;
    439439}
     
    443443        float32_u ua;
    444444        ua.val = a;
    445        
     445
    446446        float32_u ub;
    447447        ub.val = b;
    448        
     448
    449449        float32_u res;
    450        
     450
    451451        if (ua.data.parts.sign != ub.data.parts.sign) {
    452452                if (ua.data.parts.sign) {
     
    459459        } else
    460460                res.data = add_float32(ua.data, ub.data);
    461        
     461
    462462        return res.val;
    463463}
     
    471471        float64_u ua;
    472472        ua.val = a;
    473        
     473
    474474        float64_u ub;
    475475        ub.val = b;
    476        
     476
    477477        float64_u res;
    478        
     478
    479479        if (ua.data.parts.sign != ub.data.parts.sign) {
    480480                if (ua.data.parts.sign) {
     
    487487        } else
    488488                res.data = add_float64(ua.data, ub.data);
    489        
     489
    490490        return res.val;
    491491}
     
    495495        float64_u ua;
    496496        ua.val = a;
    497        
     497
    498498        float64_u ub;
    499499        ub.val = b;
    500        
     500
    501501        float64_u res;
    502        
     502
    503503        if (ua.data.parts.sign != ub.data.parts.sign) {
    504504                if (ua.data.parts.sign) {
     
    511511        } else
    512512                res.data = add_float64(ua.data, ub.data);
    513        
     513
    514514        return res.val;
    515515}
     
    523523        float128_u ua;
    524524        ua.val = a;
    525        
     525
    526526        float128_u ub;
    527527        ub.val = b;
    528        
     528
    529529        float128_u res;
    530        
     530
    531531        if (ua.data.parts.sign != ub.data.parts.sign) {
    532532                if (ua.data.parts.sign) {
     
    539539        } else
    540540                res.data = add_float128(ua.data, ub.data);
    541        
     541
    542542        return res.val;
    543543}
Note: See TracChangeset for help on using the changeset viewer.