Skip to contentSkip to conversation

mips: implement __udivdi3

PATCH New Daniel Schwierzeck 1 participant 1 message Nov 6, 2023 MIPS

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mips: implement __udivdi3

From: Linus Walleij <[email protected]>

Squashfs wasn't compiling because the lldiv() directives turn into __udivdi3 and we are using private libgcc.

After this squashfs compiles for MIPS.

---
Linus, this is the updated and optimized version of your initial patch. Sorry for the long delay ;)

 arch/mips/lib/Makefile  |  2 +-
 arch/mips/lib/udivdi3.c | 17 +++++++++++++++++
 2 files changed, 18 insertions(+), 1 deletion(-)
 create mode 100644 arch/mips/lib/udivdi3.c
arch/mips/lib/Makefile +1 -1
index 9ee1fcb5c7..1621cc9a1f 100644
@@ -14,4 +14,4 @@ obj-$(CONFIG_CMD_BOOTM) += bootm.o
 obj-$(CONFIG_CMD_GO) += boot.o
 obj-$(CONFIG_SPL_BUILD) += spl.o
 
-lib-$(CONFIG_USE_PRIVATE_LIBGCC) += ashldi3.o ashrdi3.o lshrdi3.o
+lib-$(CONFIG_USE_PRIVATE_LIBGCC) += ashldi3.o ashrdi3.o lshrdi3.o udivdi3.o
arch/mips/lib/udivdi3.c new file +17 -0
new file mode 100644
index 0000000000..4d780117cf
@@ -0,0 +1,17 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+
+#include "libgcc.h"
+
+#if BITS_PER_LONG == 32
+
+#include <div64.h>
+
+long long __udivdi3(long long u, word_type b)
+{
+	long long ret = u;
+
+	__div64_32(&ret, b);
+	return ret;
+}
+
+#endif /* BITS_PER_LONG == 32 */
Signature · 1 line
2.41.0