atomic.h (177276) | atomic.h (185162) |
---|---|
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 177276 2008-03-16 21:20:50Z pjd $ | 26 * $FreeBSD: head/sys/i386/include/atomic.h 185162 2008-11-22 05:55:56Z kmacy $ |
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 | 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 |
35 36#if defined(I686_CPU) 37#define mb() __asm__ __volatile__ ("mfence;": : :"memory") 38#define wmb() __asm__ __volatile__ ("sfence;": : :"memory") 39#define rmb() __asm__ __volatile__ ("lfence;": : :"memory") 40#else |
|
35/* | 41/* |
42 * do we need a serializing instruction? 43 */ 44#define mb() 45#define wmb() 46#define rmb() 47#endif 48 49 50/* |
|
36 * Various simple operations on memory, each of which is atomic in the 37 * presence of interrupts and multiple processors. 38 * 39 * atomic_set_char(P, V) (*(u_char *)(P) |= (V)) 40 * atomic_clear_char(P, V) (*(u_char *)(P) &= ~(V)) 41 * atomic_add_char(P, V) (*(u_char *)(P) += (V)) 42 * atomic_subtract_char(P, V) (*(u_char *)(P) -= (V)) 43 * --- 423 unchanged lines hidden --- | 51 * Various simple operations on memory, each of which is atomic in the 52 * presence of interrupts and multiple processors. 53 * 54 * atomic_set_char(P, V) (*(u_char *)(P) |= (V)) 55 * atomic_clear_char(P, V) (*(u_char *)(P) &= ~(V)) 56 * atomic_add_char(P, V) (*(u_char *)(P) += (V)) 57 * atomic_subtract_char(P, V) (*(u_char *)(P) -= (V)) 58 * --- 423 unchanged lines hidden --- |