Changeset c127e1c in mainline for kernel/genarch
- Timestamp:
- 2012-04-11T15:37:01Z (14 years ago)
- 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. - Location:
- kernel/genarch
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/genarch/include/softint/division.h
r3a01483 rc127e1c 36 36 #define KERN_DIVISION_H_ 37 37 38 /* 32bit integer division */ 39 int __divsi3(int a, int b);38 extern int __divsi3(int, int); 39 extern long long __divdi3(long long, long long); 40 40 41 /* 64bit integer division */ 42 long long __divdi3(long long a, long long b);41 extern unsigned int __udivsi3(unsigned int, unsigned int); 42 extern unsigned long long __udivdi3(unsigned long long, unsigned long long); 43 43 44 /* 32bit unsigned integer division */ 45 unsigned int __udivsi3(unsigned int a, unsigned int b);44 extern int __modsi3(int, int); 45 extern long long __moddi3(long long, long long); 46 46 47 /* 64bit unsigned integer division */ 48 unsigned long long __udivdi3(unsigned long long a, unsigned long long b);47 extern unsigned int __umodsi3(unsigned int, unsigned int); 48 extern unsigned long long __umoddi3(unsigned long long, unsigned long long); 49 49 50 /* 32bit remainder of the signed division */ 51 int __modsi3(int a, int b);50 extern int __divmodsi3(int, int, int *); 51 extern unsigned int __udivmodsi3(unsigned int, unsigned int, unsigned int *); 52 52 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); 53 extern long long __divmoddi3(long long, long long, long long *); 54 extern unsigned long long __udivmoddi3(unsigned long long, unsigned long long, 55 unsigned long long *); 63 56 64 57 #endif -
kernel/genarch/include/softint/multiplication.h
r3a01483 rc127e1c 29 29 /** @addtogroup genarch 30 30 * @{ 31 */ 31 */ 32 32 /** 33 33 * @file 34 34 */ 35 35 36 #ifndef __SOFTINT_MULTIPLICATION_H__37 #define __SOFTINT_MULTIPLICATION_H__36 #ifndef KERN_MULTIPLICATION_H_ 37 #define KERN_MULTIPLICATION_H_ 38 38 39 39 /* 64 bit multiplication */ 40 long long __muldi3(long long a, long long b);40 extern long long __muldi3(long long, long long); 41 41 42 42 #endif … … 44 44 /** @} 45 45 */ 46 47 -
kernel/genarch/src/softint/division.c
r3a01483 rc127e1c 27 27 */ 28 28 29 /** @addtogroup genarch 29 /** @addtogroup genarch 30 30 * @{ 31 31 */ … … 35 35 #include <genarch/softint/division.h> 36 36 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 40 40 static unsigned int divandmod32(unsigned int a, unsigned int b, 41 41 unsigned int *remainder) … … 56 56 return 0; 57 57 } 58 58 59 59 for (; steps > 0; steps--) { 60 60 /* shift one bit to remainder */ … … 68 68 a <<= 1; 69 69 } 70 70 71 71 return result; 72 72 } 73 74 73 75 74 static unsigned long long divandmod64(unsigned long long a, … … 77 76 { 78 77 unsigned long long result; 79 int steps = sizeof(unsigned long long) * 8; 78 int steps = sizeof(unsigned long long) * 8; 80 79 81 80 *remainder = 0; … … 91 90 return 0; 92 91 } 93 92 94 93 for (; steps > 0; steps--) { 95 94 /* shift one bit to remainder */ … … 103 102 a <<= 1; 104 103 } 105 104 106 105 return result; 107 106 } 108 107 109 108 /* 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 109 int __divsi3(int a, int b) 110 { 111 unsigned int rem; 112 int result = (int) divandmod32(ABSVAL(a), ABSVAL(b), &rem); 113 117 114 if (SGN(a) == SGN(b)) 118 115 return result; 116 119 117 return -result; 120 118 } 121 119 122 120 /* 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 121 long 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 130 126 if (SGN(a) == SGN(b)) 131 127 return result; 128 132 129 return -result; 133 130 } … … 143 140 unsigned long long __udivdi3(unsigned long long a, unsigned long long b) 144 141 { 145 unsigned long long 142 unsigned long long rem; 146 143 return divandmod64(a, b, &rem); 147 144 } … … 154 151 155 152 /* if divident is negative, remainder must be too */ 156 if (!(SGN(a))) {153 if (!(SGN(a))) 157 154 return -((int) rem); 158 }159 155 160 156 return (int) rem; … … 162 158 163 159 /* 64bit remainder of the signed division */ 164 long long __moddi3(long long a, longlong b)160 long long __moddi3(long long a, long long b) 165 161 { 166 162 unsigned long long rem; … … 168 164 169 165 /* if divident is negative, remainder must be too */ 170 if (!(SGN(a))) {166 if (!(SGN(a))) 171 167 return -((long long) rem); 172 }173 168 174 169 return (long long) rem; … … 191 186 } 192 187 188 int __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 202 unsigned int __udivmodsi3(unsigned int a, unsigned int b, 203 unsigned int *c) 204 { 205 return divandmod32(a, b, c); 206 } 207 208 long 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 193 222 unsigned long long __udivmoddi3(unsigned long long a, unsigned long long b, 194 223 unsigned long long *c) -
kernel/genarch/src/softint/multiplication.c
r3a01483 rc127e1c 29 29 /** @addtogroup genarch 30 30 * @{ 31 */ 31 */ 32 32 /** 33 33 * @file … … 130 130 131 131 return result; 132 } 132 } 133 133 134 134 /** @}
Note:
See TracChangeset
for help on using the changeset viewer.