atomic.h (236456) | atomic.h (241374) |
---|---|
1/*- 2 * Copyright (c) 1998 Doug Rabson 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) 1998 Doug Rabson 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/i386/include/atomic.h 236456 2012-06-02 18:10:16Z kib $ | 26 * $FreeBSD: head/sys/i386/include/atomic.h 241374 2012-10-09 14:32:30Z attilio $ |
27 */ 28#ifndef _MACHINE_ATOMIC_H_ 29#define _MACHINE_ATOMIC_H_ 30 31#ifndef _SYS_CDEFS_H_ 32#error this file needs sys/cdefs.h as a prerequisite 33#endif 34 --- 256 unchanged lines hidden (view full) --- 291 * Guide, and not mfence. For UP kernels, however, the cache of the 292 * single processor is always consistent, so we only need to take care 293 * of the compiler. 294 */ 295#define ATOMIC_STORE(TYPE) \ 296static __inline void \ 297atomic_store_rel_##TYPE(volatile u_##TYPE *p, u_##TYPE v)\ 298{ \ | 27 */ 28#ifndef _MACHINE_ATOMIC_H_ 29#define _MACHINE_ATOMIC_H_ 30 31#ifndef _SYS_CDEFS_H_ 32#error this file needs sys/cdefs.h as a prerequisite 33#endif 34 --- 256 unchanged lines hidden (view full) --- 291 * Guide, and not mfence. For UP kernels, however, the cache of the 292 * single processor is always consistent, so we only need to take care 293 * of the compiler. 294 */ 295#define ATOMIC_STORE(TYPE) \ 296static __inline void \ 297atomic_store_rel_##TYPE(volatile u_##TYPE *p, u_##TYPE v)\ 298{ \ |
299 __asm __volatile("" : : : "memory"); \ | 299 __compiler_membar(); \ |
300 *p = v; \ 301} \ 302struct __hack 303 304#if defined(_KERNEL) && !defined(SMP) 305 306#define ATOMIC_LOAD(TYPE, LOP) \ 307static __inline u_##TYPE \ 308atomic_load_acq_##TYPE(volatile u_##TYPE *p) \ 309{ \ 310 u_##TYPE tmp; \ 311 \ 312 tmp = *p; \ | 300 *p = v; \ 301} \ 302struct __hack 303 304#if defined(_KERNEL) && !defined(SMP) 305 306#define ATOMIC_LOAD(TYPE, LOP) \ 307static __inline u_##TYPE \ 308atomic_load_acq_##TYPE(volatile u_##TYPE *p) \ 309{ \ 310 u_##TYPE tmp; \ 311 \ 312 tmp = *p; \ |
313 __asm __volatile("" : : : "memory"); \ | 313 __compiler_membar(); \ |
314 return (tmp); \ 315} \ 316struct __hack 317 318#else /* !(_KERNEL && !SMP) */ 319 320#define ATOMIC_LOAD(TYPE, LOP) \ 321static __inline u_##TYPE \ --- 252 unchanged lines hidden --- | 314 return (tmp); \ 315} \ 316struct __hack 317 318#else /* !(_KERNEL && !SMP) */ 319 320#define ATOMIC_LOAD(TYPE, LOP) \ 321static __inline u_##TYPE \ --- 252 unchanged lines hidden --- |