blob: a978f7afe6027d5bc5fab8414ba618ab1ad69eb1 [file] [log] [blame]
lh9ed821d2023-04-07 01:36:19 -07001
2extern unsigned long udivmodsi4(unsigned long num, unsigned long den, int modwanted);
3
4
5long
6__divsi3 (long a, long b)
7{
8 int neg = 0;
9 long res;
10
11 if (a < 0)
12 {
13 a = -a;
14 neg = !neg;
15 }
16
17 if (b < 0)
18 {
19 b = -b;
20 neg = !neg;
21 }
22
23 res = udivmodsi4 (a, b, 0);
24
25 if (neg)
26 res = -res;
27
28 return res;
29}
30
31long
32__modsi3 (long a, long b)
33{
34 int neg = 0;
35 long res;
36
37 if (a < 0)
38 {
39 a = -a;
40 neg = 1;
41 }
42
43 if (b < 0)
44 b = -b;
45
46 res = udivmodsi4 (a, b, 1);
47
48 if (neg)
49 res = -res;
50
51 return res;
52}