mailing list of musl libc
 help / color / mirror / code / Atom feed
9eaf4156f26d5aeefd9b8c8ad6ddb4996a86320e blob 1041 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
46
 
#include "pthread_impl.h"
#include <threads.h>

int __thrd_wait(volatile int *addr, int val, const struct timespec *at);

int __mtx_timedlock(__mtx_t *restrict mtx, const struct timespec *restrict at)
{
	int r, t;

	if (mtx->_mt_typ == PTHREAD_MUTEX_NORMAL && !a_cas(&mtx->_mt_lck, 0, thrd_busy))
		return thrd_success;

	for (;;) {
		r=__mtx_trylock(mtx);
		if (r != thrd_busy) return r;
		else {
			if (!(r=mtx->_mt_lck) || (r&0x40000000)) continue;
			a_inc(&mtx->_mt_wts);
			t = r | 0x80000000;
			a_cas(&mtx->_mt_lck, r, t);
			r = __thrd_wait(&mtx->_mt_lck, t, at);
			a_dec(&mtx->_mt_wts);
			switch (r) {
			case 0:
				break;
			case EINTR:
				break;
			case EWOULDBLOCK:
				break;
			case ETIMEDOUT:
				return thrd_timedout;
			default:
				return thrd_error;
			}
		}
	}
}

int mtx_timedlock(mtx_t *restrict mut, const struct timespec *restrict at)
{
	__mtx_t * m = __mtx_getref(mut);
	if (!m) return thrd_error;
	int ret = __mtx_timedlock(m, at);
	__mtx_unref(m);
	return ret;
}
debug log:

solving cf52749 ...
found cf52749 in https://inbox.vuxu.org/musl/1408049748.4951.134.camel@eris.loria.fr/ ||
	https://inbox.vuxu.org/musl/1407801532.15134.96.camel@eris.loria.fr/

applying [1/2] https://inbox.vuxu.org/musl/1408049748.4951.134.camel@eris.loria.fr/
diff --git a/src/thread/mtx_timedlock.c b/src/thread/mtx_timedlock.c\r
new file mode 100644\r
index 0000000..cf52749\r

1:7: trailing whitespace.
#include "pthread_impl.h"\r
1:8: trailing whitespace.
#include <threads.h>\r
1:9: trailing whitespace.
\r
1:10: trailing whitespace.
int __thrd_wait(volatile int *addr, int val, const struct timespec *at);\r
1:11: trailing whitespace.
\r
Checking patch src/thread/mtx_timedlock.c...
Applied patch src/thread/mtx_timedlock.c cleanly.
warning: squelched 41 whitespace errors
warning: 46 lines add whitespace errors.

skipping https://inbox.vuxu.org/musl/1407801532.15134.96.camel@eris.loria.fr/ for cf52749
index at:
100644 9eaf4156f26d5aeefd9b8c8ad6ddb4996a86320e	src/thread/mtx_timedlock.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).