mailing list of musl libc
 help / color / mirror / code / Atom feed
bbb657b649ec8d7d1ae467e39b71f17b9404ecbf blob 1373 bytes (raw)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
 
#include <time.h>
#include <errno.h>
#include "syscall.h"

#define IS32BIT(x) !((x)+0x80000000ULL>>32)
#define CLAMP(x) (int)(IS32BIT(x) ? (x) : 0x7fffffffU+((0ULL+(x))>>63))

int __clock_nanosleep(clockid_t clk, int flags, const struct timespec *req, struct timespec *rem)
{
	if (clk == CLOCK_THREAD_CPUTIME_ID) return EINVAL;
#ifdef SYS_clock_nanosleep_time64
	static int use_clock_nanosleep_time64 = 1;
	time_t s = req->tv_sec;
	long ns = req->tv_nsec;
	int r = -ENOSYS;
	if (use_clock_nanosleep_time64) {
		if (SYS_clock_nanosleep == SYS_clock_nanosleep_time64 || !IS32BIT(s))
			r = __syscall_cp(SYS_clock_nanosleep_time64, clk, flags,
				((long long[]){s, ns}), rem);
		if (SYS_clock_nanosleep == SYS_clock_nanosleep_time64 || r!=-ENOSYS)
			return -r;
		else use_clock_nanosleep_time64 = 0;
	}
	long long extra = s - CLAMP(s);
	long ts32[2] = { CLAMP(s), ns };
	if (clk == CLOCK_REALTIME && !flags)
		r = __syscall_cp(SYS_nanosleep, &ts32, &ts32);
	else
		r = __syscall_cp(SYS_clock_nanosleep, clk, flags, &ts32, &ts32);
	if (r==-EINTR && rem && !(flags & TIMER_ABSTIME)) {
		rem->tv_sec = ts32[0] + extra;
		rem->tv_nsec = ts32[1];
	}
	return -r;
#else
	if (clk == CLOCK_REALTIME && !flags)
		return -__syscall_cp(SYS_nanosleep, req, rem);
	return -__syscall_cp(SYS_clock_nanosleep, clk, flags, req, rem);
#endif
}

weak_alias(__clock_nanosleep, clock_nanosleep);
debug log:

solving bbb657b6 ...
found bbb657b6 in https://inbox.vuxu.org/musl/CAHHiRUTn__COy59J78MMGSyU52Fyn7HBJdzrM6VvcuFq5Rj6HQ@mail.gmail.com/
found e195499c in https://git.vuxu.org/mirror/musl/
preparing index
index prepared:
100644 e195499cc0729ad4561e5244445f3e570b3aed1d	src/time/clock_nanosleep.c

applying [1/1] https://inbox.vuxu.org/musl/CAHHiRUTn__COy59J78MMGSyU52Fyn7HBJdzrM6VvcuFq5Rj6HQ@mail.gmail.com/
diff --git a/src/time/clock_nanosleep.c b/src/time/clock_nanosleep.c
index e195499c..bbb657b6 100644

Checking patch src/time/clock_nanosleep.c...
Applied patch src/time/clock_nanosleep.c cleanly.

index at:
100644 bbb657b649ec8d7d1ae467e39b71f17b9404ecbf	src/time/clock_nanosleep.c

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

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).