Commit f29481c0 authored by Russell King's avatar Russell King

[PATCH] ARM: Remove gcc type-isms from GCC helper functions

Convert ugly GCC types to Linux types:

	UQImode -> u8
	SImode -> s32
	USImode -> u32
	DImode -> s64
	UDImode -> u64
	word_type -> int
Signed-off-by: default avatarRussell King <rmk+kernel@arm.linux.org.uk>
parent 34c8eaca
...@@ -31,11 +31,11 @@ Boston, MA 02111-1307, USA. */ ...@@ -31,11 +31,11 @@ Boston, MA 02111-1307, USA. */
#include "gcclib.h" #include "gcclib.h"
DItype s64
__ashldi3 (DItype u, word_type b) __ashldi3 (s64 u, int b)
{ {
DIunion w; DIunion w;
word_type bm; int bm;
DIunion uu; DIunion uu;
if (b == 0) if (b == 0)
...@@ -43,17 +43,17 @@ __ashldi3 (DItype u, word_type b) ...@@ -43,17 +43,17 @@ __ashldi3 (DItype u, word_type b)
uu.ll = u; uu.ll = u;
bm = (sizeof (SItype) * BITS_PER_UNIT) - b; bm = (sizeof (s32) * BITS_PER_UNIT) - b;
if (bm <= 0) if (bm <= 0)
{ {
w.s.low = 0; w.s.low = 0;
w.s.high = (USItype)uu.s.low << -bm; w.s.high = (u32)uu.s.low << -bm;
} }
else else
{ {
USItype carries = (USItype)uu.s.low >> bm; u32 carries = (u32)uu.s.low >> bm;
w.s.low = (USItype)uu.s.low << b; w.s.low = (u32)uu.s.low << b;
w.s.high = ((USItype)uu.s.high << b) | carries; w.s.high = ((u32)uu.s.high << b) | carries;
} }
return w.ll; return w.ll;
......
...@@ -31,11 +31,11 @@ Boston, MA 02111-1307, USA. */ ...@@ -31,11 +31,11 @@ Boston, MA 02111-1307, USA. */
#include "gcclib.h" #include "gcclib.h"
DItype s64
__ashrdi3 (DItype u, word_type b) __ashrdi3 (s64 u, int b)
{ {
DIunion w; DIunion w;
word_type bm; int bm;
DIunion uu; DIunion uu;
if (b == 0) if (b == 0)
...@@ -43,18 +43,18 @@ __ashrdi3 (DItype u, word_type b) ...@@ -43,18 +43,18 @@ __ashrdi3 (DItype u, word_type b)
uu.ll = u; uu.ll = u;
bm = (sizeof (SItype) * BITS_PER_UNIT) - b; bm = (sizeof (s32) * BITS_PER_UNIT) - b;
if (bm <= 0) if (bm <= 0)
{ {
/* w.s.high = 1..1 or 0..0 */ /* w.s.high = 1..1 or 0..0 */
w.s.high = uu.s.high >> (sizeof (SItype) * BITS_PER_UNIT - 1); w.s.high = uu.s.high >> (sizeof (s32) * BITS_PER_UNIT - 1);
w.s.low = uu.s.high >> -bm; w.s.low = uu.s.high >> -bm;
} }
else else
{ {
USItype carries = (USItype)uu.s.high << bm; u32 carries = (u32)uu.s.high << bm;
w.s.high = uu.s.high >> b; w.s.high = uu.s.high >> b;
w.s.low = ((USItype)uu.s.low >> b) | carries; w.s.low = ((u32)uu.s.low >> b) | carries;
} }
return w.ll; return w.ll;
......
/* gcclib.h -- definitions for various functions 'borrowed' from gcc-2.95.3 */ /* gcclib.h -- definitions for various functions 'borrowed' from gcc-2.95.3 */
/* I Molton 29/07/01 */ /* I Molton 29/07/01 */
#define BITS_PER_UNIT 8 #include <linux/types.h>
#define SI_TYPE_SIZE (sizeof (SItype) * BITS_PER_UNIT)
typedef unsigned int UQItype __attribute__ ((mode (QI))); #define BITS_PER_UNIT 8
typedef int SItype __attribute__ ((mode (SI))); #define SI_TYPE_SIZE (sizeof(s32) * BITS_PER_UNIT)
typedef unsigned int USItype __attribute__ ((mode (SI)));
typedef int DItype __attribute__ ((mode (DI)));
typedef int word_type __attribute__ ((mode (__word__)));
typedef unsigned int UDItype __attribute__ ((mode (DI)));
#ifdef __ARMEB__ #ifdef __ARMEB__
struct DIstruct {SItype high, low;}; struct DIstruct {s32 high, low;};
#else #else
struct DIstruct {SItype low, high;}; struct DIstruct {s32 low, high;};
#endif #endif
typedef union typedef union
{ {
struct DIstruct s; struct DIstruct s;
DItype ll; s64 ll;
} DIunion; } DIunion;
...@@ -26,18 +26,18 @@ ...@@ -26,18 +26,18 @@
#define __BITS4 (SI_TYPE_SIZE / 4) #define __BITS4 (SI_TYPE_SIZE / 4)
#define __ll_B (1L << (SI_TYPE_SIZE / 2)) #define __ll_B (1L << (SI_TYPE_SIZE / 2))
#define __ll_lowpart(t) ((USItype) (t) % __ll_B) #define __ll_lowpart(t) ((u32) (t) % __ll_B)
#define __ll_highpart(t) ((USItype) (t) / __ll_B) #define __ll_highpart(t) ((u32) (t) / __ll_B)
/* Define auxiliary asm macros. /* Define auxiliary asm macros.
1) umul_ppmm(high_prod, low_prod, multipler, multiplicand) 1) umul_ppmm(high_prod, low_prod, multipler, multiplicand)
multiplies two USItype integers MULTIPLER and MULTIPLICAND, multiplies two u32 integers MULTIPLER and MULTIPLICAND,
and generates a two-part USItype product in HIGH_PROD and and generates a two-part u32 product in HIGH_PROD and
LOW_PROD. LOW_PROD.
2) __umulsidi3(a,b) multiplies two USItype integers A and B, 2) __umulsidi3(a,b) multiplies two u32 integers A and B,
and returns a UDItype product. This is just a variant of umul_ppmm. and returns a u64 product. This is just a variant of umul_ppmm.
3) udiv_qrnnd(quotient, remainder, high_numerator, low_numerator, 3) udiv_qrnnd(quotient, remainder, high_numerator, low_numerator,
denominator) divides a two-word unsigned integer, composed by the denominator) divides a two-word unsigned integer, composed by the
...@@ -77,23 +77,23 @@ ...@@ -77,23 +77,23 @@
#define add_ssaaaa(sh, sl, ah, al, bh, bl) \ #define add_ssaaaa(sh, sl, ah, al, bh, bl) \
__asm__ ("adds %1, %4, %5 \n\ __asm__ ("adds %1, %4, %5 \n\
adc %0, %2, %3" \ adc %0, %2, %3" \
: "=r" ((USItype) (sh)), \ : "=r" ((u32) (sh)), \
"=&r" ((USItype) (sl)) \ "=&r" ((u32) (sl)) \
: "%r" ((USItype) (ah)), \ : "%r" ((u32) (ah)), \
"rI" ((USItype) (bh)), \ "rI" ((u32) (bh)), \
"%r" ((USItype) (al)), \ "%r" ((u32) (al)), \
"rI" ((USItype) (bl))) "rI" ((u32) (bl)))
#define sub_ddmmss(sh, sl, ah, al, bh, bl) \ #define sub_ddmmss(sh, sl, ah, al, bh, bl) \
__asm__ ("subs %1, %4, %5 \n\ __asm__ ("subs %1, %4, %5 \n\
sbc %0, %2, %3" \ sbc %0, %2, %3" \
: "=r" ((USItype) (sh)), \ : "=r" ((u32) (sh)), \
"=&r" ((USItype) (sl)) \ "=&r" ((u32) (sl)) \
: "r" ((USItype) (ah)), \ : "r" ((u32) (ah)), \
"rI" ((USItype) (bh)), \ "rI" ((u32) (bh)), \
"r" ((USItype) (al)), \ "r" ((u32) (al)), \
"rI" ((USItype) (bl))) "rI" ((u32) (bl)))
#define umul_ppmm(xh, xl, a, b) \ #define umul_ppmm(xh, xl, a, b) \
{register USItype __t0, __t1, __t2; \ {register u32 __t0, __t1, __t2; \
__asm__ ("%@ Inlined umul_ppmm \n\ __asm__ ("%@ Inlined umul_ppmm \n\
mov %2, %5, lsr #16 \n\ mov %2, %5, lsr #16 \n\
mov %0, %6, lsr #16 \n\ mov %0, %6, lsr #16 \n\
...@@ -107,11 +107,11 @@ ...@@ -107,11 +107,11 @@
addcs %0, %0, #65536 \n\ addcs %0, %0, #65536 \n\
adds %1, %1, %3, lsl #16 \n\ adds %1, %1, %3, lsl #16 \n\
adc %0, %0, %3, lsr #16" \ adc %0, %0, %3, lsr #16" \
: "=&r" ((USItype) (xh)), \ : "=&r" ((u32) (xh)), \
"=r" ((USItype) (xl)), \ "=r" ((u32) (xl)), \
"=&r" (__t0), "=&r" (__t1), "=r" (__t2) \ "=&r" (__t0), "=&r" (__t1), "=r" (__t2) \
: "r" ((USItype) (a)), \ : "r" ((u32) (a)), \
"r" ((USItype) (b)));} "r" ((u32) (b)));}
#define UMUL_TIME 20 #define UMUL_TIME 20
#define UDIV_TIME 100 #define UDIV_TIME 100
#endif /* __arm__ */ #endif /* __arm__ */
...@@ -123,14 +123,14 @@ ...@@ -123,14 +123,14 @@
#define __udiv_qrnnd_c(q, r, n1, n0, d) \ #define __udiv_qrnnd_c(q, r, n1, n0, d) \
do { \ do { \
USItype __d1, __d0, __q1, __q0; \ u32 __d1, __d0, __q1, __q0; \
USItype __r1, __r0, __m; \ u32 __r1, __r0, __m; \
__d1 = __ll_highpart (d); \ __d1 = __ll_highpart (d); \
__d0 = __ll_lowpart (d); \ __d0 = __ll_lowpart (d); \
\ \
__r1 = (n1) % __d1; \ __r1 = (n1) % __d1; \
__q1 = (n1) / __d1; \ __q1 = (n1) / __d1; \
__m = (USItype) __q1 * __d0; \ __m = (u32) __q1 * __d0; \
__r1 = __r1 * __ll_B | __ll_highpart (n0); \ __r1 = __r1 * __ll_B | __ll_highpart (n0); \
if (__r1 < __m) \ if (__r1 < __m) \
{ \ { \
...@@ -143,7 +143,7 @@ ...@@ -143,7 +143,7 @@
\ \
__r0 = __r1 % __d1; \ __r0 = __r1 % __d1; \
__q0 = __r1 / __d1; \ __q0 = __r1 / __d1; \
__m = (USItype) __q0 * __d0; \ __m = (u32) __q0 * __d0; \
__r0 = __r0 * __ll_B | __ll_lowpart (n0); \ __r0 = __r0 * __ll_B | __ll_lowpart (n0); \
if (__r0 < __m) \ if (__r0 < __m) \
{ \ { \
...@@ -154,7 +154,7 @@ ...@@ -154,7 +154,7 @@
} \ } \
__r0 -= __m; \ __r0 -= __m; \
\ \
(q) = (USItype) __q1 * __ll_B | __q0; \ (q) = (u32) __q1 * __ll_B | __q0; \
(r) = __r0; \ (r) = __r0; \
} while (0) } while (0)
...@@ -163,14 +163,14 @@ ...@@ -163,14 +163,14 @@
#define count_leading_zeros(count, x) \ #define count_leading_zeros(count, x) \
do { \ do { \
USItype __xr = (x); \ u32 __xr = (x); \
USItype __a; \ u32 __a; \
\ \
if (SI_TYPE_SIZE <= 32) \ if (SI_TYPE_SIZE <= 32) \
{ \ { \
__a = __xr < ((USItype)1<<2*__BITS4) \ __a = __xr < ((u32)1<<2*__BITS4) \
? (__xr < ((USItype)1<<__BITS4) ? 0 : __BITS4) \ ? (__xr < ((u32)1<<__BITS4) ? 0 : __BITS4) \
: (__xr < ((USItype)1<<3*__BITS4) ? 2*__BITS4 : 3*__BITS4); \ : (__xr < ((u32)1<<3*__BITS4) ? 2*__BITS4 : 3*__BITS4); \
} \ } \
else \ else \
{ \ { \
......
...@@ -31,11 +31,11 @@ Boston, MA 02111-1307, USA. */ ...@@ -31,11 +31,11 @@ Boston, MA 02111-1307, USA. */
#include "gcclib.h" #include "gcclib.h"
DItype s64
__lshrdi3 (DItype u, word_type b) __lshrdi3 (s64 u, int b)
{ {
DIunion w; DIunion w;
word_type bm; int bm;
DIunion uu; DIunion uu;
if (b == 0) if (b == 0)
...@@ -43,17 +43,17 @@ __lshrdi3 (DItype u, word_type b) ...@@ -43,17 +43,17 @@ __lshrdi3 (DItype u, word_type b)
uu.ll = u; uu.ll = u;
bm = (sizeof (SItype) * BITS_PER_UNIT) - b; bm = (sizeof (s32) * BITS_PER_UNIT) - b;
if (bm <= 0) if (bm <= 0)
{ {
w.s.high = 0; w.s.high = 0;
w.s.low = (USItype)uu.s.high >> -bm; w.s.low = (u32)uu.s.high >> -bm;
} }
else else
{ {
USItype carries = (USItype)uu.s.high << bm; u32 carries = (u32)uu.s.high << bm;
w.s.high = (USItype)uu.s.high >> b; w.s.high = (u32)uu.s.high >> b;
w.s.low = ((USItype)uu.s.low >> b) | carries; w.s.low = ((u32)uu.s.low >> b) | carries;
} }
return w.ll; return w.ll;
......
...@@ -32,7 +32,7 @@ Boston, MA 02111-1307, USA. */ ...@@ -32,7 +32,7 @@ Boston, MA 02111-1307, USA. */
#include "gcclib.h" #include "gcclib.h"
#define umul_ppmm(xh, xl, a, b) \ #define umul_ppmm(xh, xl, a, b) \
{register USItype __t0, __t1, __t2; \ {register u32 __t0, __t1, __t2; \
__asm__ ("%@ Inlined umul_ppmm \n\ __asm__ ("%@ Inlined umul_ppmm \n\
mov %2, %5, lsr #16 \n\ mov %2, %5, lsr #16 \n\
mov %0, %6, lsr #16 \n\ mov %0, %6, lsr #16 \n\
...@@ -46,11 +46,11 @@ Boston, MA 02111-1307, USA. */ ...@@ -46,11 +46,11 @@ Boston, MA 02111-1307, USA. */
addcs %0, %0, #65536 \n\ addcs %0, %0, #65536 \n\
adds %1, %1, %3, lsl #16 \n\ adds %1, %1, %3, lsl #16 \n\
adc %0, %0, %3, lsr #16" \ adc %0, %0, %3, lsr #16" \
: "=&r" ((USItype) (xh)), \ : "=&r" ((u32) (xh)), \
"=r" ((USItype) (xl)), \ "=r" ((u32) (xl)), \
"=&r" (__t0), "=&r" (__t1), "=r" (__t2) \ "=&r" (__t0), "=&r" (__t1), "=r" (__t2) \
: "r" ((USItype) (a)), \ : "r" ((u32) (a)), \
"r" ((USItype) (b)));} "r" ((u32) (b)));}
#define __umulsidi3(u, v) \ #define __umulsidi3(u, v) \
...@@ -59,8 +59,8 @@ Boston, MA 02111-1307, USA. */ ...@@ -59,8 +59,8 @@ Boston, MA 02111-1307, USA. */
__w.ll; }) __w.ll; })
DItype s64
__muldi3 (DItype u, DItype v) __muldi3 (s64 u, s64 v)
{ {
DIunion w; DIunion w;
DIunion uu, vv; DIunion uu, vv;
...@@ -69,8 +69,8 @@ __muldi3 (DItype u, DItype v) ...@@ -69,8 +69,8 @@ __muldi3 (DItype u, DItype v)
vv.ll = v; vv.ll = v;
w.ll = __umulsidi3 (uu.s.low, vv.s.low); w.ll = __umulsidi3 (uu.s.low, vv.s.low);
w.s.high += ((USItype) uu.s.low * (USItype) vv.s.high w.s.high += ((u32) uu.s.low * (u32) vv.s.high
+ (USItype) uu.s.high * (USItype) vv.s.low); + (u32) uu.s.high * (u32) vv.s.low);
return w.ll; return w.ll;
} }
......
...@@ -31,20 +31,20 @@ Boston, MA 02111-1307, USA. */ ...@@ -31,20 +31,20 @@ Boston, MA 02111-1307, USA. */
#include "gcclib.h" #include "gcclib.h"
word_type int
__ucmpdi2 (DItype a, DItype b) __ucmpdi2 (s64 a, s64 b)
{ {
DIunion au, bu; DIunion au, bu;
au.ll = a, bu.ll = b; au.ll = a, bu.ll = b;
if ((USItype) au.s.high < (USItype) bu.s.high) if ((u32) au.s.high < (u32) bu.s.high)
return 0; return 0;
else if ((USItype) au.s.high > (USItype) bu.s.high) else if ((u32) au.s.high > (u32) bu.s.high)
return 2; return 2;
if ((USItype) au.s.low < (USItype) bu.s.low) if ((u32) au.s.low < (u32) bu.s.low)
return 0; return 0;
else if ((USItype) au.s.low > (USItype) bu.s.low) else if ((u32) au.s.low > (u32) bu.s.low)
return 2; return 2;
return 1; return 1;
} }
......
...@@ -32,7 +32,7 @@ Boston, MA 02111-1307, USA. */ ...@@ -32,7 +32,7 @@ Boston, MA 02111-1307, USA. */
#include "gcclib.h" #include "gcclib.h"
#include "longlong.h" #include "longlong.h"
static const UQItype __clz_tab[] = static const u8 __clz_tab[] =
{ {
0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5, 0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6, 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
...@@ -44,15 +44,15 @@ static const UQItype __clz_tab[] = ...@@ -44,15 +44,15 @@ static const UQItype __clz_tab[] =
8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
}; };
UDItype u64
__udivmoddi4 (UDItype n, UDItype d, UDItype *rp) __udivmoddi4 (u64 n, u64 d, u64 *rp)
{ {
DIunion ww; DIunion ww;
DIunion nn, dd; DIunion nn, dd;
DIunion rr; DIunion rr;
USItype d0, d1, n0, n1, n2; u32 d0, d1, n0, n1, n2;
USItype q0, q1; u32 q0, q1;
USItype b, bm; u32 b, bm;
nn.ll = n; nn.ll = n;
dd.ll = d; dd.ll = d;
...@@ -185,7 +185,7 @@ __udivmoddi4 (UDItype n, UDItype d, UDItype *rp) ...@@ -185,7 +185,7 @@ __udivmoddi4 (UDItype n, UDItype d, UDItype *rp)
} }
else else
{ {
USItype m1, m0; u32 m1, m0;
/* Normalize. */ /* Normalize. */
b = SI_TYPE_SIZE - bm; b = SI_TYPE_SIZE - bm;
...@@ -224,16 +224,16 @@ __udivmoddi4 (UDItype n, UDItype d, UDItype *rp) ...@@ -224,16 +224,16 @@ __udivmoddi4 (UDItype n, UDItype d, UDItype *rp)
return ww.ll; return ww.ll;
} }
UDItype u64
__udivdi3 (UDItype n, UDItype d) __udivdi3 (u64 n, u64 d)
{ {
return __udivmoddi4 (n, d, (UDItype *) 0); return __udivmoddi4 (n, d, (u64 *) 0);
} }
UDItype u64
__umoddi3 (UDItype u, UDItype v) __umoddi3 (u64 u, u64 v)
{ {
UDItype w; u64 w;
(void) __udivmoddi4 (u ,v, &w); (void) __udivmoddi4 (u ,v, &w);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment