atomic.h (183154) | atomic.h (185029) |
---|---|
1/*- 2 * Copyright (c) 2007 Pawel Jakub Dawidek <pjd@FreeBSD.org> 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 9 unchanged lines hidden (view full) --- 18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 * | 1/*- 2 * Copyright (c) 2007 Pawel Jakub Dawidek <pjd@FreeBSD.org> 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 9 unchanged lines hidden (view full) --- 18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 * |
26 * $FreeBSD: head/sys/cddl/compat/opensolaris/sys/atomic.h 183154 2008-09-18 19:57:06Z imp $ | 26 * $FreeBSD: head/sys/cddl/compat/opensolaris/sys/atomic.h 185029 2008-11-17 20:49:29Z pjd $ |
27 */ 28 29#ifndef _OPENSOLARIS_SYS_ATOMIC_H_ 30#define _OPENSOLARIS_SYS_ATOMIC_H_ 31 32#include <sys/types.h> 33#include <machine/atomic.h> 34 35#define casptr(_a, _b, _c) \ 36 atomic_cmpset_ptr((volatile uintptr_t *)(_a), (uintptr_t)(_b), (uintptr_t) (_c)) 37#define cas32 atomic_cmpset_32 38 39#ifndef __LP64__ 40extern void atomic_add_64(volatile uint64_t *target, int64_t delta); | 27 */ 28 29#ifndef _OPENSOLARIS_SYS_ATOMIC_H_ 30#define _OPENSOLARIS_SYS_ATOMIC_H_ 31 32#include <sys/types.h> 33#include <machine/atomic.h> 34 35#define casptr(_a, _b, _c) \ 36 atomic_cmpset_ptr((volatile uintptr_t *)(_a), (uintptr_t)(_b), (uintptr_t) (_c)) 37#define cas32 atomic_cmpset_32 38 39#ifndef __LP64__ 40extern void atomic_add_64(volatile uint64_t *target, int64_t delta); |
41extern void atomic_dec_64(volatile uint64_t *target); |
|
41extern void *atomic_cas_ptr(volatile void *target, void *cmp, void *newval); 42#endif 43#ifndef __sparc64__ 44extern uint64_t atomic_cas_64(volatile uint64_t *target, uint64_t cmp, 45 uint64_t newval); 46#endif 47extern uint64_t atomic_add_64_nv(volatile uint64_t *target, int64_t delta); 48extern uint8_t atomic_or_8_nv(volatile uint8_t *target, uint8_t value); --- 29 unchanged lines hidden (view full) --- 78} 79 80static __inline uint32_t 81atomic_dec_32_nv(volatile uint32_t *target) 82{ 83 return (atomic_fetchadd_32(target, -1) - 1); 84} 85 | 42extern void *atomic_cas_ptr(volatile void *target, void *cmp, void *newval); 43#endif 44#ifndef __sparc64__ 45extern uint64_t atomic_cas_64(volatile uint64_t *target, uint64_t cmp, 46 uint64_t newval); 47#endif 48extern uint64_t atomic_add_64_nv(volatile uint64_t *target, int64_t delta); 49extern uint8_t atomic_or_8_nv(volatile uint8_t *target, uint8_t value); --- 29 unchanged lines hidden (view full) --- 79} 80 81static __inline uint32_t 82atomic_dec_32_nv(volatile uint32_t *target) 83{ 84 return (atomic_fetchadd_32(target, -1) - 1); 85} 86 |
87#ifdef __LP64__ |
|
86static __inline void | 88static __inline void |
89atomic_dec_64(volatile uint64_t *target) 90{ 91 atomic_subtract_64(target, 1); 92} 93#endif 94 95static __inline void |
|
87atomic_inc_32(volatile uint32_t *target) 88{ 89 atomic_add_32(target, 1); 90} 91 92static __inline uint32_t 93atomic_inc_32_nv(volatile uint32_t *target) 94{ --- 25 unchanged lines hidden --- | 96atomic_inc_32(volatile uint32_t *target) 97{ 98 atomic_add_32(target, 1); 99} 100 101static __inline uint32_t 102atomic_inc_32_nv(volatile uint32_t *target) 103{ --- 25 unchanged lines hidden --- |