Move files from gst-plugins-bad into the "subprojects/gst-plugins-bad/" subdir
[platform/upstream/gstreamer.git] / subprojects / gst-plugins-bad / ext / sctp / usrsctp / usrsctplib / netinet / sctp_lock_userspace.h
1 /*-
2  * SPDX-License-Identifier: BSD-3-Clause
3  *
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.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions are met:
11  *
12  * a) Redistributions of source code must retain the above copyright notice,
13  *   this list of conditions and the following disclaimer.
14  *
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.
18  *
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.
22  *
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.
34  */
35
36 #if defined(__FreeBSD__) && !defined(__Userspace__)
37 #include <sys/cdefs.h>
38 __FBSDID("$FreeBSD$");
39 #endif
40
41 #ifndef _NETINET_SCTP_LOCK_EMPTY_H_
42 #define _NETINET_SCTP_LOCK_EMPTY_H_
43
44 /*
45  * Empty Lock declarations for all other platforms. Pre-process away to
46  * nothing.
47  */
48
49 /* __Userspace__ putting lock macros in same order as sctp_lock_bsd.h ...*/
50
51 #define SCTP_IPI_COUNT_INIT()
52
53 #define SCTP_STATLOG_INIT_LOCK()
54 #define SCTP_STATLOG_LOCK()
55 #define SCTP_STATLOG_UNLOCK()
56 #define SCTP_STATLOG_DESTROY()
57
58 #define SCTP_INP_INFO_LOCK_DESTROY()
59
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()
66
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()
72
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()
81
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()
86
87 #define SCTP_IP_PKTLOG_INIT()
88 #define SCTP_IP_PKTLOG_LOCK()
89 #define SCTP_IP_PKTLOG_UNLOCK()
90 #define SCTP_IP_PKTLOG_DESTROY()
91
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)
96
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)
101
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)
106
107 #define SCTP_INP_LOCK_CONTENDED(_inp) (0) /* Don't know if this is possible */
108
109 #define SCTP_INP_READ_CONTENDED(_inp) (0) /* Don't know if this is possible */
110
111 #define SCTP_ASOC_CREATE_LOCK_CONTENDED(_inp) (0) /* Don't know if this is possible */
112
113
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)
118
119 #define SCTP_INP_INCR_REF(_inp)
120 #define SCTP_INP_DECR_REF(_inp)
121
122 #define SCTP_ASOC_CREATE_LOCK(_inp)
123
124 #define SCTP_INP_RUNLOCK(_inp)
125 #define SCTP_INP_WUNLOCK(_inp)
126 #define SCTP_ASOC_CREATE_UNLOCK(_inp)
127
128
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)
136
137
138
139 #define SCTP_ITERATOR_LOCK_INIT()
140 #define SCTP_ITERATOR_LOCK()
141 #define SCTP_ITERATOR_UNLOCK()
142 #define SCTP_ITERATOR_LOCK_DESTROY()
143
144
145
146 #define SCTP_INCR_EP_COUNT() \
147                 do { \
148                        sctppcbinfo.ipi_count_ep++; \
149                 } while (0)
150
151 #define SCTP_DECR_EP_COUNT() \
152                 do { \
153                        sctppcbinfo.ipi_count_ep--; \
154                 } while (0)
155
156 #define SCTP_INCR_ASOC_COUNT() \
157                 do { \
158                        sctppcbinfo.ipi_count_asoc++; \
159                 } while (0)
160
161 #define SCTP_DECR_ASOC_COUNT() \
162                 do { \
163                        sctppcbinfo.ipi_count_asoc--; \
164                 } while (0)
165
166 #define SCTP_INCR_LADDR_COUNT() \
167                 do { \
168                        sctppcbinfo.ipi_count_laddr++; \
169                 } while (0)
170
171 #define SCTP_DECR_LADDR_COUNT() \
172                 do { \
173                        sctppcbinfo.ipi_count_laddr--; \
174                 } while (0)
175
176 #define SCTP_INCR_RADDR_COUNT() \
177                 do { \
178                        sctppcbinfo.ipi_count_raddr++; \
179                 } while (0)
180
181 #define SCTP_DECR_RADDR_COUNT() \
182                 do { \
183                        sctppcbinfo.ipi_count_raddr--; \
184                 } while (0)
185
186 #define SCTP_INCR_CHK_COUNT() \
187                 do { \
188                        sctppcbinfo.ipi_count_chunk++; \
189                 } while (0)
190
191 #define SCTP_DECR_CHK_COUNT() \
192                 do { \
193                        sctppcbinfo.ipi_count_chunk--; \
194                 } while (0)
195
196 #define SCTP_INCR_READQ_COUNT() \
197                 do { \
198                        sctppcbinfo.ipi_count_readq++; \
199                 } while (0)
200
201 #define SCTP_DECR_READQ_COUNT() \
202                 do { \
203                        sctppcbinfo.ipi_count_readq--; \
204                 } while (0)
205
206 #define SCTP_INCR_STRMOQ_COUNT() \
207                 do { \
208                        sctppcbinfo.ipi_count_strmoq++; \
209                 } while (0)
210
211 #define SCTP_DECR_STRMOQ_COUNT() \
212                 do { \
213                        sctppcbinfo.ipi_count_strmoq--; \
214                 } while (0)
215
216
217 /* these were in sctp_lock_empty.h but aren't in sctp_lock_bsd.h ... */
218 #if 0
219 #define SCTP_IPI_ADDR_LOCK()
220 #define SCTP_IPI_ADDR_UNLOCK()
221 #endif
222
223
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 .
229  *
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).
236  */
237 #if 1
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)
243 #endif
244
245 #endif