diff --git a/app-emulation/qemu/patches/qemu-6.0.0.patchset b/app-emulation/qemu/patches/qemu-6.0.0.patchset new file mode 100644 index 000000000..44635bbf9 --- /dev/null +++ b/app-emulation/qemu/patches/qemu-6.0.0.patchset @@ -0,0 +1,141 @@ +From e2fc63ba3e0f33018a2b0623e50feca92d234556 Mon Sep 17 00:00:00 2001 +From: Alexander von Gluck IV +Date: Tue, 18 May 2021 16:49:20 -0500 +Subject: [PATCH] haiku: fixes and patches, rebased from qemu 3.x + +--- + disas/nanomips.h | 4 ++++ + os-posix.c | 10 ++++++++++ + slirp/src/tftp.c | 5 +++++ + target/mips/mips-semi.c | 4 ++++ + util/main-loop.c | 2 ++ + util/notify.c | 4 ++++ + util/qemu-thread-posix.c | 4 ++++ + 7 files changed, 33 insertions(+) + +diff --git a/disas/nanomips.h b/disas/nanomips.h +index a0a222530..8b8add814 100644 +--- a/disas/nanomips.h ++++ b/disas/nanomips.h +@@ -25,10 +25,14 @@ + + #include + ++#ifndef __HAIKU__ + typedef int64_t int64; + typedef uint64_t uint64; + typedef uint32_t uint32; + typedef uint16_t uint16; ++#else ++#include ++#endif + + namespace img + { +diff --git a/os-posix.c b/os-posix.c +index a6846f51c..cc0c80e8c 100644 +--- a/os-posix.c ++++ b/os-posix.c +@@ -42,6 +42,16 @@ + #include + #endif + ++#ifdef __HAIKU__ ++#ifndef MCL_CURRENT ++#define MCL_CURRENT 8192 ++#endif ++#ifndef MCL_FUTURE ++#define MCL_FUTURE 16384 ++#endif ++#endif ++ ++ + /* + * Must set all three of these at once. + * Legal combinations are unset by name by uid +diff --git a/slirp/src/tftp.c b/slirp/src/tftp.c +index c6950ee10..5e1cad3ec 100644 +--- a/slirp/src/tftp.c ++++ b/slirp/src/tftp.c +@@ -29,6 +29,11 @@ + #include + #include + ++#ifndef O_BINARY ++#define O_BINARY 0 ++#endif ++ ++ + static inline int tftp_session_in_use(struct tftp_session *spt) + { + return (spt->slirp != NULL); +diff --git a/target/mips/mips-semi.c b/target/mips/mips-semi.c +index 6de60fa6d..717a24787 100644 +--- a/target/mips/mips-semi.c ++++ b/target/mips/mips-semi.c +@@ -76,6 +76,7 @@ enum UHIOpenFlags { + + /* Errno values taken from asm-mips/errno.h */ + static uint16_t host_to_mips_errno[] = { ++#ifndef __HAIKU__ + [ENAMETOOLONG] = 78, + #ifdef EOVERFLOW + [EOVERFLOW] = 79, +@@ -83,6 +84,9 @@ static uint16_t host_to_mips_errno[] = { + #ifdef ELOOP + [ELOOP] = 90, + #endif ++#else ++ NULL ++#endif + }; + + static int errno_mips(int err) +diff --git a/util/main-loop.c b/util/main-loop.c +index 5188ff654..62cdbf6dd 100644 +--- a/util/main-loop.c ++++ b/util/main-loop.c +@@ -97,7 +97,9 @@ static int qemu_signal_init(Error **errp) + */ + sigemptyset(&set); + sigaddset(&set, SIG_IPI); ++ #ifdef SIGIO + sigaddset(&set, SIGIO); ++ #endif + sigaddset(&set, SIGALRM); + sigaddset(&set, SIGBUS); + /* SIGINT cannot be handled via signalfd, so that ^C can be used +diff --git a/util/notify.c b/util/notify.c +index 76bab212a..7c1ea8405 100644 +--- a/util/notify.c ++++ b/util/notify.c +@@ -67,6 +67,10 @@ int notifier_with_return_list_notify(NotifierWithReturnList *list, void *data) + int ret = 0; + + QLIST_FOREACH_SAFE(notifier, &list->notifiers, node, next) { ++ #ifdef __HAIKU__ ++ if(notifier->notify == NULL) break; ++ #endif ++ + ret = notifier->notify(notifier, data); + if (ret != 0) { + break; +diff --git a/util/qemu-thread-posix.c b/util/qemu-thread-posix.c +index dcff5e7c5..2e8271be5 100644 +--- a/util/qemu-thread-posix.c ++++ b/util/qemu-thread-posix.c +@@ -311,7 +311,11 @@ int qemu_sem_timedwait(QemuSemaphore *sem, int ms) + } + } + if (rc < 0) { ++ #ifndef __HAIKU__ + error_exit(errno, __func__); ++ #else ++ return -1; ++ #endif + } + return 0; + #endif +-- +2.30.2 + diff --git a/app-emulation/qemu/qemu-6.0.0.recipe b/app-emulation/qemu/qemu-6.0.0.recipe new file mode 100644 index 000000000..d4574a262 --- /dev/null +++ b/app-emulation/qemu/qemu-6.0.0.recipe @@ -0,0 +1,241 @@ +SUMMARY="A generic and open source machine emulator and virtualizer" +DESCRIPTION="QEMU is a generic and open source machine emulator and virtualizer. + +QEMU can run OSes and programs made for one machine (e.g. an ARM board) on a \ +different machine (e.g. your own PC). By using dynamic translation, it \ +achieves very good performance." +HOMEPAGE="https://www.qemu.org/" +COPYRIGHT="2003-2018 Fabrice Bellard" +LICENSE="GNU GPL v2" +REVISION="1" +SOURCE_URI="https://download.qemu.org/qemu-$portVersion.tar.xz" +CHECKSUM_SHA256="87bc1a471ca24b97e7005711066007d443423d19aacda3d442558ae032fa30b9" +SOURCE_DIR="qemu-$portVersion" +PATCHES="qemu-$portVersion.patchset" +ADDITIONAL_FILES="qemu.rdef.in" + +ARCHITECTURES="!x86_gcc2 ?x86 ?x86_64" +SECONDARY_ARCHITECTURES="?x86" + +commandSuffix=$secondaryArchSuffix +commandBinDir=$binDir +if [ "$targetArchitecture" = x86_gcc2 ]; then + commandSuffix= + commandBinDir=$prefix/bin +fi + +platformList="x86 arm mips ppc sparc m68k riscv" +archList_x86="i386 x86_64" +archList_arm="arm aarch64" +archList_mips="mips mipsel mips64 mips64el" +archList_ppc="ppc ppc64" +archList_sparc="sparc sparc64" +archList_m68k="m68k" +archList_riscv="riscv32 riscv64" + +PROVIDES=" + qemu$secondaryArchSuffix = $portVersion + cmd:qemu_edid$commandSuffix = $portVersion + cmd:qemu_img$commandSuffix = $portVersion + cmd:qemu_io$commandSuffix = $portVersion + " +REQUIRES=" + haiku$secondaryArchSuffix + cmd:iasl + cmd:smbd$secondaryArchSuffix + lib:libbz2$secondaryArchSuffix + lib:libcapstone$secondaryArchSuffix + lib:libcurl$secondaryArchSuffix + lib:libfdt$secondaryArchSuffix + lib:libgcrypt$secondaryArchSuffix + lib:libglib_2.0$secondaryArchSuffix + lib:libgnutls$secondaryArchSuffix + lib:libgpg_error$secondaryArchSuffix + lib:libintl$secondaryArchSuffix + lib:libjpeg$secondaryArchSuffix + lib:liblzo2$secondaryArchSuffix + lib:libncursesw$secondaryArchSuffix + lib:libnettle$secondaryArchSuffix + lib:libpixman_1$secondaryArchSuffix + lib:libpng16$secondaryArchSuffix + lib:libSDL2_2.0$secondaryArchSuffix + lib:libsnappy$secondaryArchSuffix + lib:libssh2$secondaryArchSuffix + lib:libssp$secondaryArchSuffix + lib:libtasn1$secondaryArchSuffix + lib:libusb_1.0$secondaryArchSuffix + lib:libxml2$secondaryArchSuffix + lib:libz$secondaryArchSuffix + " + +PROVIDES_x86=" + qemu_x86$secondaryArchSuffix = $portVersion + cmd:qemu$commandSuffix = $portVersion + cmd:qemu_system_i386$commandSuffix = $portVersion + cmd:qemu_system_x86_64$commandSuffix = $portVersion + " +REQUIRES_x86=" + $REQUIRES + qemu$secondaryArchSuffix + " +SUPPLEMENTS_x86=" + qemu$secondaryArchSuffix + " + +PROVIDES_arm=" + qemu_arm$secondaryArchSuffix = $portVersion + cmd:qemu_system_aarch64$commandSuffix = $portVersion + cmd:qemu_system_arm$commandSuffix = $portVersion + " +REQUIRES_arm=$REQUIRES_x86 + +PROVIDES_mips=" + qemu_mips$secondaryArchSuffix = $portVersion + cmd:qemu_system_mips$commandSuffix = $portVersion + cmd:qemu_system_mips64$commandSuffix = $portVersion + cmd:qemu_system_mips64el$commandSuffix = $portVersion + cmd:qemu_system_mipsel$commandSuffix = $portVersion + " +REQUIRES_mips=$REQUIRES_x86 + +PROVIDES_ppc=" + qemu_ppc$secondaryArchSuffix = $portVersion + cmd:qemu_system_ppc$commandSuffix = $portVersion + cmd:qemu_system_ppc64$commandSuffix = $portVersion + " +REQUIRES_ppc=$REQUIRES_x86 + +PROVIDES_sparc=" + qemu_sparc$secondaryArchSuffix = $portVersion + cmd:qemu_system_sparc$commandSuffix = $portVersion + cmd:qemu_system_sparc64$commandSuffix = $portVersion + " +REQUIRES_sparc=$REQUIRES_x86 + +PROVIDES_m68k=" + qemu_m68k$secondaryArchSuffix = $portVersion + cmd:qemu_system_m68k$commandSuffix = $portVersion + " +REQUIRES_m68k=$REQUIRES_x86 + +PROVIDES_riscv=" + qemu_riscv$secondaryArchSuffix = $portVersion + cmd:qemu_system_riscv32$commandSuffix = $portVersion + cmd:qemu_system_riscv64$commandSuffix = $portVersion + " +REQUIRES_riscv=$REQUIRES_x86 + +BUILD_REQUIRES=" + devel:libbz2$secondaryArchSuffix + devel:libcapstone$secondaryArchSuffix + devel:libcurl$secondaryArchSuffix + devel:libfdt$secondaryArchSuffix + devel:libgcrypt$secondaryArchSuffix + devel:libglib_2.0$secondaryArchSuffix + devel:libgnutls$secondaryArchSuffix + devel:libgpg_error$secondaryArchSuffix + devel:libintl$secondaryArchSuffix + devel:libjpeg$secondaryArchSuffix >= 9 + devel:liblzo2$secondaryArchSuffix + devel:libncursesw$secondaryArchSuffix + devel:libnettle$secondaryArchSuffix + devel:libpixman_1$secondaryArchSuffix + devel:libpng16$secondaryArchSuffix + devel:libSDL2_2.0$secondaryArchSuffix + devel:libsnappy$secondaryArchSuffix + devel:libssh2$secondaryArchSuffix + devel:libtasn1$secondaryArchSuffix + devel:libusb_1.0$secondaryArchSuffix + devel:libxml2$secondaryArchSuffix + devel:libz$secondaryArchSuffix + " +BUILD_PREREQUIRES=" + haiku${secondaryArchSuffix}_devel + cmd:awk + cmd:cmp + cmd:git + cmd:gcc$secondaryArchSuffix + cmd:gcov$secondaryArchSuffix + cmd:gprof$secondaryArchSuffix + cmd:ld$secondaryArchSuffix + cmd:make + cmd:ninja + cmd:find + cmd:iasl + cmd:pkg_config$secondaryArchSuffix + cmd:pod2man + cmd:python + " + +BUILD() +{ + export CFLAGS="-I`finddir B_SYSTEM_HEADERS_DIRECTORY`/capstone" + + for platformItem in $platformList; do + platformArchList=$(eval echo \$archList_$platformItem) + archList="$archList $platformArchList" + done + + for archItem in $archList; do + targetList="$archItem-softmmu,$targetList" + done + + runConfigure --omit-dirs "binDir sbinDir" \ + --omit-buildspec ./configure \ + --bindir="$commandBinDir" --sbindir="$commandBinDir" \ + --enable-capstone=system \ + --enable-gcrypt \ + --disable-tpm \ + --smbd=/$relativeBinDir/smbd \ + --target-list="${targetList::-1}" + + cd build + ninja $jobArgs +} + +INSTALL() +{ + cd build + ninja install $jobArgs + + local MAJOR="`echo "$portVersion" | cut -d. -f1`" + local MIDDLE="`echo "$portVersion" | cut -d. -f2`" + local MINOR="`echo "$portVersion" | cut -d. -f3`" + local LONG_INFO="$SUMMARY" + + archList="" + + for platformItem in $platformList; do + platformArchList=$(eval echo \$archList_$platformItem) + archList="$archList $platformArchList" + done + + for archItem in $archList; do + echo $archItem + local APP_SIGNATURE="application/x-vnd.qemu-system-$archItem" + sed \ + -e "s|@APP_SIGNATURE@|$APP_SIGNATURE|" \ + -e "s|@MAJOR@|$MAJOR|" \ + -e "s|@MIDDLE@|$MIDDLE|" \ + -e "s|@MINOR@|$MINOR|" \ + -e "s|@LONG_INFO@|$LONG_INFO|" \ + $portDir/additional-files/qemu.rdef.in > qemu-system-$archItem.rdef + addResourcesToBinaries qemu-system-$archItem.rdef $commandBinDir/qemu-system-$archItem + done + + # provide convenience symlink to just "qemu" + if [ "$effectiveTargetArchitecture" = x86_64 ]; then + ln -s $commandBinDir/qemu-system-x86_64 $commandBinDir/qemu + else + ln -s $commandBinDir/qemu-system-i386 $commandBinDir/qemu + fi + + packageEntries x86 $commandBinDir/qemu + + for platformItem in $platformList; do + platformArchList=$(eval echo \$archList_$platformItem) + for archItem in $platformArchList; do + packageEntries $platformItem $commandBinDir/qemu-system-$archItem + done + done +}