1From af6adb3f5f05be4faa88a5aa83296c388c8085e7 Mon Sep 17 00:00:00 2001
2From: "Yann E. MORIN" <yann.morin.1998@free.fr>
3Date: Wed, 8 Feb 2023 12:30:10 +0100
4Subject: [PATCH] configure: fix build on mips
5
6This patch is a historical baggage that Buildroot has carried for ages
7(since 2006), and the reason for it are notentirely clear.
8
9Since dmalloc is pretty tricky, and as this patch has not been
10identified as causing issues, we keep it; we just add the configure.ac
11patchlet to match the one in configure.
12
13As for the title, the original patch was named dmalloc-mips.patch, so
14presumably it fixes some mips issue; let's title the commit that way.
15
16[Fabrice: Updated for 5.6.5]
17Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
18[yann.morin.1998@free.fr: make it a git-formatted patch]
19Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
20---
21 configure    |  4 ++--
22 configure.ac |  2 +-
23 return.h     | 16 +++-------------
24 3 files changed, 6 insertions(+), 16 deletions(-)
25
26diff --git a/configure b/configure
27index d52a1e8..c18dfb2 100755
28--- a/configure
29+++ b/configure
30@@ -5413,8 +5413,8 @@ fi
31 { $as_echo "$as_me:${as_lineno-$LINENO}: checking return.h macros work" >&5
32 $as_echo_n "checking return.h macros work... " >&6; }
33 if test "$cross_compiling" = yes; then :
34-   $as_echo "#define RETURN_MACROS_WORK 0" >>confdefs.h
35- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
36+   $as_echo "#define RETURN_MACROS_WORK 1" >>confdefs.h
37+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: assume yes (cross-compiling)" >&5
38 $as_echo "no" >&6; }
39
40 else
41diff --git a/configure.ac b/configure.ac
42index a5295f1..9740fdc 100644
43--- a/configure.ac
44+++ b/configure.ac
45@@ -705,7 +705,7 @@ int main()
46 ])],
47 [ AC_DEFINE(RETURN_MACROS_WORK, 1) AC_MSG_RESULT([yes]) ],
48 [ AC_DEFINE(RETURN_MACROS_WORK, 0) AC_MSG_RESULT([no]) ],
49-[ AC_DEFINE(RETURN_MACROS_WORK, 0) AC_MSG_RESULT([no]) ]
50+[ AC_DEFINE(RETURN_MACROS_WORK, 1) AC_MSG_RESULT([assume yes (cross-compiling)]) ]
51 )
52
53 ##############################################################################
54diff --git a/return.h b/return.h
55index 9d3f5f1..d916c7a 100644
56--- a/return.h
57+++ b/return.h
58@@ -117,26 +117,16 @@
59 /*************************************/
60
61 /*
62- * For DEC Mips machines running Ultrix
63+ * For Mips machines running Linux
64  */
65 #if __mips
66
67-/*
68- * I have no idea how to get inline assembly with the default cc.
69- * Anyone know how?
70- */
71-
72-#if 0
73-
74 /*
75  * NOTE: we assume here that file is global.
76  *
77- * $31 is the frame pointer.  $2 looks to be the return address but maybe
78- * not consistently.
79+ * $31 is the return address.
80  */
81-#define GET_RET_ADDR(file)	asm("sw $2, file")
82-
83-#endif
84+#define GET_RET_ADDR(file)	asm("sw $31, %0" : "=m" (file))
85
86 #endif /* __mips */
87
88--
892.25.1
90
91