Changeset c127e1c in mainline for kernel/genarch


Ignore:
Timestamp:
2012-04-11T15:37:01Z (14 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
49a736e2
Parents:
3a01483 (diff), d11a181 (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.
Message:

Mainline changes.

Location:
kernel/genarch
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • kernel/genarch/include/softint/division.h

    r3a01483 rc127e1c  
    3636#define KERN_DIVISION_H_
    3737
    38 /* 32bit integer division */
    39 int __divsi3(int a, int b);
     38extern int __divsi3(int, int);
     39extern long long __divdi3(long long, long long);
    4040
    41 /* 64bit integer division */
    42 long long __divdi3(long long a, long long b);
     41extern unsigned int __udivsi3(unsigned int, unsigned int);
     42extern unsigned long long __udivdi3(unsigned long long, unsigned long long);
    4343
    44 /* 32bit unsigned integer division */
    45 unsigned int __udivsi3(unsigned int a, unsigned int b);
     44extern int __modsi3(int, int);
     45extern long long __moddi3(long long, long long);
    4646
    47 /* 64bit unsigned integer division */
    48 unsigned long long __udivdi3(unsigned long long a, unsigned long long b);
     47extern unsigned int __umodsi3(unsigned int, unsigned int);
     48extern unsigned long long __umoddi3(unsigned long long, unsigned long long);
    4949
    50 /* 32bit remainder of the signed division */
    51 int __modsi3(int a, int b);
     50extern int __divmodsi3(int, int, int *);
     51extern unsigned int __udivmodsi3(unsigned int, unsigned int, unsigned int *);
    5252
    53 /* 64bit remainder of the signed division */
    54 long long __moddi3(long long a, long long b);
    55 
    56 /* 32bit remainder of the unsigned division */
    57 unsigned int __umodsi3(unsigned int a, unsigned int b);
    58 
    59 /* 64bit remainder of the unsigned division */
    60 unsigned long long __umoddi3(unsigned long long a, unsigned long long b);
    61 
    62 unsigned long long __udivmoddi3(unsigned long long a, unsigned long long b, unsigned long long *c);
     53extern long long __divmoddi3(long long, long long, long long *);
     54extern unsigned long long __udivmoddi3(unsigned long long, unsigned long long,
     55    unsigned long long *);
    6356
    6457#endif
  • kernel/genarch/include/softint/multiplication.h

    r3a01483 rc127e1c  
    2929/** @addtogroup genarch
    3030 * @{
    31  */ 
     31 */
    3232/**
    3333 * @file
    3434 */
    3535
    36 #ifndef __SOFTINT_MULTIPLICATION_H__
    37 #define __SOFTINT_MULTIPLICATION_H__
     36#ifndef KERN_MULTIPLICATION_H_
     37#define KERN_MULTIPLICATION_H_
    3838
    3939/* 64 bit multiplication */
    40 long long __muldi3(long long a, long long b);
     40extern long long __muldi3(long long, long long);
    4141
    4242#endif
     
    4444/** @}
    4545 */
    46 
    47 
  • kernel/genarch/src/softint/division.c

    r3a01483 rc127e1c  
    2727 */
    2828
    29 /** @addtogroup genarch 
     29/** @addtogroup genarch
    3030 * @{
    3131 */
     
    3535#include <genarch/softint/division.h>
    3636
    37 #define ABSVAL(x) ((x) > 0 ? (x) : -(x))
    38 #define SGN(x) ((x) >= 0 ? 1 : 0)
    39                                      
     37#define ABSVAL(x)  ((x) > 0 ? (x) : -(x))
     38#define SGN(x)     ((x) >= 0 ? 1 : 0)
     39
    4040static unsigned int divandmod32(unsigned int a, unsigned int b,
    4141    unsigned int *remainder)
     
    5656                return 0;
    5757        }
    58 
     58       
    5959        for (; steps > 0; steps--) {
    6060                /* shift one bit to remainder */
     
    6868                a <<= 1;
    6969        }
    70 
     70       
    7171        return result;
    7272}
    73 
    7473
    7574static unsigned long long divandmod64(unsigned long long a,
     
    7776{
    7877        unsigned long long result;
    79         int steps = sizeof(unsigned long long) * 8; 
     78        int steps = sizeof(unsigned long long) * 8;
    8079       
    8180        *remainder = 0;
     
    9190                return 0;
    9291        }
    93 
     92       
    9493        for (; steps > 0; steps--) {
    9594                /* shift one bit to remainder */
     
    103102                a <<= 1;
    104103        }
    105 
     104       
    106105        return result;
    107106}
    108107
    109108/* 32bit integer division */
    110 int __divsi3(int a, int b)
    111 {
    112         unsigned int rem;
    113         int result;
    114        
    115         result = (int) divandmod32(ABSVAL(a), ABSVAL(b), &rem);
    116 
     109int __divsi3(int a, int b)
     110{
     111        unsigned int rem;
     112        int result = (int) divandmod32(ABSVAL(a), ABSVAL(b), &rem);
     113       
    117114        if (SGN(a) == SGN(b))
    118115                return result;
     116       
    119117        return -result;
    120118}
    121119
    122120/* 64bit integer division */
    123 long long __divdi3(long long a, long long b)
    124 {
    125         unsigned long long rem;
    126         long long result;
    127        
    128         result = (long long) divandmod64(ABSVAL(a), ABSVAL(b), &rem);
    129 
     121long long __divdi3(long long a, long long b)
     122{
     123        unsigned long long rem;
     124        long long result = (long long) divandmod64(ABSVAL(a), ABSVAL(b), &rem);
     125       
    130126        if (SGN(a) == SGN(b))
    131127                return result;
     128       
    132129        return -result;
    133130}
     
    143140unsigned long long __udivdi3(unsigned long long a, unsigned long long b)
    144141{
    145         unsigned long long  rem;
     142        unsigned long long rem;
    146143        return divandmod64(a, b, &rem);
    147144}
     
    154151       
    155152        /* if divident is negative, remainder must be too */
    156         if (!(SGN(a))) {
     153        if (!(SGN(a)))
    157154                return -((int) rem);
    158         }
    159155       
    160156        return (int) rem;
     
    162158
    163159/* 64bit remainder of the signed division */
    164 long long __moddi3(long long a,long long b)
     160long long __moddi3(long long a, long long b)
    165161{
    166162        unsigned long long rem;
     
    168164       
    169165        /* if divident is negative, remainder must be too */
    170         if (!(SGN(a))) {
     166        if (!(SGN(a)))
    171167                return -((long long) rem);
    172         }
    173168       
    174169        return (long long) rem;
     
    191186}
    192187
     188int __divmodsi3(int a, int b, int *c)
     189{
     190        unsigned int rem;
     191        int result = (int) divandmod32(ABSVAL(a), ABSVAL(b), &rem);
     192       
     193        if (SGN(a) == SGN(b)) {
     194                *c = rem;
     195                return result;
     196        }
     197       
     198        *c = -rem;
     199        return -result;
     200}
     201
     202unsigned int __udivmodsi3(unsigned int a, unsigned int b,
     203    unsigned int *c)
     204{
     205        return divandmod32(a, b, c);
     206}
     207
     208long long __divmoddi3(long long a, long long b, long long *c)
     209{
     210        unsigned long long rem;
     211        long long result = (int) divandmod64(ABSVAL(a), ABSVAL(b), &rem);
     212       
     213        if (SGN(a) == SGN(b)) {
     214                *c = rem;
     215                return result;
     216        }
     217       
     218        *c = -rem;
     219        return -result;
     220}
     221
    193222unsigned long long __udivmoddi3(unsigned long long a, unsigned long long b,
    194223    unsigned long long *c)
  • kernel/genarch/src/softint/multiplication.c

    r3a01483 rc127e1c  
    2929/** @addtogroup genarch
    3030 * @{
    31  */ 
     31 */
    3232/**
    3333 * @file
     
    130130
    131131        return result;
    132 }       
     132}
    133133
    134134/** @}
Note: See TracChangeset for help on using the changeset viewer.