/* SPDX-License-Identifier: GPL-2.0 */ /* 32-bit atomic xchg() and cmpxchg() definitions. * * Copyright (C) 1996 David S. Miller (davem@davemloft.net) * Copyright (C) 2000 Anton Blanchard (anton@linuxcare.com.au) * Copyright (C) 2007 Kyle McMartin (kyle@parisc-linux.org) * * Additions by Keith M Wesolowski (wesolows@foobazco.org) based * on asm-parisc/atomic.h Copyright (C) 2000 Philipp Rumpf <prumpf@tux.org>.
*/
/* Emulate cmpxchg() the same way we emulate atomics, * by hashing the object address and indexing into an array * of spinlocks to get a bit of performance... * * See arch/sparc/lib/atomic32.c for implementation. * * Cribbed from <asm-parisc/atomic.h>
*/
/* bug catcher for when unsupported size is used - won't link */ void __cmpxchg_called_with_bad_pointer(void);
u8 __cmpxchg_u8(volatile u8 *m, u8 old, u8 new_);
u16 __cmpxchg_u16(volatile u16 *m, u16 old, u16 new_);
u32 __cmpxchg_u32(volatile u32 *m, u32 old, u32 new_);
/* don't worry...optimizer will get rid of most of this */ staticinlineunsignedlong
__cmpxchg(volatilevoid *ptr, unsignedlong old, unsignedlong new_, int size)
{ return
size == 1 ? __cmpxchg_u8(ptr, old, new_) :
size == 2 ? __cmpxchg_u16(ptr, old, new_) :
size == 4 ? __cmpxchg_u32(ptr, old, new_) :
(__cmpxchg_called_with_bad_pointer(), old);
}
/* * cmpxchg_local and cmpxchg64_local are atomic wrt current CPU. Always make * them available.
*/ #define arch_cmpxchg_local(ptr, o, n) \
((__typeof__(*(ptr)))__generic_cmpxchg_local((ptr), (unsignedlong)(o),\
(unsignedlong)(n), sizeof(*(ptr)))) #define arch_cmpxchg64_local(ptr, o, n) __generic_cmpxchg64_local((ptr), (o), (n))
#endif/* __ARCH_SPARC_CMPXCHG__ */
Messung V0.5
¤ Dauer der Verarbeitung: 0.9 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.