]>
git.ipfire.org Git - thirdparty/u-boot.git/blob - arch/arc/lib/libgcc2.c
1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (C) 1989-2013 Free Software Foundation, Inc.
9 __ashldi3(DWtype u
, shift_count_type b
)
14 const DWunion uu
= {.ll
= u
};
15 const shift_count_type bm
= W_TYPE_SIZE
- b
;
20 w
.s
.high
= (UWtype
)uu
.s
.low
<< -bm
;
22 const UWtype carries
= (UWtype
) uu
.s
.low
>> bm
;
24 w
.s
.low
= (UWtype
)uu
.s
.low
<< b
;
25 w
.s
.high
= ((UWtype
)uu
.s
.high
<< b
) | carries
;
32 __ashrdi3(DWtype u
, shift_count_type b
)
37 const DWunion uu
= {.ll
= u
};
38 const shift_count_type bm
= W_TYPE_SIZE
- b
;
42 /* w.s.high = 1..1 or 0..0 */
43 w
.s
.high
= uu
.s
.high
>> (W_TYPE_SIZE
- 1);
44 w
.s
.low
= uu
.s
.high
>> -bm
;
46 const UWtype carries
= (UWtype
) uu
.s
.high
<< bm
;
48 w
.s
.high
= uu
.s
.high
>> b
;
49 w
.s
.low
= ((UWtype
)uu
.s
.low
>> b
) | carries
;
56 __lshrdi3(DWtype u
, shift_count_type b
)
61 const DWunion uu
= {.ll
= u
};
62 const shift_count_type bm
= W_TYPE_SIZE
- b
;
67 w
.s
.low
= (UWtype
)uu
.s
.high
>> -bm
;
69 const UWtype carries
= (UWtype
)uu
.s
.high
<< bm
;
71 w
.s
.high
= (UWtype
)uu
.s
.high
>> b
;
72 w
.s
.low
= ((UWtype
)uu
.s
.low
>> b
) | carries
;
79 udivmodsi4(unsigned long num
, unsigned long den
, int modwanted
)
81 unsigned long bit
= 1;
82 unsigned long res
= 0;
84 while (den
< num
&& bit
&& !(den
& (1L<<31))) {
105 __divsi3(long a
, long b
)
120 res
= udivmodsi4(a
, b
, 0);
129 __modsi3(long a
, long b
)
142 res
= udivmodsi4(a
, b
, 1);
151 __udivsi3(long a
, long b
)
153 return udivmodsi4(a
, b
, 0);
157 __umodsi3(long a
, long b
)
159 return udivmodsi4(a
, b
, 1);