Print this page
5045 use atomic_{inc,dec}_* instead of atomic_add_*
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/uts/common/fs/sockfs/nl7curi.h
+++ new/usr/src/uts/common/fs/sockfs/nl7curi.h
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
↓ open down ↓ |
19 lines elided |
↑ open up ↑ |
20 20 */
21 21
22 22 /*
23 23 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
24 24 * Use is subject to license terms.
25 25 */
26 26
27 27 #ifndef _SYS_SOCKFS_NL7CURI_H
28 28 #define _SYS_SOCKFS_NL7CURI_H
29 29
30 -#pragma ident "%Z%%M% %I% %E% SMI"
31 -
32 30 #ifdef __cplusplus
33 31 extern "C" {
34 32 #endif
35 33
36 34 #include <sys/types.h>
37 35 #include <sys/atomic.h>
38 36 #include <sys/cmn_err.h>
39 37 #include <sys/stropts.h>
40 38 #include <sys/socket.h>
41 39 #include <sys/socketvar.h>
42 40
43 41 #undef PROMIF_DEBUG
44 42
45 43 /*
46 44 * Some usefull chararcter macros:
47 45 */
48 46
49 47 #ifndef tolower
50 48 #define tolower(c) ((c) >= 'A' && (c) <= 'Z' ? (c) | 0x20 : (c))
51 49 #endif
52 50
53 51 #ifndef isdigit
54 52 #define isdigit(c) ((c) >= '0' && (c) <= '9')
55 53 #endif
56 54
57 55 #ifndef isalpha
58 56 #define isalpha(c) (((c) >= 'A' && (c) <= 'Z') || ((c) >= 'a' && (c) <= 'z'))
59 57 #endif
60 58
61 59 #ifndef isspace
62 60 #define isspace(c) ((c) == ' ' || (c) == '\t' || (c) == '\n' || \
63 61 (c) == '\r' || (c) == '\f' || (c) == '\013')
64 62 #endif
65 63
66 64 /*
67 65 * ref_t - reference type, ...
68 66 *
69 67 * Note, all struct's must contain a single ref_t, all must use
70 68 * kmem_cache, all must use the REF_* macros for free.
71 69 */
72 70
73 71 typedef struct ref_s {
74 72 uint32_t cnt; /* Reference count */
75 73 void (*last)(void *); /* Call-back for last ref */
↓ open down ↓ |
34 lines elided |
↑ open up ↑ |
76 74 kmem_cache_t *kmc; /* Container allocator cache */
77 75 } ref_t;
78 76
79 77 #define REF_INIT(container, count, inactive, kmem) { \
80 78 (container)->ref.cnt = (count); \
81 79 (container)->ref.last = (void (*)(void *))((inactive)); \
82 80 (container)->ref.kmc = (kmem); \
83 81 }
84 82
85 83 #define REF_HOLD(container) { \
86 - atomic_add_32(&(container)->ref.cnt, 1); \
84 + atomic_inc_32(&(container)->ref.cnt); \
87 85 ASSERT((container)->ref.cnt != 0); \
88 86 }
89 87
90 88 #define REF_RELE(container) { \
91 - if (atomic_add_32_nv(&(container)->ref.cnt, -1) == 0) { \
89 + if (atomic_dec_32_nv(&(container)->ref.cnt) == 0) { \
92 90 (container)->ref.last((container)); \
93 91 kmem_cache_free((container)->ref.kmc, (container)); \
94 92 } \
95 93 }
96 94
97 95 #define REF_COUNT(container) (container)->ref.cnt
98 96
99 97 #define REF_ASSERT(container, count) \
100 98 ASSERT((container)->ref.cnt == (count));
101 99
102 100 /*
103 101 * str_t - string type, used to access a an arbitrary span of a char[].
104 102 */
105 103
106 104 typedef struct str_s {
107 105 char *cp; /* Char pointer current char */
108 106 char *ep; /* Char pointer past end of string */
109 107 } str_t;
110 108
111 109 /*
112 110 * uri_*_t - URI descriptor, used to describe a cached URI object.
113 111 */
114 112
115 113 typedef struct uri_rd_s {
116 114 size_t sz; /* Size of data */
117 115 offset_t off; /* Offset into file or -1 for kmem */
118 116 union { /* Response data */
119 117 char *kmem; /* Data in kmem */
120 118 vnode_t *vnode; /* Data in vnode */
121 119 } data;
122 120 struct uri_rd_s *next; /* Next response descriptor */
123 121 } uri_rd_t;
124 122
125 123 typedef struct uri_desc_s {
126 124 struct uri_desc_s *hash; /* Hash *next */
127 125 uint64_t hit; /* Hit counter */
128 126 clock_t expire; /* URI lbolt expires on (-1 = NEVER) */
129 127 #ifdef notyet
130 128 void *sslctx; /* SSL context */
131 129 #endif
132 130 boolean_t nocache; /* URI no cache */
133 131 boolean_t conditional; /* Conditional response */
134 132 uint32_t hvalue; /* Hashed value */
135 133
136 134 mblk_t *reqmp; /* Request mblk_t */
137 135 str_t path; /* Path name of response */
138 136 str_t auth; /* Authority for response */
139 137 ssize_t resplen; /* Response length */
140 138 ssize_t respclen; /* Response chunk length */
141 139 char *eoh; /* End of header pointer */
142 140 void *scheme; /* Scheme private state */
143 141
144 142 ref_t ref; /* Reference stuff */
145 143
146 144 size_t count; /* rd_t chain byte count */
147 145 uri_rd_t *tail; /* Last response descriptor */
148 146 uri_rd_t response; /* First response descriptor */
149 147
150 148 struct sonode *proc; /* Socket processing this uri */
151 149 kcondvar_t waiting; /* Socket(s) waiting for processing */
152 150 kmutex_t proclock; /* Lock for proc and waiting */
153 151 } uri_desc_t;
154 152
155 153 /* Hash the (char)c to the hash accumulator (uint32_t)hv */
156 154 #define CHASH(hv, c) (hv) = ((hv) << 5) + (hv) + c; (hv) &= 0x7FFFFFFF
157 155
158 156 #define URI_TEMP (uri_desc_t *)-1 /* Temp (nocache) uri_t.hash pointer */
159 157
160 158 #define URI_LEN_NOVALUE -1 /* Length (int) counter no value yet */
161 159 #define URI_LEN_CONSUMED -2 /* Length (int) counter consumed */
162 160
163 161 typedef struct uri_segmap_s {
164 162 ref_t ref; /* Reference, one per uri_desb_t */
165 163 caddr_t base; /* Base addr of segmap mapping */
166 164 size_t len; /* Length of segmap mapping */
167 165 vnode_t *vp; /* Vnode mapped */
168 166 } uri_segmap_t;
169 167
170 168 typedef struct uri_desb_s {
171 169 frtn_t frtn; /* For use by esballoc() and freinds */
172 170 uri_desc_t *uri; /* Containing URI of REF_HOLD() */
173 171 uri_segmap_t *segmap; /* If segmap mapped else NULL */
174 172 } uri_desb_t;
175 173
176 174 /*
177 175 * Add (and create if need be) a new uri_rd_t to a uri.
178 176 *
179 177 * Note, macro can block, must be called from a blockable context.
180 178 */
181 179 #define URI_RD_ADD(uri, rdp, size, offset) { \
182 180 if ((uri)->tail == NULL) { \
183 181 (rdp) = &(uri)->response; \
184 182 } else { \
185 183 (rdp) = kmem_cache_alloc(nl7c_uri_rd_kmc, KM_SLEEP); \
186 184 (uri)->tail->next = (rdp); \
187 185 } \
188 186 (rdp)->sz = size; \
189 187 (rdp)->off = offset; \
190 188 (rdp)->next = NULL; \
191 189 (uri)->tail = rdp; \
192 190 (uri)->count += size; \
193 191 }
194 192
195 193 #ifdef __cplusplus
196 194 }
197 195 #endif
198 196
199 197 #endif /* _SYS_SOCKFS_NL7CURI_H */
↓ open down ↓ |
98 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX