From b6220478b0a2c714d65625292da5f32b3b9bfbeb Mon Sep 17 00:00:00 2001
From: yzewei <yangzewei@loongson.cn>
Date: Mon, 8 Jul 2024 07:23:53 +0000
Subject: [PATCH] testing/simh: fix build on loongarch64

musl-1.2.4 removed lfs64

Signed-off-by: yzewei <yangzewei@loongson.cn>
---
 testing/simh/0001-fix-build.patch | 28 ++++++++++++++++++++++++++++
 testing/simh/APKBUILD             |  4 +++-
 2 files changed, 31 insertions(+), 1 deletion(-)
 create mode 100644 testing/simh/0001-fix-build.patch

diff --git a/testing/simh/0001-fix-build.patch b/testing/simh/0001-fix-build.patch
new file mode 100644
index 000000000000..2f7f40f9cd35
--- /dev/null
+++ b/testing/simh/0001-fix-build.patch
@@ -0,0 +1,28 @@
+diff --git a/sim_fio.c b/sim_fio.c
+index c86d67b..e30a533 100644
+--- a/sim_fio.c
++++ b/sim_fio.c
+@@ -183,7 +183,7 @@ FILE *sim_fopen (const char *file, const char *mode)
+ return fopen (file, mode, "ALQ=32", "DEQ=4096",
+         "MBF=6", "MBC=127", "FOP=cbt,tef", "ROP=rah,wbh", "CTX=stm");
+ #elif (defined (__linux) || defined (__linux__) || defined (__hpux) || defined (_AIX)) && !defined (DONT_DO_LARGEFILE)
+-return fopen64 (file, mode);
++return fopen (file, mode);
+ #else
+ return fopen (file, mode);
+ #endif
+@@ -268,12 +268,12 @@ return (t_offset) _ftelli64 (st);
+ 
+ int sim_fseeko (FILE *st, t_offset xpos, int origin)
+ {
+-return fseeko64 (st, (off64_t)xpos, origin);
++return fseeko (st, (off_t)xpos, origin);
+ }
+ 
+ t_offset sim_ftell (FILE *st)
+ {
+-return (t_offset)(ftello64 (st));
++return (t_offset)(ftello (st));
+ }
+ 
+ #endif                                                  /* end Linux with LFS */
diff --git a/testing/simh/APKBUILD b/testing/simh/APKBUILD
index 782ce886ffc4..e620594337e8 100644
--- a/testing/simh/APKBUILD
+++ b/testing/simh/APKBUILD
@@ -11,7 +11,8 @@ license="BSD-3-Clause"
 options="!check"
 makedepends="libpcap-dev"
 source="simh-$pkgver.tar.gz::https://github.com/simh/simh/archive/v$_pkgver.tar.gz
-	gcc-10.patch"
+	gcc-10.patch
+	0001-fix-build.patch"
 builddir="$srcdir"/simh-$_pkgver
 
 export CFLAGS="$CFLAGS -fcommon"
@@ -36,4 +37,5 @@ package() {
 sha512sums="
 7c2f81a64d3016b9a44409fc336c804c0da836317745d47594cc48c64cb57dc8f22084d9086e3f86868ec485ee56ac63301f350cee6d275e705b7c5fc82875db  simh-3.11.1.tar.gz
 9b6ac5106528e9cd403cfc0a9b0d22192bed5ed1172bb34447274c69b3c2408e47f08125fc845b82091f55e21adf67c72db531d9032f413aaad06b3f55655ca4  gcc-10.patch
+7b4321a31c5ef842586394ff0eca8431bb0a06640c27230530139c89d62c86d79d4796f2b5dc72bcbaab772db9b742d98e2621104d7e898b9b83accb773c3216  0001-fix-build.patch
 "
-- 
GitLab