On 2026-02-16 19:03, noneofyourbusiness via Tinycc-devel wrote: > > - providing an emulation host for any target ARCH other than x86_32, since > > tangent, since we mention qemu in a tcc context (just fyi, I don't expect any > source code diffs):
The quick-and-dirty patch for qemu-0.14.1 is attached. qemu.static will compile/link/run with tinycc atop linux2.4/musl/x86_32 with it. The plan is another though, to cooridnate a complete(!) release of the fully self-hosting/bootstrappable TinyCC/OS for x86_32 all at once, including at least one QEMU version bundled inside the fully forked portage tree to kickstart this to provide a runtime environment (qemu-binfmt) to test for other ARCH. I merely mentioned riscv64 and aarch64 since those two are locked into excess dependencies with everything (latest kernel versions, GNU/g++ and/or llvm/clang toolchains, uboot-loader/python/swig/c++ and latest qemu-versions bloated) - none of which will be included with a release of mine. > I wanted to mention this http://landley.net/qcc/ I recall Landley for several other of his projects (toybox, aboriginal), and in particular his free/open SH2 turtle board - to my knowledge TinyCC does not target SH2/3/4, at least qemu-0.14.1 could, too linux-2.4 had SuperH already. Sigh. > re-using the code in qemu's TCG to support more backends I can't yet wrap my brain around any system-integration path with this, but i am certain Landley's reasoning was plausible when he considered this with qcc. > the qemu upstream is a bit nasty in terms of build dependencies Maybe it would be easier to backport riscv64/aarch64 to qemu-0.14.1? From the perspective of TinyCC/OS x86_32 which can host QEMU this would be ideal although that's no priority for me individually, since i see various other blockers related to aarch64/riscv64. And of cause, i rather did a little runtime testing of the current qemu/tinycc-os port before wasting any time with it (if i could spare any more time at all). > this could also help with cross-compilation: the proposed "qcc" emits TCG IR > to qemu's TCG, which does the rest - we only need to do the "C to TCG IR" > step correctly > this additional processing step will probably decrease the compilation speed > we can also go even bigger: targeting SPIR-V instead - which has a thorough > spec, unlike TCG IR > > I'd say that neither fit into tcc, it wouldn't be tiny anymore > We can look at the qemu TCG backends (TCG IR->machine code) regardless - > remember that qemu has common ancestry with tcc - with n years of adding > complexity in hopes of better throughput All that is way beyond my comprehension currently. Nonetheless i placed qcc on TODO for review some time. Btw. didn't mean to be impolite when not citing Landly in the documentation, there's just not been any link yet, and i kept rolling TinyCC/OS with an old version of BusyBox instead of toybox. Recalling another aspect, no clue what licensing implications there were, i didn't bother with any GPL/MIT/BSD peculiarities since none of these interfered with my tiny interest. (i did notice however tinycc-devel asked for consent to relicense tinycc)
diff --git a/configure b/configure
index f2551b3..8c89d5b 100755
--- a/configure
+++ b/configure
@@ -2360,12 +2360,6 @@ if test "$werror" = "yes" ; then
QEMU_CFLAGS="-Werror $QEMU_CFLAGS"
fi
-if test "$solaris" = "no" ; then
- if $ld --version 2>/dev/null | grep "GNU ld" >/dev/null 2>/dev/null ; then
- LDFLAGS="-Wl,--warn-common $LDFLAGS"
- fi
-fi
-
# Use ASLR, no-SEH and DEP if available
if test "$mingw32" = "yes" ; then
for flag in --dynamicbase --no-seh --nxcompat; do
@@ -2389,15 +2383,6 @@ if test "$softmmu" = yes ; then
fi
fi
-# Mac OS X ships with a broken assembler
-roms=
-if test \( "$cpu" = "i386" -o "$cpu" = "x86_64" \) -a \
- "$targetos" != "Darwin" -a "$targetos" != "SunOS" -a \
- "$softmmu" = yes ; then
- roms="optionrom"
-fi
-
-
echo "Install prefix $prefix"
echo "BIOS directory `eval echo $datadir`"
echo "binary directory `eval echo $bindir`"
@@ -2715,9 +2700,6 @@ fi
if test "$iovec" = "yes" ; then
echo "CONFIG_IOVEC=y" >> $config_host_mak
fi
-if test "$preadv" = "yes" ; then
- echo "CONFIG_PREADV=y" >> $config_host_mak
-fi
if test "$fdt" = "yes" ; then
echo "CONFIG_FDT=y" >> $config_host_mak
fi
@@ -3223,7 +3205,7 @@ if test "$gprof" = "yes" ; then
fi
fi
-linker_script="-Wl,-T../config-host.ld -Wl,-T,\$(SRC_PATH)/\$(ARCH).ld"
+linker_script=""
if test "$target_linux_user" = "yes" -o "$target_bsd_user" = "yes" ; then
case "$ARCH" in
sparc)
diff --git a/device_tree.c b/device_tree.c
index 426a631..7a7cb45 100644
--- a/device_tree.c
+++ b/device_tree.c
@@ -24,6 +24,10 @@
#include "device_tree.h"
#include "hw/loader.h"
+typedef uint16_t fdt16_t;
+typedef uint32_t fdt32_t;
+typedef uint64_t fdt64_t;
+
#include <libfdt.h>
void *load_device_tree(const char *filename_path, int *sizep)
diff --git a/hw/ppce500_mpc8544ds.c b/hw/ppce500_mpc8544ds.c
index b7670ae..5f2eb2f 100644
--- a/hw/ppce500_mpc8544ds.c
+++ b/hw/ppce500_mpc8544ds.c
@@ -56,11 +56,11 @@ static int mpc8544_copy_soc_cell(void *fdt, const char
*node, const char *prop)
uint32_t cell;
int ret;
- ret = kvmppc_read_host_property(node, prop, &cell, sizeof(cell));
- if (ret < 0) {
- fprintf(stderr, "couldn't read host %s/%s\n", node, prop);
- goto out;
- }
+// ret = kvmppc_read_host_property(node, prop, &cell, sizeof(cell));
+// if (ret < 0) {
+// fprintf(stderr, "couldn't read host %s/%s\n", node, prop);
+// goto out;
+// }
ret = qemu_devtree_setprop_cell(fdt, "/cpus/PowerPC,8544@0",
prop, cell);
diff --git a/hw/virtio-9p.c b/hw/virtio-9p.c
index 7c59988..73fd8b6 100644
--- a/hw/virtio-9p.c
+++ b/hw/virtio-9p.c
@@ -11,6 +11,8 @@
*
*/
+#include <sys/sysmacros.h>
+
#include "virtio.h"
#include "pc.h"
#include "qemu_socket.h"
diff --git a/linux-user/signal.c b/linux-user/signal.c
index b01bd64..3fe1198 100644
--- a/linux-user/signal.c
+++ b/linux-user/signal.c
@@ -84,8 +84,8 @@ static uint8_t host_to_target_signal_table[_NSIG] = {
host libpthread signals. This assumes noone actually uses SIGRTMAX :-/
To fix this properly we need to do manual signal delivery multiplexed
over a single host signal. */
- [__SIGRTMIN] = __SIGRTMAX,
- [__SIGRTMAX] = __SIGRTMIN,
+// [__SIGRTMIN] = __SIGRTMAX,
+// [__SIGRTMAX] = __SIGRTMIN,
};
static uint8_t target_to_host_signal_table[_NSIG];
@@ -3241,7 +3241,7 @@ struct target_signal_frame {
};
struct rt_signal_frame {
- struct siginfo info;
+ siginfo_t info;
struct ucontext uc;
uint32_t tramp[2];
};
@@ -3461,7 +3461,7 @@ struct target_signal_frame {
struct rt_signal_frame {
struct siginfo *pinfo;
void *puc;
- struct siginfo info;
+ siginfo_t info;
struct ucontext uc;
uint8_t retcode[8]; /* Trampoline code. */
};
diff --git a/linux-user/strace.c b/linux-user/strace.c
index bf9a0d9..e846e1c 100644
--- a/linux-user/strace.c
+++ b/linux-user/strace.c
@@ -9,6 +9,9 @@
#include <sys/mount.h>
#include <sys/mman.h>
#include <unistd.h>
+
+#include <sys/sysmacros.h>
+
#include "qemu.h"
int do_strace=0;
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 499c4d7..ea08271 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -82,7 +82,7 @@ int __clone2(int (*fn)(void *), void *child_stack_base,
#include <linux/soundcard.h>
#include <linux/kd.h>
#include <linux/mtio.h>
-#include <linux/fs.h>
+//#include <linux/fs.h>
#if defined(CONFIG_FIEMAP)
#include <linux/fiemap.h>
#endif
@@ -534,7 +534,7 @@ extern int personality(int);
extern int flock(int, int);
extern int setfsuid(int);
extern int setfsgid(int);
-extern int setgroups(int, gid_t *);
+extern int setgroups(size_t, const gid_t *);
#define ERRNO_TABLE_SIZE 1200
@@ -2281,7 +2281,7 @@ union semun {
union target_semun {
int val;
abi_ulong buf;
- abi_ulong array;
+ unsigned short int *array;
abi_ulong __buf;
};
@@ -2347,61 +2347,118 @@ static inline abi_long host_to_target_semarray(int
semid, abi_ulong target_addr,
return 0;
}
-static inline abi_long do_semctl(int semid, int semnum, int cmd,
- union target_semun target_su)
+static inline abi_long target_to_host_semun(int cmd,
+ union semun *host_su,
+ abi_ulong target_addr,
+ struct semid_ds *ds)
+{
+ union target_semun *target_su;
+
+ switch( cmd ) {
+ case IPC_STAT:
+ case IPC_SET:
+ if (!lock_user_struct(VERIFY_READ, target_su, target_addr, 1))
+ return -TARGET_EFAULT;
+ target_to_host_semid_ds(ds,target_su->buf);
+ host_su->buf = ds;
+ unlock_user_struct(target_su, target_addr, 0);
+ break;
+ case GETVAL:
+ case SETVAL:
+ if (!lock_user_struct(VERIFY_READ, target_su, target_addr, 1))
+ return -TARGET_EFAULT;
+ host_su->val = tswapl(target_su->val);
+ unlock_user_struct(target_su, target_addr, 0);
+ break;
+ case GETALL:
+ case SETALL:
+ if (!lock_user_struct(VERIFY_READ, target_su, target_addr, 1))
+ return -TARGET_EFAULT;
+ *host_su->array = tswap16(*target_su->array);
+ unlock_user_struct(target_su, target_addr, 0);
+ break;
+ default:
+ gemu_log("semun operation not fully supported: %d\n", (int)cmd);
+ }
+ return 0;
+}
+
+static inline abi_long host_to_target_semun(int cmd,
+ abi_ulong target_addr,
+ union semun *host_su,
+ struct semid_ds *ds)
+{
+ union target_semun *target_su;
+
+ switch( cmd ) {
+ case IPC_STAT:
+ case IPC_SET:
+ if (lock_user_struct(VERIFY_WRITE, target_su, target_addr, 0))
+ return -TARGET_EFAULT;
+ host_to_target_semid_ds(target_su->buf,ds);
+ unlock_user_struct(target_su, target_addr, 1);
+ break;
+ case GETVAL:
+ case SETVAL:
+ if (lock_user_struct(VERIFY_WRITE, target_su, target_addr, 0))
+ return -TARGET_EFAULT;
+ target_su->val = tswapl(host_su->val);
+ unlock_user_struct(target_su, target_addr, 1);
+ break;
+ case GETALL:
+ case SETALL:
+ if (lock_user_struct(VERIFY_WRITE, target_su, target_addr, 0))
+ return -TARGET_EFAULT;
+ *target_su->array = tswap16(*host_su->array);
+ unlock_user_struct(target_su, target_addr, 1);
+ break;
+ default:
+ gemu_log("semun operation not fully supported: %d\n", (int)cmd);
+ }
+ return 0;
+}
+
+static inline abi_long do_semctl(int first, int second, int third,
+ abi_long ptr)
{
union semun arg;
struct semid_ds dsarg;
- unsigned short *array = NULL;
- struct seminfo seminfo;
- abi_long ret = -TARGET_EINVAL;
- abi_long err;
- cmd &= 0xff;
+ int cmd = third&0xff;
+ abi_long ret = 0;
switch( cmd ) {
case GETVAL:
+ target_to_host_semun(cmd,&arg,ptr,&dsarg);
+ ret = get_errno(semctl(first, second, cmd, arg));
+ host_to_target_semun(cmd,ptr,&arg,&dsarg);
+ break;
case SETVAL:
- arg.val = tswapl(target_su.val);
- ret = get_errno(semctl(semid, semnum, cmd, arg));
- target_su.val = tswapl(arg.val);
+ target_to_host_semun(cmd,&arg,ptr,&dsarg);
+ ret = get_errno(semctl(first, second, cmd, arg));
+ host_to_target_semun(cmd,ptr,&arg,&dsarg);
break;
case GETALL:
+ target_to_host_semun(cmd,&arg,ptr,&dsarg);
+ ret = get_errno(semctl(first, second, cmd, arg));
+ host_to_target_semun(cmd,ptr,&arg,&dsarg);
+ break;
case SETALL:
- err = target_to_host_semarray(semid, &array, target_su.array);
- if (err)
- return err;
- arg.array = array;
- ret = get_errno(semctl(semid, semnum, cmd, arg));
- err = host_to_target_semarray(semid, target_su.array, &array);
- if (err)
- return err;
+ target_to_host_semun(cmd,&arg,ptr,&dsarg);
+ ret = get_errno(semctl(first, second, cmd, arg));
+ host_to_target_semun(cmd,ptr,&arg,&dsarg);
break;
case IPC_STAT:
- case IPC_SET:
- case SEM_STAT:
- err = target_to_host_semid_ds(&dsarg, target_su.buf);
- if (err)
- return err;
- arg.buf = &dsarg;
- ret = get_errno(semctl(semid, semnum, cmd, arg));
- err = host_to_target_semid_ds(target_su.buf, &dsarg);
- if (err)
- return err;
- break;
- case IPC_INFO:
- case SEM_INFO:
- arg.__buf = &seminfo;
- ret = get_errno(semctl(semid, semnum, cmd, arg));
- err = host_to_target_seminfo(target_su.__buf, &seminfo);
- if (err)
- return err;
+ target_to_host_semun(cmd,&arg,ptr,&dsarg);
+ ret = get_errno(semctl(first, second, cmd, arg));
+ host_to_target_semun(cmd,ptr,&arg,&dsarg);
break;
- case IPC_RMID:
- case GETPID:
- case GETNCNT:
- case GETZCNT:
- ret = get_errno(semctl(semid, semnum, cmd, NULL));
+ case IPC_SET:
+ target_to_host_semun(cmd,&arg,ptr,&dsarg);
+ ret = get_errno(semctl(first, second, cmd, arg));
+ host_to_target_semun(cmd,ptr,&arg,&dsarg);
break;
+ default:
+ ret = get_errno(semctl(first, second, cmd, arg));
}
return ret;
@@ -2873,7 +2930,7 @@ static abi_long do_ipc(unsigned int call, int first,
break;
case IPCOP_semctl:
- ret = do_semctl(first, second, third, (union target_semun)(abi_ulong)
ptr);
+ ret = do_semctl(first, second, third, ptr);
break;
case IPCOP_msgget:
@@ -4465,21 +4522,21 @@ abi_long do_syscall(void *cpu_env, int num, abi_long
arg1,
}
break;
#endif
-#ifdef TARGET_NR_waitid
- case TARGET_NR_waitid:
- {
- siginfo_t info;
- info.si_pid = 0;
- ret = get_errno(waitid(arg1, arg2, &info, arg4));
- if (!is_error(ret) && arg3 && info.si_pid != 0) {
- if (!(p = lock_user(VERIFY_WRITE, arg3,
sizeof(target_siginfo_t), 0)))
- goto efault;
- host_to_target_siginfo(p, &info);
- unlock_user(p, arg3, sizeof(target_siginfo_t));
- }
- }
- break;
-#endif
+//#ifdef TARGET_NR_waitid
+// case TARGET_NR_waitid:
+// {
+// siginfo_t info;
+// info.si_pid = 0;
+// ret = get_errno(waitid(arg1, arg2, &info, arg4));
+// if (!is_error(ret) && arg3 && info.si_pid != 0) {
+// if (!(p = lock_user(VERIFY_WRITE, arg3,
sizeof(target_siginfo_t), 0)))
+// goto efault;
+// host_to_target_siginfo(p, &info);
+// unlock_user(p, arg3, sizeof(target_siginfo_t));
+// }
+// }
+// break;
+//#endif
#ifdef TARGET_NR_creat /* not on alpha */
case TARGET_NR_creat:
if (!(p = lock_user_string(arg1)))
@@ -4768,7 +4825,11 @@ abi_long do_syscall(void *cpu_env, int num, abi_long
arg1,
}
if (!(p = lock_user_string(arg1)))
goto efault;
- ret = get_errno(utimes(p, tvp));
+
+ struct utimbuf ubuf;
+ ubuf.actime = tv[0].tv_sec;
+ ubuf.modtime = tv[1].tv_sec;
+ ret = get_errno(utime(p, &ubuf));
unlock_user(p, arg1, 0);
}
break;
@@ -5970,7 +6031,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
#endif
#ifdef TARGET_NR_semctl
case TARGET_NR_semctl:
- ret = do_semctl(arg1, arg2, arg3, (union target_semun)(abi_ulong)arg4);
+ ret = do_semctl(arg1, arg2, arg3, arg4);
break;
#endif
#ifdef TARGET_NR_msgctl
diff --git a/oslib-posix.c b/oslib-posix.c
index 7bc5f7c..b2b8004 100644
--- a/oslib-posix.c
+++ b/oslib-posix.c
@@ -31,6 +31,8 @@
#include "trace.h"
#include "qemu_socket.h"
+#include <utime.h>
+
void *qemu_oom_check(void *ptr)
{
if (ptr == NULL) {
@@ -129,7 +131,7 @@ int qemu_utimensat(int dirfd, const char *path, const
struct timespec *times,
return 0;
}
if (times[0].tv_nsec == UTIME_NOW && times[1].tv_nsec == UTIME_NOW) {
- return utimes(path, NULL);
+ return utime(path, NULL);
}
/* prepare for hard cases */
@@ -153,5 +155,8 @@ int qemu_utimensat(int dirfd, const char *path, const
struct timespec *times,
}
}
- return utimes(path, &tv[0]);
+ struct utimbuf ubuf;
+ ubuf.actime = times[0].tv_sec;
+ ubuf.modtime = times[1].tv_sec;
+ return utime(path, &ubuf);
}
diff --git a/poison.h b/poison.h
index d7db7f4..b5cef01 100644
--- a/poison.h
+++ b/poison.h
@@ -4,7 +4,7 @@
#ifndef HW_POISON_H
#define HW_POISON_H
#ifdef __GNUC__
-
+/*
#pragma GCC poison TARGET_I386
#pragma GCC poison TARGET_X86_64
#pragma GCC poison TARGET_ALPHA
@@ -45,6 +45,6 @@
#pragma GCC poison CPU_INTERRUPT_DEBUG
#pragma GCC poison CPU_INTERRUPT_VIRQ
#pragma GCC poison CPU_INTERRUPT_NMI
-
+*/
#endif
#endif
diff --git a/qemu-doc.texi b/qemu-doc.texi
index 86e017c..2671dd7 100644
--- a/qemu-doc.texi
+++ b/qemu-doc.texi
@@ -224,7 +224,7 @@ VGA BIOS.
QEMU uses YM3812 emulation by Tatsuyuki Satoh.
QEMU uses GUS emulation (GUSEMU32 @url{http://www.deinmeister.de/gusemu/})
-by Tibor "TS" Schütz.
+by Tibor "TS" Schuetz.
Not that, by default, GUS shares IRQ(7) with parallel ports and so
qemu must be told to not have parallel ports to have working GUS
diff --git a/qemu-timer-common.c b/qemu-timer-common.c
index 755e300..1be0a22 100644
--- a/qemu-timer-common.c
+++ b/qemu-timer-common.c
@@ -49,15 +49,15 @@ int use_rt_clock;
static void __attribute__((constructor)) init_get_clock(void)
{
use_rt_clock = 0;
-#if defined(__linux__) || (defined(__FreeBSD__) && __FreeBSD_version >=
500000) \
- || defined(__DragonFly__) || defined(__FreeBSD_kernel__) \
- || defined(__OpenBSD__)
- {
- struct timespec ts;
- if (clock_gettime(CLOCK_MONOTONIC, &ts) == 0) {
- use_rt_clock = 1;
- }
- }
-#endif
+//#if defined(__linux__) || (defined(__FreeBSD__) && __FreeBSD_version >=
500000) \
+// || defined(__DragonFly__) || defined(__FreeBSD_kernel__) \
+// || defined(__OpenBSD__)
+// {
+// struct timespec ts;
+// if (clock_gettime(CLOCK_MONOTONIC, &ts) == 0) {
+// use_rt_clock = 1;
+// }
+// }
+//#endif
}
#endif
diff --git a/qemu-timer.h b/qemu-timer.h
index 8cd8f83..e94dcdb 100644
--- a/qemu-timer.h
+++ b/qemu-timer.h
@@ -87,19 +87,19 @@ extern int use_rt_clock;
static inline int64_t get_clock(void)
{
-#if defined(__linux__) || (defined(__FreeBSD__) && __FreeBSD_version >=
500000) \
- || defined(__DragonFly__) || defined(__FreeBSD_kernel__)
- if (use_rt_clock) {
- struct timespec ts;
- clock_gettime(CLOCK_MONOTONIC, &ts);
- return ts.tv_sec * 1000000000LL + ts.tv_nsec;
- } else
-#endif
- {
+//#if defined(__linux__) || (defined(__FreeBSD__) && __FreeBSD_version >=
500000) \
+// || defined(__DragonFly__) || defined(__FreeBSD_kernel__)
+// if (use_rt_clock) {
+// struct timespec ts;
+// clock_gettime(CLOCK_MONOTONIC, &ts);
+// return ts.tv_sec * 1000000000LL + ts.tv_nsec;
+// } else
+//#endif
+// {
/* XXX: using gettimeofday leads to problems if the date
changes, so it should be avoided. */
return get_clock_realtime();
- }
+// }
}
#endif
diff --git a/rules.mak b/rules.mak
index 876ebc5..4d7ee6a 100644
--- a/rules.mak
+++ b/rules.mak
@@ -12,7 +12,7 @@ MAKEFLAGS += -rR
%.mak:
# Flags for dependency generation
-QEMU_DGFLAGS += -MMD -MP -MT $@ -MF $(*D)/$(*F).d
+QEMU_DGFLAGS += -MMD -MP -MF $(*D)/$(*F).d
%.o: %.c
$(call quiet-command,$(CC) $(QEMU_CFLAGS) $(QEMU_INCLUDES)
$(QEMU_DGFLAGS) $(CFLAGS) -c -o $@ $<," CC $(TARGET_DIR)$@")
qemu-0.14.1.ebuild
Description: application/vnd.gentoo.ebuild
signature.asc
Description: Digital signature
_______________________________________________ Tinycc-devel mailing list [email protected] https://lists.nongnu.org/mailman/listinfo/tinycc-devel
