[PATCH] bsd-user/syscall_defs.h: define STAT_TIME_T_EXT only for 32 bits

Pierrick Bouvier posted 1 patch 2 weeks, 4 days ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20260119075738.712207-1-pierrick.bouvier@linaro.org
Maintainers: Warner Losh <imp@bsdimp.com>, Kyle Evans <kevans@freebsd.org>
bsd-user/syscall_defs.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] bsd-user/syscall_defs.h: define STAT_TIME_T_EXT only for 32 bits
Posted by Pierrick Bouvier 2 weeks, 4 days ago
Commit 369c1ba2b changed the wrong conditional "#if defined(__i386__)" to
"#if defined(TARGET_I386)".
However, TARGET_I386 is defined for target x86_64 also.

This commit fixes it by identifying correctly 32 bits target.

Found with:
$ ./build/qemu-x86_64 \
  -plugin ./build/contrib/plugins/libstoptrigger,icount=1000000 \
  -plugin ./build/tests/tcg/plugins/libinsn \
  -d plugin \
  ./build/qemu-system-x86_64 --version
ld-elf.so.1: /lib/libz.so.6: invalid file format
cpu 0 insns: 59746
total insns: 59746

Fixes: 369c1ba2b ("Fix __i386__ test for TARGET_HAS_STAT_TIME_T_EXT")
Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
---
 bsd-user/syscall_defs.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/bsd-user/syscall_defs.h b/bsd-user/syscall_defs.h
index c49be32bdc0..cc4b484f3ab 100644
--- a/bsd-user/syscall_defs.h
+++ b/bsd-user/syscall_defs.h
@@ -247,7 +247,7 @@ struct target_freebsd11_stat {
     unsigned int:(8 / 2) * (16 - (int)sizeof(struct target_freebsd_timespec));
 } __packed;
 
-#if defined(TARGET_I386)
+#if defined(TARGET_I386) && !defined(TARGET_X86_64)
 #define TARGET_HAS_STAT_TIME_T_EXT       1
 #endif
 
-- 
2.47.3
Re: [PATCH] bsd-user/syscall_defs.h: define STAT_TIME_T_EXT only for 32 bits
Posted by Warner Losh 2 weeks, 4 days ago
On Mon, Jan 19, 2026 at 12:57 AM Pierrick Bouvier <
pierrick.bouvier@linaro.org> wrote:

> Commit 369c1ba2b changed the wrong conditional "#if defined(__i386__)" to
> "#if defined(TARGET_I386)".
> However, TARGET_I386 is defined for target x86_64 also.
>

Oh I always forget about that...


> This commit fixes it by identifying correctly 32 bits target.
>
> Found with:
> $ ./build/qemu-x86_64 \
>   -plugin ./build/contrib/plugins/libstoptrigger,icount=1000000 \
>   -plugin ./build/tests/tcg/plugins/libinsn \
>   -d plugin \
>   ./build/qemu-system-x86_64 --version
> ld-elf.so.1: /lib/libz.so.6: invalid file format
> cpu 0 insns: 59746
> total insns: 59746
>
> Fixes: 369c1ba2b ("Fix __i386__ test for TARGET_HAS_STAT_TIME_T_EXT")
> Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
> ---
>  bsd-user/syscall_defs.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>

Reviewed-by: Warner Losh <imp@bsdimp.com>


> diff --git a/bsd-user/syscall_defs.h b/bsd-user/syscall_defs.h
> index c49be32bdc0..cc4b484f3ab 100644
> --- a/bsd-user/syscall_defs.h
> +++ b/bsd-user/syscall_defs.h
> @@ -247,7 +247,7 @@ struct target_freebsd11_stat {
>      unsigned int:(8 / 2) * (16 - (int)sizeof(struct
> target_freebsd_timespec));
>  } __packed;
>
> -#if defined(TARGET_I386)
> +#if defined(TARGET_I386) && !defined(TARGET_X86_64)
>  #define TARGET_HAS_STAT_TIME_T_EXT       1
>  #endif
>
> --
> 2.47.3
>
>
Re: [PATCH] bsd-user/syscall_defs.h: define STAT_TIME_T_EXT only for 32 bits
Posted by Philippe Mathieu-Daudé 2 weeks, 4 days ago
On 19/1/26 08:57, Pierrick Bouvier wrote:
> Commit 369c1ba2b changed the wrong conditional "#if defined(__i386__)" to
> "#if defined(TARGET_I386)".
> However, TARGET_I386 is defined for target x86_64 also.
> 
> This commit fixes it by identifying correctly 32 bits target.
> 
> Found with:
> $ ./build/qemu-x86_64 \
>    -plugin ./build/contrib/plugins/libstoptrigger,icount=1000000 \
>    -plugin ./build/tests/tcg/plugins/libinsn \
>    -d plugin \
>    ./build/qemu-system-x86_64 --version
> ld-elf.so.1: /lib/libz.so.6: invalid file format
> cpu 0 insns: 59746
> total insns: 59746
> 
> Fixes: 369c1ba2b ("Fix __i386__ test for TARGET_HAS_STAT_TIME_T_EXT")
> Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
> ---
>   bsd-user/syscall_defs.h | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>