Module Name: src Committed By: riastradh Date: Sun Dec 19 11:31:11 UTC 2021
Modified Files: src/sys/external/bsd/drm2/include/linux: atomic.h Log Message: linux: Just use __sync_* for xchg and cmpxchg. Easier than figuring out the dance with __builtin_choose_expr to make these work with all types they need to work with. To generate a diff of this commit: cvs rdiff -u -r1.38 -r1.39 src/sys/external/bsd/drm2/include/linux/atomic.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/external/bsd/drm2/include/linux/atomic.h diff -u src/sys/external/bsd/drm2/include/linux/atomic.h:1.38 src/sys/external/bsd/drm2/include/linux/atomic.h:1.39 --- src/sys/external/bsd/drm2/include/linux/atomic.h:1.38 Sun Dec 19 11:26:42 2021 +++ src/sys/external/bsd/drm2/include/linux/atomic.h Sun Dec 19 11:31:11 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: atomic.h,v 1.38 2021/12/19 11:26:42 riastradh Exp $ */ +/* $NetBSD: atomic.h,v 1.39 2021/12/19 11:31:11 riastradh Exp $ */ /*- * Copyright (c) 2013 The NetBSD Foundation, Inc. @@ -38,19 +38,9 @@ #include <asm/barrier.h> -#define xchg(P, V) \ - (sizeof(*(P)) == 4 ? atomic_swap_32((volatile uint32_t *)(P), \ - (uint32_t)(V)) \ - : sizeof(*(P)) == 8 ? atomic_swap_64((volatile uint64_t *)(P), \ - (uint64_t)(V)) \ - : (__builtin_abort(), 0)) - -#define cmpxchg(P, O, N) \ - (sizeof(*(P)) == 4 ? atomic_cas_32((volatile uint32_t *)(P), \ - (uint32_t)(O), (uint32_t)(N)) \ - : sizeof(*(P)) == 8 ? atomic_cas_64((volatile uint64_t *)(P), \ - (uint64_t)(O), (uint64_t)(N)) \ - : (__builtin_abort(), 0)) +/* XXX Hope the GCC __sync builtins work everywhere we care about! */ +#define xchg(P, V) __sync_lock_test_and_set(P, V) +#define cmpxchg(P, O, N) __sync_val_compare_and_swap(P, O, N) /* * atomic (u)int operations