summaryrefslogtreecommitdiffstats
path: root/lib/lshrdi3.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/lshrdi3.c
parentc98cfe4aa64d3af43323d0d15c81172caba13ce2 (diff)
downloadtalos-obmc-linux-b35cd9884fa5d81c9d5e7f57c9d03264ae2bd835.tar.gz
talos-obmc-linux-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/lshrdi3.c')
-rw-r--r--lib/lshrdi3.c45
1 files changed, 45 insertions, 0 deletions
diff --git a/lib/lshrdi3.c b/lib/lshrdi3.c
new file mode 100644
index 000000000000..8e845f4bb65f
--- /dev/null
+++ b/lib/lshrdi3.c
@@ -0,0 +1,45 @@
+/*
+ * lib/lshrdi3.c
+ *
+ * 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/module.h>
+#include <lib/libgcc.h>
+
+long long notrace __lshrdi3(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 = 0;
+ w.s.low = (unsigned int) uu.s.high >> -bm;
+ } else {
+ const unsigned int carries = (unsigned int) uu.s.high << bm;
+
+ w.s.high = (unsigned int) uu.s.high >> b;
+ w.s.low = ((unsigned int) uu.s.low >> b) | carries;
+ }
+
+ return w.ll;
+}
+EXPORT_SYMBOL(__lshrdi3);
OpenPOWER on IntegriCloud