Always use unsigned long.
Traditional C compilers had long but not unsigned long. I now assume that everyone can compile unsigned long. Remove macro UNSIGNED_ARITH and act like it is always defined. The type `unsigned arith` works because arith is a macro for long.
This commit is contained in:
parent
9a965efae8
commit
649410bb27
|
@ -94,7 +94,3 @@
|
||||||
#define USE_INSERT 1 /* use C_insertpart mechanism */
|
#define USE_INSERT 1 /* use C_insertpart mechanism */
|
||||||
|
|
||||||
|
|
||||||
!File: uns_arith.h
|
|
||||||
/*#define UNSIGNED_ARITH unsigned arith /* when it is supported */
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -94,7 +94,3 @@
|
||||||
/*#define USE_INSERT 1 /* use C_insertpart mechanism */
|
/*#define USE_INSERT 1 /* use C_insertpart mechanism */
|
||||||
|
|
||||||
|
|
||||||
!File: uns_arith.h
|
|
||||||
/*#define UNSIGNED_ARITH unsigned arith /* when it is supported */
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -117,49 +117,8 @@ divide(pdiv, prem)
|
||||||
register arith o1 = *pdiv;
|
register arith o1 = *pdiv;
|
||||||
register arith o2 = *prem;
|
register arith o2 = *prem;
|
||||||
|
|
||||||
#ifndef UNSIGNED_ARITH
|
*pdiv = (unsigned arith) o1 / (unsigned arith) o2;
|
||||||
/* this is more of a problem than you might
|
*prem = (unsigned arith) o1 % (unsigned arith) o2;
|
||||||
think on C compilers which do not have
|
|
||||||
unsigned long.
|
|
||||||
*/
|
|
||||||
if (o2 & arith_sign) {/* o2 > max_arith */
|
|
||||||
if (! (o1 >= 0 || o1 < o2)) {
|
|
||||||
/* this is the unsigned test
|
|
||||||
o1 < o2 for o2 > max_arith
|
|
||||||
*/
|
|
||||||
*prem = o2 - o1;
|
|
||||||
*pdiv = 1;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
*pdiv = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else { /* o2 <= max_arith */
|
|
||||||
arith half, bit, hdiv, hrem, rem;
|
|
||||||
|
|
||||||
half = (o1 >> 1) & ~arith_sign;
|
|
||||||
bit = o1 & 01;
|
|
||||||
/* now o1 == 2 * half + bit
|
|
||||||
and half <= max_arith
|
|
||||||
and bit <= max_arith
|
|
||||||
*/
|
|
||||||
hdiv = half / o2;
|
|
||||||
hrem = half % o2;
|
|
||||||
rem = 2 * hrem + bit;
|
|
||||||
*pdiv = 2*hdiv;
|
|
||||||
*prem = rem;
|
|
||||||
if (rem < 0 || rem >= o2) {
|
|
||||||
/* that is the unsigned compare
|
|
||||||
rem >= o2 for o2 <= max_arith
|
|
||||||
*/
|
|
||||||
*pdiv += 1;
|
|
||||||
*prem -= o2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
*pdiv = (UNSIGNED_ARITH) o1 / (UNSIGNED_ARITH) o2;
|
|
||||||
*prem = (UNSIGNED_ARITH) o1 % (UNSIGNED_ARITH) o2;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -306,14 +306,7 @@ chk_bounds(l1, l2, fund)
|
||||||
if (fund == T_INTEGER) {
|
if (fund == T_INTEGER) {
|
||||||
return l2 >= l1;
|
return l2 >= l1;
|
||||||
}
|
}
|
||||||
#ifdef UNSIGNED_ARITH
|
return (unsigned arith) l2 >= (unsigned arith) l1;
|
||||||
return (UNSIGNED_ARITH) l2 >= (UNSIGNED_ARITH) l1;
|
|
||||||
#else
|
|
||||||
return (l2 & arith_sign ?
|
|
||||||
(l1 & arith_sign ? l2 >= l1 : 1) :
|
|
||||||
(l1 & arith_sign ? 0 : l2 >= l1)
|
|
||||||
);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
|
Loading…
Reference in a new issue