1*b1e83836Smrg /* Copyright (C) 2000-2022 Free Software Foundation, Inc.
248fb7bfaSmrg
348fb7bfaSmrg This file is part of GCC.
448fb7bfaSmrg
548fb7bfaSmrg GCC is free software; you can redistribute it and/or modify it under
648fb7bfaSmrg the terms of the GNU General Public License as published by the Free
748fb7bfaSmrg Software Foundation; either version 3, or (at your option) any later
848fb7bfaSmrg version.
948fb7bfaSmrg
1048fb7bfaSmrg GCC is distributed in the hope that it will be useful, but WITHOUT ANY
1148fb7bfaSmrg WARRANTY; without even the implied warranty of MERCHANTABILITY or
1248fb7bfaSmrg FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
1348fb7bfaSmrg for more details.
1448fb7bfaSmrg
1548fb7bfaSmrg Under Section 7 of GPL version 3, you are granted additional
1648fb7bfaSmrg permissions described in the GCC Runtime Library Exception, version
1748fb7bfaSmrg 3.1, as published by the Free Software Foundation.
1848fb7bfaSmrg
1948fb7bfaSmrg You should have received a copy of the GNU General Public License and
2048fb7bfaSmrg a copy of the GCC Runtime Library Exception along with this program;
2148fb7bfaSmrg see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
2248fb7bfaSmrg <http://www.gnu.org/licenses/>. */
2348fb7bfaSmrg
24181254a7Smrg extern unsigned long __udivmodsi4(unsigned long num, unsigned long den,
25181254a7Smrg int modwanted);
2648fb7bfaSmrg
2748fb7bfaSmrg long
__divsi3(long a,long b)2848fb7bfaSmrg __divsi3 (long a, long b)
2948fb7bfaSmrg {
3048fb7bfaSmrg int neg = 0;
3148fb7bfaSmrg long res;
3248fb7bfaSmrg
3348fb7bfaSmrg if (a < 0)
3448fb7bfaSmrg {
3548fb7bfaSmrg a = -a;
3648fb7bfaSmrg neg = !neg;
3748fb7bfaSmrg }
3848fb7bfaSmrg
3948fb7bfaSmrg if (b < 0)
4048fb7bfaSmrg {
4148fb7bfaSmrg b = -b;
4248fb7bfaSmrg neg = !neg;
4348fb7bfaSmrg }
4448fb7bfaSmrg
45181254a7Smrg res = __udivmodsi4 (a, b, 0);
4648fb7bfaSmrg
4748fb7bfaSmrg if (neg)
4848fb7bfaSmrg res = -res;
4948fb7bfaSmrg
5048fb7bfaSmrg return res;
5148fb7bfaSmrg }
5248fb7bfaSmrg
5348fb7bfaSmrg long
__modsi3(long a,long b)5448fb7bfaSmrg __modsi3 (long a, long b)
5548fb7bfaSmrg {
5648fb7bfaSmrg int neg = 0;
5748fb7bfaSmrg long res;
5848fb7bfaSmrg
5948fb7bfaSmrg if (a < 0)
6048fb7bfaSmrg {
6148fb7bfaSmrg a = -a;
6248fb7bfaSmrg neg = 1;
6348fb7bfaSmrg }
6448fb7bfaSmrg
6548fb7bfaSmrg if (b < 0)
6648fb7bfaSmrg b = -b;
6748fb7bfaSmrg
68181254a7Smrg res = __udivmodsi4 (a, b, 1);
6948fb7bfaSmrg
7048fb7bfaSmrg if (neg)
7148fb7bfaSmrg res = -res;
7248fb7bfaSmrg
7348fb7bfaSmrg return res;
7448fb7bfaSmrg }
75