Thu Mar 5 17:58:08 2020 UTC ()
Fix userland build by surrounding stuff with #ifdef _KERNEL.

(...Why does this header file get exposed to userland at all?)


(riastradh)
diff -r1.22 -r1.23 src/sys/arch/arm/include/mutex.h
diff -r1.8 -r1.9 src/sys/arch/x86/include/mutex.h

cvs diff -r1.22 -r1.23 src/sys/arch/arm/include/mutex.h (expand / switch to unified diff)

--- src/sys/arch/arm/include/mutex.h 2020/03/05 15:56:55 1.22
+++ src/sys/arch/arm/include/mutex.h 2020/03/05 17:58:08 1.23
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: mutex.h,v 1.22 2020/03/05 15:56:55 riastradh Exp $ */ 1/* $NetBSD: mutex.h,v 1.23 2020/03/05 17:58:08 riastradh Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2002, 2007 The NetBSD Foundation, Inc. 4 * Copyright (c) 2002, 2007 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Jason R. Thorpe and Andrew Doran. 8 * by Jason R. Thorpe and Andrew Doran.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -41,38 +41,40 @@ @@ -41,38 +41,40 @@
41 * MP-safe compare-and-swap. 41 * MP-safe compare-and-swap.
42 * 42 *
43 * So, what we have done is implement simple mutexes using a compare-and-swap. 43 * So, what we have done is implement simple mutexes using a compare-and-swap.
44 * We support pre-ARMv6 by implementing CAS as a restartable atomic sequence 44 * We support pre-ARMv6 by implementing CAS as a restartable atomic sequence
45 * that is checked by the IRQ vector. 45 * that is checked by the IRQ vector.
46 *  46 *
47 */ 47 */
48 48
49struct kmutex { 49struct kmutex {
50 union { 50 union {
51 /* Adaptive mutex */ 51 /* Adaptive mutex */
52 volatile uintptr_t mtxa_owner; /* 0-3 */ 52 volatile uintptr_t mtxa_owner; /* 0-3 */
53 53
 54#ifdef _KERNEL
54 /* Spin mutex */ 55 /* Spin mutex */
55 struct { 56 struct {
56 /* 57 /*
57 * Since the low bit of mtxa_owner is used to flag this 58 * Since the low bit of mtxa_owner is used to flag this
58 * mutex as a spin mutex, we can't use the first byte 59 * mutex as a spin mutex, we can't use the first byte
59 * or the last byte to store the ipl or lock values. 60 * or the last byte to store the ipl or lock values.
60 */ 61 */
61 volatile uint8_t mtxs_dummy; 62 volatile uint8_t mtxs_dummy;
62 ipl_cookie_t mtxs_ipl; 63 ipl_cookie_t mtxs_ipl;
63 __cpu_simple_lock_t mtxs_lock; 64 __cpu_simple_lock_t mtxs_lock;
64 volatile uint8_t mtxs_unused; 65 volatile uint8_t mtxs_unused;
65 } s; 66 } s;
 67#endif
66 } u; 68 } u;
67}; 69};
68 70
69#ifdef __MUTEX_PRIVATE 71#ifdef __MUTEX_PRIVATE
70 72
71#define mtx_owner u.mtxa_owner 73#define mtx_owner u.mtxa_owner
72#define mtx_ipl u.s.mtxs_ipl 74#define mtx_ipl u.s.mtxs_ipl
73#define mtx_lock u.s.mtxs_lock 75#define mtx_lock u.s.mtxs_lock
74 76
75#if 0 77#if 0
76#define __HAVE_MUTEX_STUBS 1 78#define __HAVE_MUTEX_STUBS 1
77#define __HAVE_SPIN_MUTEX_STUBS 1 79#define __HAVE_SPIN_MUTEX_STUBS 1
78#endif 80#endif

cvs diff -r1.8 -r1.9 src/sys/arch/x86/include/mutex.h (expand / switch to unified diff)

--- src/sys/arch/x86/include/mutex.h 2020/03/05 15:56:55 1.8
+++ src/sys/arch/x86/include/mutex.h 2020/03/05 17:58:08 1.9
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: mutex.h,v 1.8 2020/03/05 15:56:55 riastradh Exp $ */ 1/* $NetBSD: mutex.h,v 1.9 2020/03/05 17:58:08 riastradh Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2002, 2006, 2009 The NetBSD Foundation, Inc. 4 * Copyright (c) 2002, 2006, 2009 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Jason R. Thorpe and Andrew Doran. 8 * by Jason R. Thorpe and Andrew Doran.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -25,32 +25,34 @@ @@ -25,32 +25,34 @@
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE. 29 * POSSIBILITY OF SUCH DAMAGE.
30 */ 30 */
31 31
32#ifndef _X86_MUTEX_H_ 32#ifndef _X86_MUTEX_H_
33#define _X86_MUTEX_H_ 33#define _X86_MUTEX_H_
34 34
35struct kmutex { 35struct kmutex {
36 union { 36 union {
37 volatile uintptr_t mtxa_owner; 37 volatile uintptr_t mtxa_owner;
 38#ifdef _KERNEL
38 struct { 39 struct {
39 volatile uint8_t mtxs_dummy; 40 volatile uint8_t mtxs_dummy;
40 ipl_cookie_t mtxs_ipl; 41 ipl_cookie_t mtxs_ipl;
41 __cpu_simple_lock_t mtxs_lock; 42 __cpu_simple_lock_t mtxs_lock;
42 volatile uint8_t mtxs_unused; 43 volatile uint8_t mtxs_unused;
43 } s; 44 } s;
 45#endif
44 } u; 46 } u;
45}; 47};
46 48
47#ifdef __MUTEX_PRIVATE 49#ifdef __MUTEX_PRIVATE
48 50
49#define mtx_owner u.mtxa_owner 51#define mtx_owner u.mtxa_owner
50#define mtx_ipl u.s.mtxs_ipl 52#define mtx_ipl u.s.mtxs_ipl
51#define mtx_lock u.s.mtxs_lock 53#define mtx_lock u.s.mtxs_lock
52 54
53#define __HAVE_MUTEX_STUBS 1 55#define __HAVE_MUTEX_STUBS 1
54#define __HAVE_SPIN_MUTEX_STUBS 1 56#define __HAVE_SPIN_MUTEX_STUBS 1
55#define __HAVE_SIMPLE_MUTEXES 1 57#define __HAVE_SIMPLE_MUTEXES 1
56 58