summaryrefslogtreecommitdiffstats
path: root/lib/ashrdi3.c
diff options
context:
space:
mode:
authorPalmer Dabbelt <palmer@dabbelt.com>2017-05-23 10:28:26 -0700
committerPalmer Dabbelt <palmer@dabbelt.com>2017-09-25 15:50:57 -0700
commitb35cd9884fa5d81c9d5e7f57c9d03264ae2bd835 (patch)
tree850f9dc5181db9eb022fefa84ba6e9425fb0bbf3 /lib/ashrdi3.c
parentc98cfe4aa64d3af43323d0d15c81172caba13ce2 (diff)
downloadlinux-stable-b35cd9884fa5d81c9d5e7f57c9d03264ae2bd835.tar.gz
linux-stable-b35cd9884fa5d81c9d5e7f57c9d03264ae2bd835.tar.bz2
linux-stable-b35cd9884fa5d81c9d5e7f57c9d03264ae2bd835.zip
lib: Add shared copies of some GCC library routines
Many ports (m32r, microblaze, mips, parisc, score, and sparc) use functionally identical copies of various GCC library routine files, which came up as we were submitting the RISC-V port (which also uses some of these). This patch adds a new copy of these library routine files, which are functionally identical to the various other copies. These are availiable via Kconfig as CONFIG_GENERIC_$ROUTINE, which currently isn't used anywhere. Reviewed-by: Geert Uytterhoeven <geert@linux-m68k.org> Signed-off-by: Palmer Dabbelt <palmer@dabbelt.com>
Diffstat (limited to 'lib/ashrdi3.c')
-rw-r--r--lib/ashrdi3.c46
1 files changed, 46 insertions, 0 deletions
diff --git a/lib/ashrdi3.c b/lib/ashrdi3.c
new file mode 100644
index 000000000000..2e67c97ac65a
--- /dev/null
+++ b/lib/ashrdi3.c
@@ -0,0 +1,46 @@
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see the file COPYING, or write
+ * to the Free Software Foundation, Inc.
+ */
+
+#include <linux/export.h>
+
+#include <lib/libgcc.h>
+
+long long notrace __ashrdi3(long long u, word_type b)
+{
+ DWunion uu, w;
+ word_type bm;
+
+ if (b == 0)
+ return u;
+
+ uu.ll = u;
+ bm = 32 - b;
+
+ if (bm <= 0) {
+ /* w.s.high = 1..1 or 0..0 */
+ w.s.high =
+ uu.s.high >> 31;
+ w.s.low = uu.s.high >> -bm;
+ } else {
+ const unsigned int carries = (unsigned int) uu.s.high << bm;
+
+ w.s.high = uu.s.high >> b;
+ w.s.low = ((unsigned int) uu.s.low >> b) | carries;
+ }
+
+ return w.ll;
+}
+EXPORT_SYMBOL(__ashrdi3);