Thu, 15 Jan 2015 21:03:48 +0100
Integrate friendly tips from Tor colleagues to make (or not) 4.5 alpha 3;
This includes removal of overloaded (but unused) methods, and addition of
a overlooked call to DataStruct::SetData(nsISupports, uint32_t, bool.)
michael@0 | 1 | /*- |
michael@0 | 2 | * Copyright (c) 2001-2007, by Cisco Systems, Inc. All rights reserved. |
michael@0 | 3 | * Copyright (c) 2008-2012, by Randall Stewart. All rights reserved. |
michael@0 | 4 | * Copyright (c) 2008-2012, by Michael Tuexen. All rights reserved. |
michael@0 | 5 | * Copyright (c) 2008-2012, by Brad Penoff. All rights reserved. |
michael@0 | 6 | * |
michael@0 | 7 | * Redistribution and use in source and binary forms, with or without |
michael@0 | 8 | * modification, are permitted provided that the following conditions are met: |
michael@0 | 9 | * |
michael@0 | 10 | * a) Redistributions of source code must retain the above copyright notice, |
michael@0 | 11 | * this list of conditions and the following disclaimer. |
michael@0 | 12 | * |
michael@0 | 13 | * b) Redistributions in binary form must reproduce the above copyright |
michael@0 | 14 | * notice, this list of conditions and the following disclaimer in |
michael@0 | 15 | * the documentation and/or other materials provided with the distribution. |
michael@0 | 16 | * |
michael@0 | 17 | * c) Neither the name of Cisco Systems, Inc. nor the names of its |
michael@0 | 18 | * contributors may be used to endorse or promote products derived |
michael@0 | 19 | * from this software without specific prior written permission. |
michael@0 | 20 | * |
michael@0 | 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
michael@0 | 22 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, |
michael@0 | 23 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
michael@0 | 24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE |
michael@0 | 25 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
michael@0 | 26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
michael@0 | 27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
michael@0 | 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
michael@0 | 29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
michael@0 | 30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
michael@0 | 31 | * THE POSSIBILITY OF SUCH DAMAGE. |
michael@0 | 32 | */ |
michael@0 | 33 | |
michael@0 | 34 | #ifdef __FreeBSD__ |
michael@0 | 35 | #include <sys/cdefs.h> |
michael@0 | 36 | __FBSDID("$FreeBSD$"); |
michael@0 | 37 | #endif |
michael@0 | 38 | |
michael@0 | 39 | #ifndef _NETINET_SCTP_LOCK_EMPTY_H_ |
michael@0 | 40 | #define _NETINET_SCTP_LOCK_EMPTY_H_ |
michael@0 | 41 | |
michael@0 | 42 | /* |
michael@0 | 43 | * Empty Lock declarations for all other platforms. Pre-process away to |
michael@0 | 44 | * nothing. |
michael@0 | 45 | */ |
michael@0 | 46 | |
michael@0 | 47 | /* __Userspace__ putting lock macros in same order as sctp_lock_bsd.h ...*/ |
michael@0 | 48 | |
michael@0 | 49 | #define SCTP_IPI_COUNT_INIT() |
michael@0 | 50 | |
michael@0 | 51 | #define SCTP_STATLOG_INIT_LOCK() |
michael@0 | 52 | #define SCTP_STATLOG_LOCK() |
michael@0 | 53 | #define SCTP_STATLOG_UNLOCK() |
michael@0 | 54 | #define SCTP_STATLOG_DESTROY() |
michael@0 | 55 | |
michael@0 | 56 | #define SCTP_INP_INFO_LOCK_DESTROY() |
michael@0 | 57 | |
michael@0 | 58 | #define SCTP_INP_INFO_LOCK_INIT() |
michael@0 | 59 | #define SCTP_INP_INFO_RLOCK() |
michael@0 | 60 | #define SCTP_INP_INFO_WLOCK() |
michael@0 | 61 | #define SCTP_INP_INFO_TRYLOCK() 1 |
michael@0 | 62 | #define SCTP_INP_INFO_RUNLOCK() |
michael@0 | 63 | #define SCTP_INP_INFO_WUNLOCK() |
michael@0 | 64 | |
michael@0 | 65 | #define SCTP_WQ_ADDR_INIT() |
michael@0 | 66 | #define SCTP_WQ_ADDR_DESTROY() |
michael@0 | 67 | #define SCTP_WQ_ADDR_LOCK() |
michael@0 | 68 | #define SCTP_WQ_ADDR_UNLOCK() |
michael@0 | 69 | |
michael@0 | 70 | |
michael@0 | 71 | #define SCTP_IPI_ADDR_INIT() |
michael@0 | 72 | #define SCTP_IPI_ADDR_DESTROY() |
michael@0 | 73 | #define SCTP_IPI_ADDR_RLOCK() |
michael@0 | 74 | #define SCTP_IPI_ADDR_WLOCK() |
michael@0 | 75 | #define SCTP_IPI_ADDR_RUNLOCK() |
michael@0 | 76 | #define SCTP_IPI_ADDR_WUNLOCK() |
michael@0 | 77 | |
michael@0 | 78 | #define SCTP_IPI_ITERATOR_WQ_INIT() |
michael@0 | 79 | #define SCTP_IPI_ITERATOR_WQ_DESTROY() |
michael@0 | 80 | #define SCTP_IPI_ITERATOR_WQ_LOCK() |
michael@0 | 81 | #define SCTP_IPI_ITERATOR_WQ_UNLOCK() |
michael@0 | 82 | |
michael@0 | 83 | |
michael@0 | 84 | #define SCTP_IP_PKTLOG_INIT() |
michael@0 | 85 | #define SCTP_IP_PKTLOG_LOCK() |
michael@0 | 86 | #define SCTP_IP_PKTLOG_UNLOCK() |
michael@0 | 87 | #define SCTP_IP_PKTLOG_DESTROY() |
michael@0 | 88 | |
michael@0 | 89 | |
michael@0 | 90 | |
michael@0 | 91 | #define SCTP_INP_READ_INIT(_inp) |
michael@0 | 92 | #define SCTP_INP_READ_DESTROY(_inp) |
michael@0 | 93 | #define SCTP_INP_READ_LOCK(_inp) |
michael@0 | 94 | #define SCTP_INP_READ_UNLOCK(_inp) |
michael@0 | 95 | |
michael@0 | 96 | #define SCTP_INP_LOCK_INIT(_inp) |
michael@0 | 97 | #define SCTP_ASOC_CREATE_LOCK_INIT(_inp) |
michael@0 | 98 | #define SCTP_INP_LOCK_DESTROY(_inp) |
michael@0 | 99 | #define SCTP_ASOC_CREATE_LOCK_DESTROY(_inp) |
michael@0 | 100 | |
michael@0 | 101 | |
michael@0 | 102 | #define SCTP_INP_RLOCK(_inp) |
michael@0 | 103 | #define SCTP_INP_WLOCK(_inp) |
michael@0 | 104 | |
michael@0 | 105 | #define SCTP_INP_LOCK_CONTENDED(_inp) (0) /* Don't know if this is possible */ |
michael@0 | 106 | |
michael@0 | 107 | #define SCTP_INP_READ_CONTENDED(_inp) (0) /* Don't know if this is possible */ |
michael@0 | 108 | |
michael@0 | 109 | #define SCTP_ASOC_CREATE_LOCK_CONTENDED(_inp) (0) /* Don't know if this is possible */ |
michael@0 | 110 | |
michael@0 | 111 | |
michael@0 | 112 | #define SCTP_TCB_SEND_LOCK_INIT(_tcb) |
michael@0 | 113 | #define SCTP_TCB_SEND_LOCK_DESTROY(_tcb) |
michael@0 | 114 | #define SCTP_TCB_SEND_LOCK(_tcb) |
michael@0 | 115 | #define SCTP_TCB_SEND_UNLOCK(_tcb) |
michael@0 | 116 | |
michael@0 | 117 | #define SCTP_INP_INCR_REF(_inp) |
michael@0 | 118 | #define SCTP_INP_DECR_REF(_inp) |
michael@0 | 119 | |
michael@0 | 120 | #define SCTP_ASOC_CREATE_LOCK(_inp) |
michael@0 | 121 | |
michael@0 | 122 | #define SCTP_INP_RUNLOCK(_inp) |
michael@0 | 123 | #define SCTP_INP_WUNLOCK(_inp) |
michael@0 | 124 | #define SCTP_ASOC_CREATE_UNLOCK(_inp) |
michael@0 | 125 | |
michael@0 | 126 | |
michael@0 | 127 | #define SCTP_TCB_LOCK_INIT(_tcb) |
michael@0 | 128 | #define SCTP_TCB_LOCK_DESTROY(_tcb) |
michael@0 | 129 | #define SCTP_TCB_LOCK(_tcb) |
michael@0 | 130 | #define SCTP_TCB_TRYLOCK(_tcb) 1 |
michael@0 | 131 | #define SCTP_TCB_UNLOCK(_tcb) |
michael@0 | 132 | #define SCTP_TCB_UNLOCK_IFOWNED(_tcb) |
michael@0 | 133 | #define SCTP_TCB_LOCK_ASSERT(_tcb) |
michael@0 | 134 | |
michael@0 | 135 | |
michael@0 | 136 | |
michael@0 | 137 | #define SCTP_ITERATOR_LOCK_INIT() |
michael@0 | 138 | #define SCTP_ITERATOR_LOCK() |
michael@0 | 139 | #define SCTP_ITERATOR_UNLOCK() |
michael@0 | 140 | #define SCTP_ITERATOR_LOCK_DESTROY() |
michael@0 | 141 | |
michael@0 | 142 | |
michael@0 | 143 | |
michael@0 | 144 | #define SCTP_INCR_EP_COUNT() \ |
michael@0 | 145 | do { \ |
michael@0 | 146 | sctppcbinfo.ipi_count_ep++; \ |
michael@0 | 147 | } while (0) |
michael@0 | 148 | |
michael@0 | 149 | #define SCTP_DECR_EP_COUNT() \ |
michael@0 | 150 | do { \ |
michael@0 | 151 | sctppcbinfo.ipi_count_ep--; \ |
michael@0 | 152 | } while (0) |
michael@0 | 153 | |
michael@0 | 154 | #define SCTP_INCR_ASOC_COUNT() \ |
michael@0 | 155 | do { \ |
michael@0 | 156 | sctppcbinfo.ipi_count_asoc++; \ |
michael@0 | 157 | } while (0) |
michael@0 | 158 | |
michael@0 | 159 | #define SCTP_DECR_ASOC_COUNT() \ |
michael@0 | 160 | do { \ |
michael@0 | 161 | sctppcbinfo.ipi_count_asoc--; \ |
michael@0 | 162 | } while (0) |
michael@0 | 163 | |
michael@0 | 164 | #define SCTP_INCR_LADDR_COUNT() \ |
michael@0 | 165 | do { \ |
michael@0 | 166 | sctppcbinfo.ipi_count_laddr++; \ |
michael@0 | 167 | } while (0) |
michael@0 | 168 | |
michael@0 | 169 | #define SCTP_DECR_LADDR_COUNT() \ |
michael@0 | 170 | do { \ |
michael@0 | 171 | sctppcbinfo.ipi_count_laddr--; \ |
michael@0 | 172 | } while (0) |
michael@0 | 173 | |
michael@0 | 174 | #define SCTP_INCR_RADDR_COUNT() \ |
michael@0 | 175 | do { \ |
michael@0 | 176 | sctppcbinfo.ipi_count_raddr++; \ |
michael@0 | 177 | } while (0) |
michael@0 | 178 | |
michael@0 | 179 | #define SCTP_DECR_RADDR_COUNT() \ |
michael@0 | 180 | do { \ |
michael@0 | 181 | sctppcbinfo.ipi_count_raddr--; \ |
michael@0 | 182 | } while (0) |
michael@0 | 183 | |
michael@0 | 184 | #define SCTP_INCR_CHK_COUNT() \ |
michael@0 | 185 | do { \ |
michael@0 | 186 | sctppcbinfo.ipi_count_chunk++; \ |
michael@0 | 187 | } while (0) |
michael@0 | 188 | |
michael@0 | 189 | #define SCTP_DECR_CHK_COUNT() \ |
michael@0 | 190 | do { \ |
michael@0 | 191 | sctppcbinfo.ipi_count_chunk--; \ |
michael@0 | 192 | } while (0) |
michael@0 | 193 | |
michael@0 | 194 | #define SCTP_INCR_READQ_COUNT() \ |
michael@0 | 195 | do { \ |
michael@0 | 196 | sctppcbinfo.ipi_count_readq++; \ |
michael@0 | 197 | } while (0) |
michael@0 | 198 | |
michael@0 | 199 | #define SCTP_DECR_READQ_COUNT() \ |
michael@0 | 200 | do { \ |
michael@0 | 201 | sctppcbinfo.ipi_count_readq--; \ |
michael@0 | 202 | } while (0) |
michael@0 | 203 | |
michael@0 | 204 | #define SCTP_INCR_STRMOQ_COUNT() \ |
michael@0 | 205 | do { \ |
michael@0 | 206 | sctppcbinfo.ipi_count_strmoq++; \ |
michael@0 | 207 | } while (0) |
michael@0 | 208 | |
michael@0 | 209 | #define SCTP_DECR_STRMOQ_COUNT() \ |
michael@0 | 210 | do { \ |
michael@0 | 211 | sctppcbinfo.ipi_count_strmoq--; \ |
michael@0 | 212 | } while (0) |
michael@0 | 213 | |
michael@0 | 214 | |
michael@0 | 215 | /* not sure if __Userspace__ needs these (but copied nonetheless...) */ |
michael@0 | 216 | #if defined(SCTP_SO_LOCK_TESTING) |
michael@0 | 217 | #define SCTP_INP_SO(sctpinp) (sctpinp)->ip_inp.inp.inp_socket |
michael@0 | 218 | #define SCTP_SOCKET_LOCK(so, refcnt) |
michael@0 | 219 | #define SCTP_SOCKET_UNLOCK(so, refcnt) |
michael@0 | 220 | #endif |
michael@0 | 221 | |
michael@0 | 222 | |
michael@0 | 223 | /* these were in sctp_lock_empty.h but aren't in sctp_lock_bsd.h ... */ |
michael@0 | 224 | #if 0 |
michael@0 | 225 | #define SCTP_IPI_ADDR_LOCK() |
michael@0 | 226 | #define SCTP_IPI_ADDR_UNLOCK() |
michael@0 | 227 | #endif |
michael@0 | 228 | |
michael@0 | 229 | |
michael@0 | 230 | /* These were in sctp_lock_empty.h because they were commented out within |
michael@0 | 231 | * within user_include/user_socketvar.h . If they are NOT commented out |
michael@0 | 232 | * in user_socketvar.h (because that seems the more natural place for them |
michael@0 | 233 | * to live), then change this "if" to 0. Keep the "if" as 1 if these ARE |
michael@0 | 234 | * indeed commented out in user_socketvar.h . |
michael@0 | 235 | * |
michael@0 | 236 | * This modularity is kept so this file can easily be chosen as an alternative |
michael@0 | 237 | * to SCTP_PROCESS_LEVEL_LOCKS. If one defines SCTP_PROCESS_LEVEL_LOCKS in |
michael@0 | 238 | * user_include/opt_sctp.h, then the file sctp_process_lock.h (which we didn't |
michael@0 | 239 | * implement) is used, and that declares these locks already (so using |
michael@0 | 240 | * SCTP_PROCESS_LEVEL_LOCKS *requires* that these defintions be commented out |
michael@0 | 241 | * in user_socketvar.h). |
michael@0 | 242 | */ |
michael@0 | 243 | #if 1 |
michael@0 | 244 | #define SOCK_LOCK(_so) |
michael@0 | 245 | #define SOCK_UNLOCK(_so) |
michael@0 | 246 | #define SOCKBUF_LOCK(_so_buf) |
michael@0 | 247 | #define SOCKBUF_UNLOCK(_so_buf) |
michael@0 | 248 | #define SOCKBUF_LOCK_ASSERT(_so_buf) |
michael@0 | 249 | #endif |
michael@0 | 250 | |
michael@0 | 251 | #endif |