Fresh pull from upstream
[librecmc/librecmc.git] / toolchain / musl / patches / 049-fix-clock_nanosleep-error-case.patch
1 From 3ca2d2d4aef910663785fe232d7d2127a22d8a84 Mon Sep 17 00:00:00 2001
2 From: Daniel Sabogal <dsabogalcc@gmail.com>
3 Date: Sat, 17 Sep 2016 12:05:45 -0400
4 Subject: fix clock_nanosleep error case
5
6 posix requires that EINVAL be returned if the first parameter specifies
7 the cpu-time clock of the calling thread (CLOCK_THREAD_CPUTIME_ID).
8 linux returns ENOTSUP instead so we handle this.
9 ---
10  src/time/clock_nanosleep.c | 4 +++-
11  1 file changed, 3 insertions(+), 1 deletion(-)
12
13 diff --git a/src/time/clock_nanosleep.c b/src/time/clock_nanosleep.c
14 index ec87b9e..9e4d9f1 100644
15 --- a/src/time/clock_nanosleep.c
16 +++ b/src/time/clock_nanosleep.c
17 @@ -1,8 +1,10 @@
18  #include <time.h>
19 +#include <errno.h>
20  #include "syscall.h"
21  #include "libc.h"
22  
23  int clock_nanosleep(clockid_t clk, int flags, const struct timespec *req, struct timespec *rem)
24  {
25 -       return -__syscall_cp(SYS_clock_nanosleep, clk, flags, req, rem);
26 +       int r = -__syscall_cp(SYS_clock_nanosleep, clk, flags, req, rem);
27 +       return clk == CLOCK_THREAD_CPUTIME_ID ? EINVAL : r;
28  }
29 -- 
30 cgit v0.11.2