Skip to content
This repository has been archived by the owner on Apr 22, 2022. It is now read-only.

Commit

Permalink
- New Package: tinyemu
Browse files Browse the repository at this point in the history
- tinyemu patchfile: Fix & disable 128bit
- fixup: improve patch file organisation
  Move time_nsec definition fixes and Makefile changes to separate patch files
  • Loading branch information
Yonle authored and xtkoba committed Apr 5, 2022
1 parent b4c5d0f commit 065428d
Show file tree
Hide file tree
Showing 5 changed files with 134 additions and 0 deletions.
60 changes: 60 additions & 0 deletions packages/tinyemu/001-fix-hardcoded-paths.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
diff -uNr tinyemu-2019-12-21/fs_net.c tinyemu-2019-12-21.mod/fs_net.c
--- tinyemu-2019-12-21/fs_net.c 2019-12-22 00:23:54.000000000 +0700
+++ tinyemu-2019-12-21.mod/fs_net.c 2022-04-04 17:30:37.675945776 +0700
@@ -2093,7 +2093,7 @@
static FSDevice *fs_import_fs;
#endif

-#define DEFAULT_IMPORT_FILE_PATH "/tmp"
+#define DEFAULT_IMPORT_FILE_PATH "@TERMUX_PREFIX@/tmp"

FSDevice *fs_net_init(const char *url, void (*start_cb)(void *opaque),
void *start_opaque)
diff -uNr tinyemu-2019-12-21/riscv_cpu.c tinyemu-2019-12-21.mod/riscv_cpu.c
--- tinyemu-2019-12-21/riscv_cpu.c 2019-12-22 00:23:54.000000000 +0700
+++ tinyemu-2019-12-21.mod/riscv_cpu.c 2022-04-04 17:30:37.679945776 +0700
@@ -69,7 +69,7 @@
static void log_vprintf(const char *fmt, va_list ap)
{
if (!log_file)
- log_file = fopen("/tmp/riscemu.log", "wb");
+ log_file = fopen("@TERMUX_PREFIX@/tmp/riscemu.log", "wb");
vfprintf(log_file, fmt, ap);
}
#else
diff -uNr tinyemu-2019-12-21/riscv_machine.c tinyemu-2019-12-21.mod/riscv_machine.c
--- tinyemu-2019-12-21/riscv_machine.c 2019-12-22 00:23:54.000000000 +0700
+++ tinyemu-2019-12-21.mod/riscv_machine.c 2022-04-04 17:30:37.683945776 +0700
@@ -742,7 +742,7 @@
#if 0
{
FILE *f;
- f = fopen("/tmp/riscvemu.dtb", "wb");
+ f = fopen("@TERMUX_PREFIX@/tmp/riscvemu.dtb", "wb");
fwrite(dst, 1, size, f);
fclose(f);
}
diff -uNr tinyemu-2019-12-21/slirp/slirp_config.h tinyemu-2019-12-21.mod/slirp/slirp_config.h
--- tinyemu-2019-12-21/slirp/slirp_config.h 2019-12-22 00:23:54.000000000 +0700
+++ tinyemu-2019-12-21.mod/slirp/slirp_config.h 2022-04-04 17:30:37.687945776 +0700
@@ -15,7 +15,7 @@
#define MAX_INTERFACES 1
#define MAX_PPP_INTERFACES 1

-/* Define if you want slirp's socket in /tmp */
+/* Define if you want slirp's socket in @TERMUX_PREFIX@/tmp */
/* XXXXXX Do this in ./configure */
#undef USE_TMPSOCKET

diff -uNr tinyemu-2019-12-21/temu.c tinyemu-2019-12-21.mod/temu.c
--- tinyemu-2019-12-21/temu.c 2019-12-22 00:23:54.000000000 +0700
+++ tinyemu-2019-12-21.mod/temu.c 2022-04-04 17:30:37.687945776 +0700
@@ -239,7 +239,7 @@
{
static FILE *f;
if (!f)
- f = fopen("/tmp/read_sect.txt", "wb");
+ f = fopen("@TERMUX_PREFIX@/tmp/read_sect.txt", "wb");
fprintf(f, "%" PRId64 " %d\n", sector_num, n);
}
#endif
22 changes: 22 additions & 0 deletions packages/tinyemu/002-fix-time_nsec-defs.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
diff -uNr tinyemu-2019-12-21/fs.h tinyemu-2019-12-21.mod/fs.h
--- tinyemu-2019-12-21/fs.h 2019-12-22 00:23:54.000000000 +0700
+++ tinyemu-2019-12-21.mod/fs.h 2022-04-04 17:30:37.691945776 +0700
@@ -109,6 +109,18 @@
uint64_t path;
} FSQID;

+#ifdef st_atime_nsec
+# undef st_atime_nsec
+#endif
+
+#ifdef st_mtime_nsec
+# undef st_mtime_nsec
+#endif
+
+#ifdef st_ctime_nsec
+# undef st_ctime_nsec
+#endif
+
typedef struct {
FSQID qid;
uint32_t st_mode;
30 changes: 30 additions & 0 deletions packages/tinyemu/003-Makefile.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
--- tinyemu-2019-12-21/Makefile 2019-12-22 00:23:54.000000000 +0700
+++ tinyemu-2019-12-21.mod/Makefile 2022-04-04 18:48:58.361000139 +0700
@@ -44,13 +44,13 @@
CROSS_PREFIX=
EXE=
endif
-CC=$(CROSS_PREFIX)gcc
-STRIP=$(CROSS_PREFIX)strip
-CFLAGS=-O2 -Wall -g -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -MMD
-CFLAGS+=-D_GNU_SOURCE -DCONFIG_VERSION=\"$(shell cat VERSION)\"
-LDFLAGS=
+CC?=$(CROSS_PREFIX)gcc
+STRIP?=$(CROSS_PREFIX)strip
+CFLAGS?=-O2
+CFLAGS+=-I@TERMUX_PREFIX@/include -Wall -g -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -MMD -DCONFIG_VERSION=\"$(cat VERSION)\"
+LDFLAGS?=

-bindir=/usr/local/bin
+bindir=@TERMUX_PREFIX@/bin
INSTALL=install

PROGS+= temu$(EXE)
@@ -72,7 +72,6 @@

ifndef CONFIG_WIN32
EMU_OBJS+=fs_disk.o
-EMU_LIBS=-lrt
endif
ifdef CONFIG_FS_NET
CFLAGS+=-DCONFIG_FS_NET
11 changes: 11 additions & 0 deletions packages/tinyemu/004-Makefile.patch32
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--- tinyemu-2019-12-21/Makefile 2022-04-04 18:51:51.353000150 +0700
+++ tinyemu-2019-12-21.mod/Makefile 2022-04-04 18:52:16.785000151 +0700
@@ -29,7 +29,7 @@
CONFIG_SDL=y
# if set, compile the 128 bit emulator. Note: the 128 bit target does
# not compile if gcc does not support the int128 type (32 bit hosts).
-CONFIG_INT128=y
+
# build x86 emulator
CONFIG_X86EMU=y
# win32 build (not usable yet)
11 changes: 11 additions & 0 deletions packages/tinyemu/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
TERMUX_PKG_HOMEPAGE=https://bellard.org/tinyemu
TERMUX_PKG_DESCRIPTION="A system emulator for the RISC-V and x86 architectures."
TERMUX_PKG_LICENSE="MIT"
TERMUX_PKG_LICENSE_FILE="MIT-LICENSE.txt"
TERMUX_PKG_MAINTAINER="@Yonle <yonle@duck.com>"
_VERSION=2019-12-21
TERMUX_PKG_VERSION=${_VERSION//-/.}
TERMUX_PKG_SRCURL=https://bellard.org/tinyemu/tinyemu-${_VERSION}.tar.gz
TERMUX_PKG_SHA256=be8351f2121819b3172fcedce5cb1826fa12c87da1b7ed98f269d3e802a05555
TERMUX_PKG_DEPENDS="openssl, curl, sdl"
TERMUX_PKG_BUILD_IN_SRC=true

0 comments on commit 065428d

Please sign in to comment.