summaryrefslogtreecommitdiffstats
path: root/gcc/config/divmod.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/config/divmod.c')
-rw-r--r--gcc/config/divmod.c50
1 files changed, 50 insertions, 0 deletions
diff --git a/gcc/config/divmod.c b/gcc/config/divmod.c
new file mode 100644
index 00000000000..6faa09102b5
--- /dev/null
+++ b/gcc/config/divmod.c
@@ -0,0 +1,50 @@
+long udivmodsi4 ();
+
+long
+__divsi3 (long a, long b)
+{
+ int neg = 0;
+ long res;
+
+ if (a < 0)
+ {
+ a = -a;
+ neg = !neg;
+ }
+
+ if (b < 0)
+ {
+ b = -b;
+ neg = !neg;
+ }
+
+ res = udivmodsi4 (a, b, 0);
+
+ if (neg)
+ res = -res;
+
+ return res;
+}
+
+long
+__modsi3 (long a, long b)
+{
+ int neg = 0;
+ long res;
+
+ if (a < 0)
+ {
+ a = -a;
+ neg = 1;
+ }
+
+ if (b < 0)
+ b = -b;
+
+ res = udivmodsi4 (a, b, 1);
+
+ if (neg)
+ res = -res;
+
+ return res;
+}
OpenPOWER on IntegriCloud