qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] linux-user: Fix incorrect use of feature-test-macros
@ 2021-05-26  3:55 Michael Forney
  2021-06-15  6:36 ` Laurent Vivier
  2021-06-20 14:40 ` Laurent Vivier
  0 siblings, 2 replies; 3+ messages in thread
From: Michael Forney @ 2021-05-26  3:55 UTC (permalink / raw)
  To: Laurent Vivier; +Cc: qemu-devel

The _POSIX_C_SOURCE and _XOPEN_SOURCE macros are used by the
application to indicate to libc which declarations it should expose.
Since qemu does not define them anywhere, it does not make sense
to check their value.

Instead, since the intent is to determine whether the host struct
stat supports the st_*tim fields, use the configure test result
which does exactly that.

Signed-off-by: Michael Forney <mforney@mforney.org>
---
 linux-user/syscall.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index c9f812091c..9a52f235d2 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -7470,7 +7470,7 @@ static inline abi_long host_to_target_stat64(void *cpu_env,
         __put_user(host_st->st_atime, &target_st->target_st_atime);
         __put_user(host_st->st_mtime, &target_st->target_st_mtime);
         __put_user(host_st->st_ctime, &target_st->target_st_ctime);
-#if _POSIX_C_SOURCE >= 200809L || _XOPEN_SOURCE >= 700
+#ifdef HAVE_STRUCT_STAT_ST_ATIM
         __put_user(host_st->st_atim.tv_nsec, &target_st->target_st_atime_nsec);
         __put_user(host_st->st_mtim.tv_nsec, &target_st->target_st_mtime_nsec);
         __put_user(host_st->st_ctim.tv_nsec, &target_st->target_st_ctime_nsec);
@@ -7505,7 +7505,7 @@ static inline abi_long host_to_target_stat64(void *cpu_env,
         __put_user(host_st->st_atime, &target_st->target_st_atime);
         __put_user(host_st->st_mtime, &target_st->target_st_mtime);
         __put_user(host_st->st_ctime, &target_st->target_st_ctime);
-#if _POSIX_C_SOURCE >= 200809L || _XOPEN_SOURCE >= 700
+#ifdef HAVE_STRUCT_STAT_ST_ATIM
         __put_user(host_st->st_atim.tv_nsec, &target_st->target_st_atime_nsec);
         __put_user(host_st->st_mtim.tv_nsec, &target_st->target_st_mtime_nsec);
         __put_user(host_st->st_ctim.tv_nsec, &target_st->target_st_ctime_nsec);
@@ -10056,8 +10056,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
                 __put_user(st.st_atime, &target_st->target_st_atime);
                 __put_user(st.st_mtime, &target_st->target_st_mtime);
                 __put_user(st.st_ctime, &target_st->target_st_ctime);
-#if (_POSIX_C_SOURCE >= 200809L || _XOPEN_SOURCE >= 700) && \
-    defined(TARGET_STAT_HAVE_NSEC)
+#if defined(HAVE_STRUCT_STAT_ST_ATIM) && defined(TARGET_STAT_HAVE_NSEC)
                 __put_user(st.st_atim.tv_nsec,
                            &target_st->target_st_atime_nsec);
                 __put_user(st.st_mtim.tv_nsec,
-- 
2.31.1



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] linux-user: Fix incorrect use of feature-test-macros
  2021-05-26  3:55 [PATCH] linux-user: Fix incorrect use of feature-test-macros Michael Forney
@ 2021-06-15  6:36 ` Laurent Vivier
  2021-06-20 14:40 ` Laurent Vivier
  1 sibling, 0 replies; 3+ messages in thread
From: Laurent Vivier @ 2021-06-15  6:36 UTC (permalink / raw)
  To: Michael Forney; +Cc: qemu-devel

Le 26/05/2021 à 05:55, Michael Forney a écrit :
> The _POSIX_C_SOURCE and _XOPEN_SOURCE macros are used by the
> application to indicate to libc which declarations it should expose.
> Since qemu does not define them anywhere, it does not make sense
> to check their value.
> 
> Instead, since the intent is to determine whether the host struct
> stat supports the st_*tim fields, use the configure test result
> which does exactly that.
> 
> Signed-off-by: Michael Forney <mforney@mforney.org>
> ---
>  linux-user/syscall.c | 7 +++----
>  1 file changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/linux-user/syscall.c b/linux-user/syscall.c
> index c9f812091c..9a52f235d2 100644
> --- a/linux-user/syscall.c
> +++ b/linux-user/syscall.c
> @@ -7470,7 +7470,7 @@ static inline abi_long host_to_target_stat64(void *cpu_env,
>          __put_user(host_st->st_atime, &target_st->target_st_atime);
>          __put_user(host_st->st_mtime, &target_st->target_st_mtime);
>          __put_user(host_st->st_ctime, &target_st->target_st_ctime);
> -#if _POSIX_C_SOURCE >= 200809L || _XOPEN_SOURCE >= 700
> +#ifdef HAVE_STRUCT_STAT_ST_ATIM
>          __put_user(host_st->st_atim.tv_nsec, &target_st->target_st_atime_nsec);
>          __put_user(host_st->st_mtim.tv_nsec, &target_st->target_st_mtime_nsec);
>          __put_user(host_st->st_ctim.tv_nsec, &target_st->target_st_ctime_nsec);
> @@ -7505,7 +7505,7 @@ static inline abi_long host_to_target_stat64(void *cpu_env,
>          __put_user(host_st->st_atime, &target_st->target_st_atime);
>          __put_user(host_st->st_mtime, &target_st->target_st_mtime);
>          __put_user(host_st->st_ctime, &target_st->target_st_ctime);
> -#if _POSIX_C_SOURCE >= 200809L || _XOPEN_SOURCE >= 700
> +#ifdef HAVE_STRUCT_STAT_ST_ATIM
>          __put_user(host_st->st_atim.tv_nsec, &target_st->target_st_atime_nsec);
>          __put_user(host_st->st_mtim.tv_nsec, &target_st->target_st_mtime_nsec);
>          __put_user(host_st->st_ctim.tv_nsec, &target_st->target_st_ctime_nsec);
> @@ -10056,8 +10056,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
>                  __put_user(st.st_atime, &target_st->target_st_atime);
>                  __put_user(st.st_mtime, &target_st->target_st_mtime);
>                  __put_user(st.st_ctime, &target_st->target_st_ctime);
> -#if (_POSIX_C_SOURCE >= 200809L || _XOPEN_SOURCE >= 700) && \
> -    defined(TARGET_STAT_HAVE_NSEC)
> +#if defined(HAVE_STRUCT_STAT_ST_ATIM) && defined(TARGET_STAT_HAVE_NSEC)
>                  __put_user(st.st_atim.tv_nsec,
>                             &target_st->target_st_atime_nsec);
>                  __put_user(st.st_mtim.tv_nsec,
> 

Reviewed-by: Laurent Vivier <laurent@vivier.eu>


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] linux-user: Fix incorrect use of feature-test-macros
  2021-05-26  3:55 [PATCH] linux-user: Fix incorrect use of feature-test-macros Michael Forney
  2021-06-15  6:36 ` Laurent Vivier
@ 2021-06-20 14:40 ` Laurent Vivier
  1 sibling, 0 replies; 3+ messages in thread
From: Laurent Vivier @ 2021-06-20 14:40 UTC (permalink / raw)
  To: Michael Forney; +Cc: qemu-devel

Le 26/05/2021 à 05:55, Michael Forney a écrit :
> The _POSIX_C_SOURCE and _XOPEN_SOURCE macros are used by the
> application to indicate to libc which declarations it should expose.
> Since qemu does not define them anywhere, it does not make sense
> to check their value.
> 
> Instead, since the intent is to determine whether the host struct
> stat supports the st_*tim fields, use the configure test result
> which does exactly that.
> 
> Signed-off-by: Michael Forney <mforney@mforney.org>
> ---
>  linux-user/syscall.c | 7 +++----
>  1 file changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/linux-user/syscall.c b/linux-user/syscall.c
> index c9f812091c..9a52f235d2 100644
> --- a/linux-user/syscall.c
> +++ b/linux-user/syscall.c
> @@ -7470,7 +7470,7 @@ static inline abi_long host_to_target_stat64(void *cpu_env,
>          __put_user(host_st->st_atime, &target_st->target_st_atime);
>          __put_user(host_st->st_mtime, &target_st->target_st_mtime);
>          __put_user(host_st->st_ctime, &target_st->target_st_ctime);
> -#if _POSIX_C_SOURCE >= 200809L || _XOPEN_SOURCE >= 700
> +#ifdef HAVE_STRUCT_STAT_ST_ATIM
>          __put_user(host_st->st_atim.tv_nsec, &target_st->target_st_atime_nsec);
>          __put_user(host_st->st_mtim.tv_nsec, &target_st->target_st_mtime_nsec);
>          __put_user(host_st->st_ctim.tv_nsec, &target_st->target_st_ctime_nsec);
> @@ -7505,7 +7505,7 @@ static inline abi_long host_to_target_stat64(void *cpu_env,
>          __put_user(host_st->st_atime, &target_st->target_st_atime);
>          __put_user(host_st->st_mtime, &target_st->target_st_mtime);
>          __put_user(host_st->st_ctime, &target_st->target_st_ctime);
> -#if _POSIX_C_SOURCE >= 200809L || _XOPEN_SOURCE >= 700
> +#ifdef HAVE_STRUCT_STAT_ST_ATIM
>          __put_user(host_st->st_atim.tv_nsec, &target_st->target_st_atime_nsec);
>          __put_user(host_st->st_mtim.tv_nsec, &target_st->target_st_mtime_nsec);
>          __put_user(host_st->st_ctim.tv_nsec, &target_st->target_st_ctime_nsec);
> @@ -10056,8 +10056,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
>                  __put_user(st.st_atime, &target_st->target_st_atime);
>                  __put_user(st.st_mtime, &target_st->target_st_mtime);
>                  __put_user(st.st_ctime, &target_st->target_st_ctime);
> -#if (_POSIX_C_SOURCE >= 200809L || _XOPEN_SOURCE >= 700) && \
> -    defined(TARGET_STAT_HAVE_NSEC)
> +#if defined(HAVE_STRUCT_STAT_ST_ATIM) && defined(TARGET_STAT_HAVE_NSEC)
>                  __put_user(st.st_atim.tv_nsec,
>                             &target_st->target_st_atime_nsec);
>                  __put_user(st.st_mtim.tv_nsec,
> 

Applied to my linux-user-for-6.1 branch.

Thanks,
Laurent



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-06-20 14:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-26  3:55 [PATCH] linux-user: Fix incorrect use of feature-test-macros Michael Forney
2021-06-15  6:36 ` Laurent Vivier
2021-06-20 14:40 ` Laurent Vivier

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).