qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v2 2/3] linux-user: Add support for semtimedop()


From: Laurent Vivier
Subject: Re: [Qemu-devel] [PATCH v2 2/3] linux-user: Add support for semtimedop() syscall
Date: Tue, 23 Oct 2018 19:04:24 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0

On 23/10/2018 14:07, Aleksandar Markovic wrote:
> From: Aleksandar Rikalo <address@hidden>
> 
> Add support for semtimedop() emulation.
> 
> Signed-off-by: Aleksandar Rikalo <address@hidden>
> Signed-off-by: Aleksandar Markovic <address@hidden>
> ---
>  linux-user/syscall.c | 27 +++++++++++++++++++++++++++
>  1 file changed, 27 insertions(+)
> 
> diff --git a/linux-user/syscall.c b/linux-user/syscall.c
> index 8b01ab0..e722ba8 100644
> --- a/linux-user/syscall.c
> +++ b/linux-user/syscall.c
> @@ -6162,7 +6162,29 @@ static inline abi_long host_to_target_stat64(void 
> *cpu_env,
>      return 0;
>  }
>  #endif
> +#ifdef TARGET_NR_semtimedop
> +static inline abi_long do_semtimedop(int semid, abi_long ptr, unsigned nsops,
> +                                     abi_long timeout)
> +{
> +    struct sembuf sops[nsops];
> +    struct timespec ts, *pts;
> +
> +    if (timeout) {
> +        pts = &ts;
> +        if (target_to_host_timespec(pts, timeout)) {
> +            return -TARGET_EFAULT;
> +        }
> +    } else {
> +        pts = NULL;
> +    }
>  
> +    if (target_to_host_sembuf(sops, ptr, nsops)) {
> +        return -TARGET_EFAULT;
> +    }
> +
> +    return get_errno(semtimedop(semid, sops, nsops, pts));
> +}

The current function do_semop() actually uses a safe_semtimedop() with a
NULL timeout pointer. Perhaps you can change/rename this function to
take the timeout pointer and convert it, and use it for TARGET_NR_semop
with NULL timeout pointer and with TARGET_NR_semtimeop with the pointer
to the target timeout.

And agree with Philippe, I think it's a good opportunity to replace the
stack allocated structure by a g_mallocated_one()

Thanks,
Laurent




reply via email to

[Prev in Thread] Current Thread [Next in Thread]