Changeset a35b458 in mainline for boot/genarch/src/division.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
  • boot/genarch/src/division.c

    r3061bc1 ra35b458  
    4040        unsigned int result;
    4141        int steps = sizeof(unsigned int) * 8;
    42        
     42
    4343        *remainder = 0;
    4444        result = 0;
    45        
     45
    4646        if (b == 0) {
    4747                /* FIXME: division by zero */
    4848                return 0;
    4949        }
    50        
     50
    5151        if (a < b) {
    5252                *remainder = a;
    5353                return 0;
    5454        }
    55        
     55
    5656        for (; steps > 0; steps--) {
    5757                /* shift one bit to remainder */
    5858                *remainder = ((*remainder) << 1) | (( a >> 31) & 0x1);
    5959                result <<= 1;
    60                
     60
    6161                if (*remainder >= b) {
    6262                        *remainder -= b;
     
    6565                a <<= 1;
    6666        }
    67        
     67
    6868        return result;
    6969}
     
    7474        unsigned long long result;
    7575        int steps = sizeof(unsigned long long) * 8;
    76        
     76
    7777        *remainder = 0;
    7878        result = 0;
    79        
     79
    8080        if (b == 0) {
    8181                /* FIXME: division by zero */
    8282                return 0;
    8383        }
    84        
     84
    8585        if (a < b) {
    8686                *remainder = a;
    8787                return 0;
    8888        }
    89        
     89
    9090        for (; steps > 0; steps--) {
    9191                /* shift one bit to remainder */
    9292                *remainder = ((*remainder) << 1) | ((a >> 63) & 0x1);
    9393                result <<= 1;
    94                
     94
    9595                if (*remainder >= b) {
    9696                        *remainder -= b;
     
    9999                a <<= 1;
    100100        }
    101        
     101
    102102        return result;
    103103}
     
    108108        unsigned int rem;
    109109        int result = (int) divandmod32(ABSVAL(a), ABSVAL(b), &rem);
    110        
     110
    111111        if (SGN(a) == SGN(b))
    112112                return result;
    113        
     113
    114114        return -result;
    115115}
     
    120120        unsigned long long rem;
    121121        long long result = (long long) divandmod64(ABSVAL(a), ABSVAL(b), &rem);
    122        
     122
    123123        if (SGN(a) == SGN(b))
    124124                return result;
    125        
     125
    126126        return -result;
    127127}
     
    146146        unsigned int rem;
    147147        divandmod32(a, b, &rem);
    148        
     148
    149149        /* if divident is negative, remainder must be too */
    150150        if (!(SGN(a)))
    151151                return -((int) rem);
    152        
     152
    153153        return (int) rem;
    154154}
     
    159159        unsigned long long rem;
    160160        divandmod64(a, b, &rem);
    161        
     161
    162162        /* if divident is negative, remainder must be too */
    163163        if (!(SGN(a)))
    164164                return -((long long) rem);
    165        
     165
    166166        return (long long) rem;
    167167}
     
    187187        unsigned int rem;
    188188        int result = (int) divandmod32(ABSVAL(a), ABSVAL(b), &rem);
    189        
     189
    190190        if (SGN(a) == SGN(b)) {
    191191                *c = rem;
    192192                return result;
    193193        }
    194        
     194
    195195        *c = -rem;
    196196        return -result;
     
    207207        unsigned long long rem;
    208208        long long result = (int) divandmod64(ABSVAL(a), ABSVAL(b), &rem);
    209        
     209
    210210        if (SGN(a) == SGN(b)) {
    211211                *c = rem;
    212212                return result;
    213213        }
    214        
     214
    215215        *c = -rem;
    216216        return -result;
Note: See TracChangeset for help on using the changeset viewer.