mailing list of musl libc
 help / color / mirror / code / Atom feed
cf6a4787bf8bb29a2330c672b016d962532ef7f5 blob 2503 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
47
48
49
50
51
52
53
54
55
56
 
/*
 * Atomic compare and exchange: Compare OLD with MEM, if identical,
 * store NEW in MEM. Return the initial value in MEM. Success is
 * indicated by comparing RETURN with OLD.
 */
#define __cmpxchg(ptr, old, new, op_suffix) \
({ \
	__typeof((ptr)) __cxc__ptr = (ptr);                             \
	register unsigned long __cxc__rn __asm__("$r62") = (unsigned long) (new); \
	register unsigned long __cxc__ro __asm__("$r63") = (unsigned long) (old); \
	do {                                                            \
		__asm__ __volatile__ (                                  \
			"acswap" #op_suffix " 0[%[rPtr]], $r62r63\n"    \
			: "+r" (__cxc__rn), "+r" (__cxc__ro)            \
			: [rPtr] "r" (__cxc__ptr)                       \
			: "memory");                                    \
		/* Success */                                           \
		if (__cxc__rn) {                                        \
			__cxc__ro = (unsigned long) (old);              \
			break;                                          \
		}                                                       \
		/* We failed, read value */                             \
		__cxc__ro = (unsigned long) *(__cxc__ptr);              \
		if (__cxc__ro != (unsigned long) (old))                 \
			break;                                          \
		/* __cxc__rn has been cloberred by cmpxch result */     \
		__cxc__rn = (unsigned long) (new);                      \
	} while (1);                                                    \
	(__cxc__ro);                                                    \
})

#define cmpxchg(ptr, o, n) \
({ \
	unsigned long __cmpxchg__ret;                                   \
	switch (sizeof(*(ptr))) {                                       \
	case 4:                                                         \
		__cmpxchg__ret = __cmpxchg((ptr), (o), (n), w);         \
		break;                                                  \
	case 8:                                                         \
		__cmpxchg__ret = __cmpxchg((ptr), (o), (n), d);         \
		break;                                                  \
	}                                                               \
	(__typeof(*(ptr))) (__cmpxchg__ret);                            \
})

#define a_cas a_cas
static inline int a_cas(volatile int *p, int t, int s)
{
	return cmpxchg(p, t, s);
}

#define a_cas_p a_cas_p
static inline void *a_cas_p(volatile void *p, void *t, void *s)
{
	return (void *)a_cas(p, (uintptr_t)t, (uintptr_t)s);
}
debug log:

solving cf6a4787 ...
found cf6a4787 in https://inbox.vuxu.org/musl/20220711152322.23418-1-jborne@kalray.eu/

applying [1/1] https://inbox.vuxu.org/musl/20220711152322.23418-1-jborne@kalray.eu/
diff --git a/arch/kvx/atomic_arch.h b/arch/kvx/atomic_arch.h
new file mode 100644
index 00000000..cf6a4787

Checking patch arch/kvx/atomic_arch.h...
Applied patch arch/kvx/atomic_arch.h cleanly.

index at:
100644 cf6a4787bf8bb29a2330c672b016d962532ef7f5	arch/kvx/atomic_arch.h

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