[prev in list] [next in list] [prev in thread] [next in thread] 

List:       musl
Subject:    Re: [musl] [PATCH v2] fix clock_nanosleep error case
From:       Rich Felker <dalias () libc ! org>
Date:       2016-10-20 5:47:06
Message-ID: 20161020054706.GM19318 () brightrain ! aerifal ! cx
[Download RAW message or body]

On Sat, Sep 17, 2016 at 12:05:45PM -0400, Daniel Sabogal wrote:
> posix requires that EINVAL be returned if the first parameter specifies
> the cpu-time clock of the calling thread (CLOCK_THREAD_CPUTIME_ID).
> linux returns ENOTSUP instead so we handle this.
> ---
> Applied Szabolcs' suggestion for remapping the return value.
> clock_nanosleep is required to be a cancellation point.
> ---
>  src/time/clock_nanosleep.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/src/time/clock_nanosleep.c b/src/time/clock_nanosleep.c
> index ec87b9e..9e4d9f1 100644
> --- a/src/time/clock_nanosleep.c
> +++ b/src/time/clock_nanosleep.c
> @@ -1,8 +1,10 @@
>  #include <time.h>
> +#include <errno.h>
>  #include "syscall.h"
>  #include "libc.h"
>  
>  int clock_nanosleep(clockid_t clk, int flags, const struct timespec *req, struct timespec *rem)
>  {
> -	return -__syscall_cp(SYS_clock_nanosleep, clk, flags, req, rem);
> +	int r = -__syscall_cp(SYS_clock_nanosleep, clk, flags, req, rem);
> +	return clk == CLOCK_THREAD_CPUTIME_ID ? EINVAL : r;
>  }
> -- 
> 2.10.0

Thanks, and sorry for the delay following up. Committed.

Rich
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic