mailing list of musl libc
 help / color / mirror / code / Atom feed
7f0f03e6e36d94f02074e151457104b38618dd0d blob 1102 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
43
44
45
 
#include <pthread.h>
#include <time.h>
#include <errno.h>
#include "futex.h"
#include "syscall.h"
#include "pthread_impl.h"

int __pthread_setcancelstate(int, int *);
int __clock_gettime(clockid_t, struct timespec *);

int __timedwait_cp(volatile int *addr, int val,
	clockid_t clk, const struct timespec *at, int priv)
{
	int r;
	struct timespec to, *top=0;

	if (priv) priv = __futex_private;

	if (at) {
		if (at->tv_nsec >= 1000000000UL) return EINVAL;
		if (__clock_gettime(clk, &to)) return EINVAL;
		to.tv_sec = at->tv_sec - to.tv_sec;
		if ((to.tv_nsec = at->tv_nsec - to.tv_nsec) < 0) {
			to.tv_sec--;
			to.tv_nsec += 1000000000;
		}
		if (to.tv_sec < 0) return ETIMEDOUT;
		top = &to;
	}

	r = -__syscall_cp(SYS_futex, addr, FUTEX_WAIT|priv, val, top);
	if (r != EINTR && r != ETIMEDOUT && r != ECANCELED) r = 0;

	return r;
}

int __timedwait(volatile int *addr, int val,
	clockid_t clk, const struct timespec *at, int priv)
{
	int cs, r;
	__pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cs);
	r = __timedwait_cp(addr, val, clk, at, priv);
	__pthread_setcancelstate(cs, 0);
	return r;
}
debug log:

solving 7f0f03e6 ...
found 7f0f03e6 in https://inbox.vuxu.org/musl/f21ea165c38a4dfc9ac0b9a5b95f2a5622697213.1498228733.git.Jens.Gustedt@inria.fr/
found 13d8465a in https://git.vuxu.org/mirror/musl/
preparing index
index prepared:
100644 13d8465a450552bf418f05ac06a3d81176c5b118	src/thread/__timedwait.c

applying [1/1] https://inbox.vuxu.org/musl/f21ea165c38a4dfc9ac0b9a5b95f2a5622697213.1498228733.git.Jens.Gustedt@inria.fr/
diff --git a/src/thread/__timedwait.c b/src/thread/__timedwait.c
index 13d8465a..7f0f03e6 100644

Checking patch src/thread/__timedwait.c...
Applied patch src/thread/__timedwait.c cleanly.

index at:
100644 7f0f03e6e36d94f02074e151457104b38618dd0d	src/thread/__timedwait.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).