Changeset 8565a42 in mainline for uspace/lib/softint


Ignore:
Timestamp:
2018-03-02T20:34:50Z (7 years ago)
Author:
GitHub <noreply@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
a1a81f69, d5e5fd1
Parents:
3061bc1 (diff), 34e1206 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
git-author:
Jiří Zárevúcky <zarevucky.jiri@…> (2018-03-02 20:34:50)
git-committer:
GitHub <noreply@…> (2018-03-02 20:34:50)
Message:

Remove all trailing whitespace, everywhere.

See individual commit messages for details.

Location:
uspace/lib/softint/generic
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/softint/generic/division.c

    r3061bc1 r8565a42  
    4545        unsigned int result;
    4646        int steps = sizeof(unsigned int) * 8;
    47        
     47
    4848        *remainder = 0;
    4949        result = 0;
    50        
     50
    5151        if (b == 0) {
    5252                /* FIXME: division by zero */
    5353                return 0;
    5454        }
    55        
     55
    5656        if (a < b) {
    5757                *remainder = a;
    5858                return 0;
    5959        }
    60        
     60
    6161        for (; steps > 0; steps--) {
    6262                /* shift one bit to remainder */
    6363                *remainder = ((*remainder) << 1) | (( a >> 31) & 0x1);
    6464                result <<= 1;
    65                
     65
    6666                if (*remainder >= b) {
    6767                        *remainder -= b;
     
    7070                a <<= 1;
    7171        }
    72        
     72
    7373        return result;
    7474}
     
    7979        unsigned long long result;
    8080        int steps = sizeof(unsigned long long) * 8;
    81        
     81
    8282        *remainder = 0;
    8383        result = 0;
    84        
     84
    8585        if (b == 0) {
    8686                /* FIXME: division by zero */
    8787                return 0;
    8888        }
    89        
     89
    9090        if (a < b) {
    9191                *remainder = a;
    9292                return 0;
    9393        }
    94        
     94
    9595        for (; steps > 0; steps--) {
    9696                /* shift one bit to remainder */
    9797                *remainder = ((*remainder) << 1) | ((a >> 63) & 0x1);
    9898                result <<= 1;
    99                
     99
    100100                if (*remainder >= b) {
    101101                        *remainder -= b;
     
    104104                a <<= 1;
    105105        }
    106        
     106
    107107        return result;
    108108}
     
    113113        unsigned int rem;
    114114        int result = (int) divandmod32(ABSVAL(a), ABSVAL(b), &rem);
    115        
     115
    116116        if (SGN(a) == SGN(b))
    117117                return result;
    118        
     118
    119119        return -result;
    120120}
     
    125125        unsigned long long rem;
    126126        long long result = (long long) divandmod64(ABSVAL(a), ABSVAL(b), &rem);
    127        
     127
    128128        if (SGN(a) == SGN(b))
    129129                return result;
    130        
     130
    131131        return -result;
    132132}
     
    151151        unsigned int rem;
    152152        divandmod32(a, b, &rem);
    153        
     153
    154154        /* if divident is negative, remainder must be too */
    155155        if (!(SGN(a)))
    156156                return -((int) rem);
    157        
     157
    158158        return (int) rem;
    159159}
     
    164164        unsigned long long rem;
    165165        divandmod64(a, b, &rem);
    166        
     166
    167167        /* if divident is negative, remainder must be too */
    168168        if (!(SGN(a)))
    169169                return -((long long) rem);
    170        
     170
    171171        return (long long) rem;
    172172}
     
    192192        unsigned int rem;
    193193        int result = (int) divandmod32(ABSVAL(a), ABSVAL(b), &rem);
    194        
     194
    195195        if (SGN(a) == SGN(b)) {
    196196                *c = rem;
    197197                return result;
    198198        }
    199        
     199
    200200        *c = -rem;
    201201        return -result;
     
    212212        unsigned long long rem;
    213213        long long result = (int) divandmod64(ABSVAL(a), ABSVAL(b), &rem);
    214        
     214
    215215        if (SGN(a) == SGN(b)) {
    216216                *c = rem;
    217217                return result;
    218218        }
    219        
     219
    220220        *c = -rem;
    221221        return -result;
     
    226226        unsigned long long rem;
    227227        long long result = (int) divandmod64(ABSVAL(a), ABSVAL(b), &rem);
    228        
     228
    229229        if (SGN(a) == SGN(b)) {
    230230                *c = rem;
    231231                return result;
    232232        }
    233        
     233
    234234        *c = -rem;
    235235        return -result;
  • uspace/lib/softint/generic/multiplication.c

    r3061bc1 r8565a42  
    5353        unsigned int b1 = b >> 16;
    5454        unsigned int b2 = b & UINT16_MAX;
    55        
     55
    5656        unsigned long long t1 = a1 * b1;
    5757        unsigned long long t2 = a1 * b2;
    5858        t2 += a2 * b1;
    5959        unsigned long long t3 = a2 * b2;
    60        
     60
    6161        t3 = (((t1 << 16) + t2) << 16) + t3;
    62        
     62
    6363        return t3;
    6464}
     
    7070{
    7171        char neg = 0;
    72        
     72
    7373        if (a < 0) {
    7474                neg = !neg;
    7575                a = -a;
    7676        }
    77        
     77
    7878        if (b < 0) {
    7979                neg = !neg;
    8080                b = -b;
    8181        }
    82        
     82
    8383        unsigned long long a1 = a >> 32;
    8484        unsigned long long b1 = b >> 32;
    85        
     85
    8686        unsigned long long a2 = a & (UINT32_MAX);
    8787        unsigned long long b2 = b & (UINT32_MAX);
    88        
     88
    8989        if (SOFTINT_CHECK_OF && (a1 != 0) && (b1 != 0)) {
    9090                /* Error (overflow) */
    9191                return (neg ? INT64_MIN : INT64_MAX);
    9292        }
    93        
     93
    9494        /* (if OF checked) a1 or b1 is zero => result fits in 64 bits,
    9595         * no need to another overflow check
    9696         */
    9797        unsigned long long t1 = mul(a1, b2) + mul(b1, a2);
    98        
     98
    9999        if ((SOFTINT_CHECK_OF) && (t1 > UINT32_MAX)) {
    100100                /* Error (overflow) */
    101101                return (neg ? INT64_MIN : INT64_MAX);
    102102        }
    103        
     103
    104104        t1 = t1 << 32;
    105105        unsigned long long t2 = mul(a2, b2);
    106106        t2 += t1;
    107        
     107
    108108        /* t2 & (1ull << 63) - if this bit is set in unsigned long long,
    109109         * result does not fit in signed one */
     
    112112                return (neg ? INT64_MIN : INT64_MAX);
    113113        }
    114        
     114
    115115        long long result = t2;
    116116        if (neg)
    117117                result = -result;
    118        
     118
    119119        return result;
    120120}
  • uspace/lib/softint/generic/shift.c

    r3061bc1 r8565a42  
    4242
    4343        ll.s_whole = val;
    44        
     44
    4545        if (shift <= 0) {
    4646                return ll.s_whole;
    4747        }
    48        
     48
    4949        if (shift >= (int) WHOLE_BIT_CNT) {
    5050                ll.u_half[HI] = 0;
Note: See TracChangeset for help on using the changeset viewer.