No empty .Rs/.Re
[netbsd-mini2440.git] / gnu / dist / gcc4 / gcc / config / m32c / m32c-lib2.c
blob492e6c8362c7e53331d34667e71c1919c56cf4e6
1 /* libgcc routines for R8C/M16C/M32C
2 Copyright (C) 2005
3 Free Software Foundation, Inc.
4 Contributed by Red Hat.
6 This file is part of GCC.
8 GCC is free software; you can redistribute it and/or modify it
9 under the terms of the GNU General Public License as published
10 by the Free Software Foundation; either version 2, or (at your
11 option) any later version.
13 In addition to the permissions in the GNU General Public License,
14 the Free Software Foundation gives you unlimited permission to link
15 the compiled version of this file into combinations with other
16 programs, and to distribute those combinations without any
17 restriction coming from the use of this file. (The General Public
18 License restrictions do apply in other respects; for example, they
19 cover modification of the file, and distribution when not linked
20 into a combine executable.)
22 GCC is distributed in the hope that it will be useful, but WITHOUT
23 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
24 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
25 License for more details.
27 You should have received a copy of the GNU General Public License
28 along with GCC; see the file COPYING. If not, write to the Free
29 Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
30 02110-1301, USA. */
32 typedef int HItype __attribute__ ((mode (HI)));
33 typedef unsigned int UHItype __attribute__ ((mode (HI)));
34 typedef int SItype __attribute__ ((mode (SI)));
35 typedef unsigned int USItype __attribute__ ((mode (SI)));
37 typedef int word_type __attribute__ ((mode (__word__)));
39 USItype udivmodsi4 (USItype num, USItype den, word_type modwanted);
40 SItype __divsi3 (SItype a, SItype b);
41 SItype __modsi3 (SItype a, SItype b);
42 SItype __udivsi3 (SItype a, SItype b);
43 SItype __umodsi3 (SItype a, SItype b);
45 USItype
46 udivmodsi4 (USItype num, USItype den, word_type modwanted)
48 USItype bit = 1;
49 USItype res = 0;
51 while (den < num && bit && !(den & (1L << 31)))
53 den <<= 1;
54 bit <<= 1;
56 while (bit)
58 if (num >= den)
60 num -= den;
61 res |= bit;
63 bit >>= 1;
64 den >>= 1;
66 if (modwanted)
67 return num;
68 return res;
73 SItype
74 __divsi3 (SItype a, SItype b)
76 word_type neg = 0;
77 SItype res;
79 if (a < 0)
81 a = -a;
82 neg = !neg;
85 if (b < 0)
87 b = -b;
88 neg = !neg;
91 res = udivmodsi4 (a, b, 0);
93 if (neg)
94 res = -res;
96 return res;
101 SItype
102 __modsi3 (SItype a, SItype b)
104 word_type neg = 0;
105 SItype res;
107 if (a < 0)
109 a = -a;
110 neg = 1;
113 if (b < 0)
114 b = -b;
116 res = udivmodsi4 (a, b, 1);
118 if (neg)
119 res = -res;
121 return res;
127 SItype
128 __udivsi3 (SItype a, SItype b)
130 return udivmodsi4 (a, b, 0);
135 SItype
136 __umodsi3 (SItype a, SItype b)
138 return udivmodsi4 (a, b, 1);