Deleted Added
full compact
pcpu.h (167429) pcpu.h (170291)
1/*-
2 * Copyright (c) Peter Wemm <peter@netplex.com.au>
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) Peter Wemm <peter@netplex.com.au>
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/amd64/include/pcpu.h 167429 2007-03-11 05:54:29Z alc $
26 * $FreeBSD: head/sys/amd64/include/pcpu.h 170291 2007-06-04 21:38:48Z attilio $
27 */
28
29#ifndef _MACHINE_PCPU_H_
30#define _MACHINE_PCPU_H_
31
32#ifndef _SYS_CDEFS_H_
33#error "sys/cdefs.h is a prerequisite for this file"
34#endif

--- 16 unchanged lines hidden (view full) ---

51 u_int pc_apic_id; \
52 u_int pc_acpi_id /* ACPI CPU id */
53
54#ifdef lint
55
56extern struct pcpu *pcpup;
57
58#define PCPU_GET(member) (pcpup->pc_ ## member)
27 */
28
29#ifndef _MACHINE_PCPU_H_
30#define _MACHINE_PCPU_H_
31
32#ifndef _SYS_CDEFS_H_
33#error "sys/cdefs.h is a prerequisite for this file"
34#endif

--- 16 unchanged lines hidden (view full) ---

51 u_int pc_apic_id; \
52 u_int pc_acpi_id /* ACPI CPU id */
53
54#ifdef lint
55
56extern struct pcpu *pcpup;
57
58#define PCPU_GET(member) (pcpup->pc_ ## member)
59#define PCPU_LAZY_INC(member) (++pcpup->pc_ ## member)
59#define PCPU_ADD(member, val) (pcpup->pc_ ## member += (val))
60#define PCPU_INC(member) PCPU_ADD(member, 1)
60#define PCPU_PTR(member) (&pcpup->pc_ ## member)
61#define PCPU_SET(member, val) (pcpup->pc_ ## member = (val))
62
63#elif defined(__GNUCLIKE_ASM) && defined(__GNUCLIKE___TYPEOF)
64
65/*
66 * Evaluates to the byte offset of the per-cpu variable name.
67 */

--- 37 unchanged lines hidden (view full) ---

105 *(struct __s *)(void *)&__res = __s; \
106 } else { \
107 __res = *__PCPU_PTR(name); \
108 } \
109 __res; \
110})
111
112/*
61#define PCPU_PTR(member) (&pcpup->pc_ ## member)
62#define PCPU_SET(member, val) (pcpup->pc_ ## member = (val))
63
64#elif defined(__GNUCLIKE_ASM) && defined(__GNUCLIKE___TYPEOF)
65
66/*
67 * Evaluates to the byte offset of the per-cpu variable name.
68 */

--- 37 unchanged lines hidden (view full) ---

106 *(struct __s *)(void *)&__res = __s; \
107 } else { \
108 __res = *__PCPU_PTR(name); \
109 } \
110 __res; \
111})
112
113/*
114 * Adds the value to the per-cpu counter name. The implementation
115 * must be atomic with respect to interrupts.
116 */
117#define __PCPU_ADD(name, val) do { \
118 __pcpu_type(name) __val; \
119 struct __s { \
120 u_char __b[MIN(sizeof(__pcpu_type(name)), 8)]; \
121 } __s; \
122 \
123 __val = (val); \
124 if (sizeof(__val) == 1 || sizeof(__val) == 2 || \
125 sizeof(__val) == 4 || sizeof(__val) == 8) { \
126 __s = *(struct __s *)(void *)&__val; \
127 __asm __volatile("add %1,%%gs:%0" \
128 : "=m" (*(struct __s *)(__pcpu_offset(name))) \
129 : "r" (__s)); \
130 } else \
131 *__PCPU_PTR(name) += __val; \
132} while (0)
133
134/*
113 * Increments the value of the per-cpu counter name. The implementation
114 * must be atomic with respect to interrupts.
115 */
135 * Increments the value of the per-cpu counter name. The implementation
136 * must be atomic with respect to interrupts.
137 */
116#define __PCPU_LAZY_INC(name) do { \
138#define __PCPU_INC(name) do { \
117 CTASSERT(sizeof(__pcpu_type(name)) == 1 || \
118 sizeof(__pcpu_type(name)) == 2 || \
119 sizeof(__pcpu_type(name)) == 4 || \
120 sizeof(__pcpu_type(name)) == 8); \
121 if (sizeof(__pcpu_type(name)) == 1) { \
122 __asm __volatile("incb %%gs:%0" \
123 : "=m" (*(__pcpu_type(name) *)(__pcpu_offset(name)))\
124 : "m" (*(__pcpu_type(name) *)(__pcpu_offset(name))));\

--- 29 unchanged lines hidden (view full) ---

154 : "=m" (*(struct __s *)(__pcpu_offset(name))) \
155 : "r" (__s)); \
156 } else { \
157 *__PCPU_PTR(name) = __val; \
158 } \
159}
160
161#define PCPU_GET(member) __PCPU_GET(pc_ ## member)
139 CTASSERT(sizeof(__pcpu_type(name)) == 1 || \
140 sizeof(__pcpu_type(name)) == 2 || \
141 sizeof(__pcpu_type(name)) == 4 || \
142 sizeof(__pcpu_type(name)) == 8); \
143 if (sizeof(__pcpu_type(name)) == 1) { \
144 __asm __volatile("incb %%gs:%0" \
145 : "=m" (*(__pcpu_type(name) *)(__pcpu_offset(name)))\
146 : "m" (*(__pcpu_type(name) *)(__pcpu_offset(name))));\

--- 29 unchanged lines hidden (view full) ---

176 : "=m" (*(struct __s *)(__pcpu_offset(name))) \
177 : "r" (__s)); \
178 } else { \
179 *__PCPU_PTR(name) = __val; \
180 } \
181}
182
183#define PCPU_GET(member) __PCPU_GET(pc_ ## member)
162#define PCPU_LAZY_INC(member) __PCPU_LAZY_INC(pc_ ## member)
184#define PCPU_ADD(member, val) __PCPU_ADD(pc_ ## member, val)
185#define PCPU_INC(member) __PCPU_INC(pc_ ## member)
163#define PCPU_PTR(member) __PCPU_PTR(pc_ ## member)
164#define PCPU_SET(member, val) __PCPU_SET(pc_ ## member, val)
165
166static __inline struct thread *
167__curthread(void)
168{
169 struct thread *td;
170

--- 14 unchanged lines hidden ---
186#define PCPU_PTR(member) __PCPU_PTR(pc_ ## member)
187#define PCPU_SET(member, val) __PCPU_SET(pc_ ## member, val)
188
189static __inline struct thread *
190__curthread(void)
191{
192 struct thread *td;
193

--- 14 unchanged lines hidden ---