summaryrefslogtreecommitdiffstats
path: root/usr/klibc/libgcc/__divsi3.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr/klibc/libgcc/__divsi3.c')
-rw-r--r--usr/klibc/libgcc/__divsi3.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/usr/klibc/libgcc/__divsi3.c b/usr/klibc/libgcc/__divsi3.c
new file mode 100644
index 0000000..35420f5
--- /dev/null
+++ b/usr/klibc/libgcc/__divsi3.c
@@ -0,0 +1,29 @@
+/*
+ * libgcc/__divsi3.c
+ */
+
+#include <stdint.h>
+#include <stddef.h>
+
+extern uint32_t __udivmodsi4(uint32_t num, uint32_t den, uint32_t * rem);
+
+int32_t __divsi3(int32_t num, int32_t den)
+{
+ int minus = 0;
+ int32_t v;
+
+ if (num < 0) {
+ num = -num;
+ minus = 1;
+ }
+ if (den < 0) {
+ den = -den;
+ minus ^= 1;
+ }
+
+ v = __udivmodsi4(num, den, NULL);
+ if (minus)
+ v = -v;
+
+ return v;
+}