2 * SPDX-License-Identifier: BSD-3-Clause
4 * Copyright (c) 2001-2007, by Cisco Systems, Inc. All rights reserved.
5 * Copyright (c) 2008-2012, by Randall Stewart. All rights reserved.
6 * Copyright (c) 2008-2012, by Michael Tuexen. All rights reserved.
7 * Copyright (c) 2008-2012, by Brad Penoff. All rights reserved.
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions are met:
12 * a) Redistributions of source code must retain the above copyright notice,
13 * this list of conditions and the following disclaimer.
15 * b) Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in
17 * the documentation and/or other materials provided with the distribution.
19 * c) Neither the name of Cisco Systems, Inc. nor the names of its
20 * contributors may be used to endorse or promote products derived
21 * from this software without specific prior written permission.
23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
25 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
27 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
30 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
31 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
32 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
33 * THE POSSIBILITY OF SUCH DAMAGE.
36 #if defined(__FreeBSD__) && !defined(__Userspace__)
37 #include <sys/cdefs.h>
38 __FBSDID("$FreeBSD$");
41 #ifndef _NETINET_SCTP_LOCK_EMPTY_H_
42 #define _NETINET_SCTP_LOCK_EMPTY_H_
45 * Empty Lock declarations for all other platforms. Pre-process away to
49 /* __Userspace__ putting lock macros in same order as sctp_lock_bsd.h ...*/
51 #define SCTP_IPI_COUNT_INIT()
53 #define SCTP_STATLOG_INIT_LOCK()
54 #define SCTP_STATLOG_LOCK()
55 #define SCTP_STATLOG_UNLOCK()
56 #define SCTP_STATLOG_DESTROY()
58 #define SCTP_INP_INFO_LOCK_DESTROY()
60 #define SCTP_INP_INFO_LOCK_INIT()
61 #define SCTP_INP_INFO_RLOCK()
62 #define SCTP_INP_INFO_WLOCK()
63 #define SCTP_INP_INFO_TRYLOCK() 1
64 #define SCTP_INP_INFO_RUNLOCK()
65 #define SCTP_INP_INFO_WUNLOCK()
67 #define SCTP_WQ_ADDR_INIT()
68 #define SCTP_WQ_ADDR_DESTROY()
69 #define SCTP_WQ_ADDR_LOCK()
70 #define SCTP_WQ_ADDR_UNLOCK()
71 #define SCTP_WQ_ADDR_LOCK_ASSERT()
73 #define SCTP_IPI_ADDR_INIT()
74 #define SCTP_IPI_ADDR_DESTROY()
75 #define SCTP_IPI_ADDR_RLOCK()
76 #define SCTP_IPI_ADDR_WLOCK()
77 #define SCTP_IPI_ADDR_RUNLOCK()
78 #define SCTP_IPI_ADDR_WUNLOCK()
79 #define SCTP_IPI_ADDR_LOCK_ASSERT()
80 #define SCTP_IPI_ADDR_WLOCK_ASSERT()
82 #define SCTP_IPI_ITERATOR_WQ_INIT()
83 #define SCTP_IPI_ITERATOR_WQ_DESTROY()
84 #define SCTP_IPI_ITERATOR_WQ_LOCK()
85 #define SCTP_IPI_ITERATOR_WQ_UNLOCK()
87 #define SCTP_IP_PKTLOG_INIT()
88 #define SCTP_IP_PKTLOG_LOCK()
89 #define SCTP_IP_PKTLOG_UNLOCK()
90 #define SCTP_IP_PKTLOG_DESTROY()
92 #define SCTP_INP_READ_INIT(_inp)
93 #define SCTP_INP_READ_DESTROY(_inp)
94 #define SCTP_INP_READ_LOCK(_inp)
95 #define SCTP_INP_READ_UNLOCK(_inp)
97 #define SCTP_INP_LOCK_INIT(_inp)
98 #define SCTP_ASOC_CREATE_LOCK_INIT(_inp)
99 #define SCTP_INP_LOCK_DESTROY(_inp)
100 #define SCTP_ASOC_CREATE_LOCK_DESTROY(_inp)
102 #define SCTP_INP_RLOCK(_inp)
103 #define SCTP_INP_WLOCK(_inp)
104 #define SCTP_INP_RLOCK_ASSERT(_inp)
105 #define SCTP_INP_WLOCK_ASSERT(_inp)
107 #define SCTP_INP_LOCK_CONTENDED(_inp) (0) /* Don't know if this is possible */
109 #define SCTP_INP_READ_CONTENDED(_inp) (0) /* Don't know if this is possible */
111 #define SCTP_ASOC_CREATE_LOCK_CONTENDED(_inp) (0) /* Don't know if this is possible */
114 #define SCTP_TCB_SEND_LOCK_INIT(_tcb)
115 #define SCTP_TCB_SEND_LOCK_DESTROY(_tcb)
116 #define SCTP_TCB_SEND_LOCK(_tcb)
117 #define SCTP_TCB_SEND_UNLOCK(_tcb)
119 #define SCTP_INP_INCR_REF(_inp)
120 #define SCTP_INP_DECR_REF(_inp)
122 #define SCTP_ASOC_CREATE_LOCK(_inp)
124 #define SCTP_INP_RUNLOCK(_inp)
125 #define SCTP_INP_WUNLOCK(_inp)
126 #define SCTP_ASOC_CREATE_UNLOCK(_inp)
129 #define SCTP_TCB_LOCK_INIT(_tcb)
130 #define SCTP_TCB_LOCK_DESTROY(_tcb)
131 #define SCTP_TCB_LOCK(_tcb)
132 #define SCTP_TCB_TRYLOCK(_tcb) 1
133 #define SCTP_TCB_UNLOCK(_tcb)
134 #define SCTP_TCB_UNLOCK_IFOWNED(_tcb)
135 #define SCTP_TCB_LOCK_ASSERT(_tcb)
139 #define SCTP_ITERATOR_LOCK_INIT()
140 #define SCTP_ITERATOR_LOCK()
141 #define SCTP_ITERATOR_UNLOCK()
142 #define SCTP_ITERATOR_LOCK_DESTROY()
146 #define SCTP_INCR_EP_COUNT() \
148 sctppcbinfo.ipi_count_ep++; \
151 #define SCTP_DECR_EP_COUNT() \
153 sctppcbinfo.ipi_count_ep--; \
156 #define SCTP_INCR_ASOC_COUNT() \
158 sctppcbinfo.ipi_count_asoc++; \
161 #define SCTP_DECR_ASOC_COUNT() \
163 sctppcbinfo.ipi_count_asoc--; \
166 #define SCTP_INCR_LADDR_COUNT() \
168 sctppcbinfo.ipi_count_laddr++; \
171 #define SCTP_DECR_LADDR_COUNT() \
173 sctppcbinfo.ipi_count_laddr--; \
176 #define SCTP_INCR_RADDR_COUNT() \
178 sctppcbinfo.ipi_count_raddr++; \
181 #define SCTP_DECR_RADDR_COUNT() \
183 sctppcbinfo.ipi_count_raddr--; \
186 #define SCTP_INCR_CHK_COUNT() \
188 sctppcbinfo.ipi_count_chunk++; \
191 #define SCTP_DECR_CHK_COUNT() \
193 sctppcbinfo.ipi_count_chunk--; \
196 #define SCTP_INCR_READQ_COUNT() \
198 sctppcbinfo.ipi_count_readq++; \
201 #define SCTP_DECR_READQ_COUNT() \
203 sctppcbinfo.ipi_count_readq--; \
206 #define SCTP_INCR_STRMOQ_COUNT() \
208 sctppcbinfo.ipi_count_strmoq++; \
211 #define SCTP_DECR_STRMOQ_COUNT() \
213 sctppcbinfo.ipi_count_strmoq--; \
217 /* these were in sctp_lock_empty.h but aren't in sctp_lock_bsd.h ... */
219 #define SCTP_IPI_ADDR_LOCK()
220 #define SCTP_IPI_ADDR_UNLOCK()
224 /* These were in sctp_lock_empty.h because they were commented out within
225 * within user_include/user_socketvar.h . If they are NOT commented out
226 * in user_socketvar.h (because that seems the more natural place for them
227 * to live), then change this "if" to 0. Keep the "if" as 1 if these ARE
228 * indeed commented out in user_socketvar.h .
230 * This modularity is kept so this file can easily be chosen as an alternative
231 * to SCTP_PROCESS_LEVEL_LOCKS. If one defines SCTP_PROCESS_LEVEL_LOCKS in
232 * user_include/opt_sctp.h, then the file sctp_process_lock.h (which we didn't
233 * implement) is used, and that declares these locks already (so using
234 * SCTP_PROCESS_LEVEL_LOCKS *requires* that these defintions be commented out
235 * in user_socketvar.h).
238 #define SOCK_LOCK(_so)
239 #define SOCK_UNLOCK(_so)
240 #define SOCKBUF_LOCK(_so_buf)
241 #define SOCKBUF_UNLOCK(_so_buf)
242 #define SOCKBUF_LOCK_ASSERT(_so_buf)