Subversion Repositories HelenOS-historic

Compare Revisions

Ignore whitespace Rev 810 → Rev 811

/kernel/trunk/genarch/src/softint/division.c/softint.c
26,7 → 26,7
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
#include <softint/softint.h>
#include <genarch/softint/division.h>
 
#define ABSVAL(x) ( (x) > 0 ? (x) : -(x))
#define SGN(x) ( (x) >= 0 ? 1 : 0 )
34,7 → 34,7
static unsigned int divandmod32(unsigned int a, unsigned int b, unsigned int *remainder)
{
unsigned int result;
int steps = sizeof(unsigned int);
int steps = sizeof(unsigned int) * 8;
*remainder = 0;
result = 0;
51,7 → 51,7
 
for ( ; steps > 0; steps--) {
/* shift one bit to remainder */
*remainder = ( (*remainder) << 1) | (( divident >> 31) & 0x1);
*remainder = ( (*remainder) << 1) | (( a >> 31) & 0x1);
result <<= 1;
if (*remainder >= b) {
58,7 → 58,7
*remainder -= b;
result |= 0x1;
}
divident <<= 1;
a <<= 1;
}
 
return result;
68,7 → 68,7
static unsigned long divandmod64(unsigned long a, unsigned long b, unsigned long *remainder)
{
unsigned long result;
int steps = sizeof(unsigned long);
int steps = sizeof(unsigned long) * 8;
*remainder = 0;
result = 0;
85,7 → 85,7
 
for ( ; steps > 0; steps--) {
/* shift one bit to remainder */
*remainder = ( (*remainder) << 1) | (( divident >> 63) & 0x1);
*remainder = ( (*remainder) << 1) | ((a >> 63) & 0x1);
result <<= 1;
if (*remainder >= b) {
92,7 → 92,7
*remainder -= b;
result |= 0x1;
}
divident <<= 1;
a <<= 1;
}
 
return result;
142,7 → 142,7
unsigned int rem;
divandmod32(a, b, &rem);
/* if divident is negative, remainder must be too*/
/* if divident is negative, remainder must be too */
if (!(SGN(a))) {
return -((int)rem);
}
156,7 → 156,7
unsigned long rem;
divandmod64(a, b, &rem);
/* if divident is negative, remainder must be too*/
/* if divident is negative, remainder must be too */
if (!(SGN(a))) {
return -((long)rem);
}