aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2004-07-07 19:09:17 +0000
committerH. Peter Anvin <hpa@zytor.com>2004-07-07 19:09:17 +0000
commit8e3478d721b067b07f86f06943407dc83c56f128 (patch)
treef6805883179ebe65b1da7d67f4f751b7d725e235
parent1d38b22c363a9454aef50d20ae9aece2370e9695 (diff)
downloadklibc-8e3478d721b067b07f86f06943407dc83c56f128.tar.gz
Fix __negdi2 on crisklibc-0.150
-rw-r--r--klibc/arch/cris/__negdi2.S25
-rw-r--r--klibc/libgcc/__negdi2.c24
2 files changed, 25 insertions, 24 deletions
diff --git a/klibc/arch/cris/__negdi2.S b/klibc/arch/cris/__negdi2.S
new file mode 100644
index 0000000000000..3cca9edfa8a6a
--- /dev/null
+++ b/klibc/arch/cris/__negdi2.S
@@ -0,0 +1,25 @@
+/*
+ * arch/cris/__negdi2.c
+ */
+
+/*
+ * In 2's complement arithmetric, -x == (~x + 1), so
+ * -{h,l} = (~{h,l} + {0,1)
+ * -{h,l} = {~h,~l} + {0,1}
+ * -{h,l} = {~h + cy, ~l + 1}
+ * ... where cy = (l == 0)
+ * -{h,l} = {~h + cy, -l}
+ */
+
+ .text
+ .balign 4
+ .type __negdi2,@function
+ .globl __negdi2
+__negdi2:
+ neg.d $r10,$r10
+ seq $r12
+ not $r11
+ ret
+ add.d $r12,$r11
+
+ .size __negdi2, .-__negdi2
diff --git a/klibc/libgcc/__negdi2.c b/klibc/libgcc/__negdi2.c
deleted file mode 100644
index 60f2ed3620aa6..0000000000000
--- a/klibc/libgcc/__negdi2.c
+++ /dev/null
@@ -1,24 +0,0 @@
-#include <stdint.h>
-#include <stddef.h>
-
-struct DWstruct {int32_t low, high;};
-
-typedef union
-{
- struct DWstruct s;
- int64_t ll;
-} DWunion;
-
-
-__negdi2 (int64_t u)
-{
- DWunion w;
- DWunion uu;
-
- uu.ll = u;
-
- w.s.low = -uu.s.low;
- w.s.high = -uu.s.high - ((uint32_t) w.s.low > 0);
-
- return w.ll;
-}