Fri Nov 6 23:05:09 2015 UTC ()
Don't use macros as types or variable names.


(joerg)
diff -r1.9 -r1.10 src/lib/libc/rpc/rpc_commondata.c
diff -r1.2 -r1.3 src/lib/libc/rpc/svc_fdset.c

cvs diff -r1.9 -r1.10 src/lib/libc/rpc/rpc_commondata.c (expand / switch to unified diff)

--- src/lib/libc/rpc/rpc_commondata.c 2013/03/11 20:19:29 1.9
+++ src/lib/libc/rpc/rpc_commondata.c 2015/11/06 23:05:09 1.10
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: rpc_commondata.c,v 1.9 2013/03/11 20:19:29 tron Exp $ */ 1/* $NetBSD: rpc_commondata.c,v 1.10 2015/11/06 23:05:09 joerg Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2010, Oracle America, Inc. 4 * Copyright (c) 2010, Oracle America, Inc.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are 7 * modification, are permitted provided that the following conditions are
8 * met: 8 * met:
9 * 9 *
10 * * Redistributions of source code must retain the above copyright 10 * * Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * * Redistributions in binary form must reproduce the above 12 * * Redistributions in binary form must reproduce the above
13 * copyright notice, this list of conditions and the following 13 * copyright notice, this list of conditions and the following
14 * disclaimer in the documentation and/or other materials 14 * disclaimer in the documentation and/or other materials
@@ -21,32 +21,34 @@ @@ -21,32 +21,34 @@
21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 23 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24 * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 24 * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
25 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
27 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
29 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 29 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
30 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 */ 32 */
33 33
 34#define SVC_LEGACY
 35
34#include <sys/cdefs.h> 36#include <sys/cdefs.h>
35#if defined(LIBC_SCCS) && !defined(lint) 37#if defined(LIBC_SCCS) && !defined(lint)
36#if 0 38#if 0
37static char *sccsid = "@(#)rpc_commondata.c 2.1 88/07/29 4.0 RPCSRC"; 39static char *sccsid = "@(#)rpc_commondata.c 2.1 88/07/29 4.0 RPCSRC";
38#else 40#else
39__RCSID("$NetBSD: rpc_commondata.c,v 1.9 2013/03/11 20:19:29 tron Exp $"); 41__RCSID("$NetBSD: rpc_commondata.c,v 1.10 2015/11/06 23:05:09 joerg Exp $");
40#endif 42#endif
41#endif 43#endif
42 44
43#include <rpc/rpc.h> 45#include <rpc/rpc.h>
44 46
45/* 47/*
46 * This file should only contain common data (global data) that is exported 48 * This file should only contain common data (global data) that is exported
47 * by public interfaces  49 * by public interfaces
48 */ 50 */
49struct opaque_auth _null_auth; 51struct opaque_auth _null_auth;
50fd_set svc_fdset; 52fd_set svc_fdset;
51int svc_maxfd = -1; 53int svc_maxfd = -1;
52#ifndef _REENTRANT 54#ifndef _REENTRANT

cvs diff -r1.2 -r1.3 src/lib/libc/rpc/svc_fdset.c (expand / switch to unified diff)

--- src/lib/libc/rpc/svc_fdset.c 2015/11/06 19:34:13 1.2
+++ src/lib/libc/rpc/svc_fdset.c 2015/11/06 23:05:09 1.3
@@ -1,29 +1,29 @@ @@ -1,29 +1,29 @@
1/* $NetBSD: svc_fdset.c,v 1.2 2015/11/06 19:34:13 christos Exp $ */ 1/* $NetBSD: svc_fdset.c,v 1.3 2015/11/06 23:05:09 joerg Exp $ */
2 2
3#include <sys/cdefs.h> 3#include <sys/cdefs.h>
4__RCSID("$NetBSD: svc_fdset.c,v 1.2 2015/11/06 19:34:13 christos Exp $"); 4__RCSID("$NetBSD: svc_fdset.c,v 1.3 2015/11/06 23:05:09 joerg Exp $");
5 5
6 6
7#include "reentrant.h" 7#include "reentrant.h"
8 8
9#include <sys/fd_set.h> 9#include <sys/fd_set.h>
10 10
11#include <rpc/rpc.h> 11#include <rpc/rpc.h>
12 12
13#include <stdlib.h> 13#include <stdlib.h>
14#include <string.h> 14#include <string.h>
15 15
16struct svc_fdset { 16struct my_svc_fdset {
17 fd_set *fdset; 17 fd_set *fdset;
18 int fdmax; 18 int fdmax;
19 int fdsize; 19 int fdsize;
20}; 20};
21 21
22 22
23/* The single threaded, one global fd_set version */ 23/* The single threaded, one global fd_set version */
24static fd_set *__svc_fdset; 24static fd_set *__svc_fdset;
25static int svc_fdsize = 0; 25static int svc_fdsize = 0;
26 26
27/* 27/*
28 * Update the old global svc_fdset if needed for binary compatibility 28 * Update the old global svc_fdset if needed for binary compatibility
29 */ 29 */
@@ -86,27 +86,27 @@ svc_print(const char *func, size_t line, @@ -86,27 +86,27 @@ svc_print(const char *func, size_t line,
86} 86}
87 87
88#define DPRINTF_FDSET(...) svc_fdset_print(__func__, __LINE__, __VA_ARGS__) 88#define DPRINTF_FDSET(...) svc_fdset_print(__func__, __LINE__, __VA_ARGS__)
89#define DPRINTF(...) svc_print(__func__, __LINE__, __VA_ARGS__) 89#define DPRINTF(...) svc_print(__func__, __LINE__, __VA_ARGS__)
90#else 90#else
91#define DPRINTF_FDSET(...) 91#define DPRINTF_FDSET(...)
92#define DPRINTF(...) 92#define DPRINTF(...)
93#endif 93#endif
94 94
95 95
96static void 96static void
97svc_fdset_free(void *v) 97svc_fdset_free(void *v)
98{ 98{
99 struct svc_fdset *rv = v; 99 struct my_svc_fdset *rv = v;
100 DPRINTF_FDSET(rv->fdset, 0, "free"); 100 DPRINTF_FDSET(rv->fdset, 0, "free");
101 101
102 free(rv->fdset); 102 free(rv->fdset);
103 free(rv); 103 free(rv);
104} 104}
105 105
106static fd_set * 106static fd_set *
107svc_fdset_resize(int fd, fd_set **fdset, int *fdsize) 107svc_fdset_resize(int fd, fd_set **fdset, int *fdsize)
108{ 108{
109 if (*fdset && fd < *fdsize) { 109 if (*fdset && fd < *fdsize) {
110 DPRINTF_FDSET(*fdset, 0, "keeping %d < %d", 110 DPRINTF_FDSET(*fdset, 0, "keeping %d < %d",
111 fd, *fdsize); 111 fd, *fdsize);
112 return *fdset; 112 return *fdset;
@@ -123,30 +123,30 @@ svc_fdset_resize(int fd, fd_set **fdset, @@ -123,30 +123,30 @@ svc_fdset_resize(int fd, fd_set **fdset,
123 memset(newfdset + __NFD_BYTES(*fdsize), 0, 123 memset(newfdset + __NFD_BYTES(*fdsize), 0,
124 __NFD_BYTES(fd) - __NFD_BYTES(*fdsize)); 124 __NFD_BYTES(fd) - __NFD_BYTES(*fdsize));
125 125
126 126
127 *fdset = (void *)newfdset; 127 *fdset = (void *)newfdset;
128 DPRINTF_FDSET(*fdset, 0, "resize %d > %d", fd, *fdsize); 128 DPRINTF_FDSET(*fdset, 0, "resize %d > %d", fd, *fdsize);
129 *fdsize = fd; 129 *fdsize = fd;
130 130
131 COMPAT_UPDATE(*fdset); 131 COMPAT_UPDATE(*fdset);
132 132
133 return *fdset; 133 return *fdset;
134} 134}
135 135
136static struct svc_fdset * 136static struct my_svc_fdset *
137svc_fdset_alloc(int fd) 137svc_fdset_alloc(int fd)
138{ 138{
139 struct svc_fdset *rv; 139 struct my_svc_fdset *rv;
140 140
141 if (fdsetkey == -1) 141 if (fdsetkey == -1)
142 thr_keycreate(&fdsetkey, svc_fdset_free); 142 thr_keycreate(&fdsetkey, svc_fdset_free);
143 143
144 if ((rv = thr_getspecific(fdsetkey)) == NULL) { 144 if ((rv = thr_getspecific(fdsetkey)) == NULL) {
145 145
146 rv = calloc(1, sizeof(*rv)); 146 rv = calloc(1, sizeof(*rv));
147 if (rv == NULL) 147 if (rv == NULL)
148 return NULL; 148 return NULL;
149 149
150 (void)thr_setspecific(fdsetkey, rv); 150 (void)thr_setspecific(fdsetkey, rv);
151 151
152 if (svc_fdsize != 0) { 152 if (svc_fdsize != 0) {
@@ -162,27 +162,27 @@ svc_fdset_alloc(int fd) @@ -162,27 +162,27 @@ svc_fdset_alloc(int fd)
162 } else { 162 } else {
163 DPRINTF("again for %p", rv->fdset); 163 DPRINTF("again for %p", rv->fdset);
164 if (fd < rv->fdsize) 164 if (fd < rv->fdsize)
165 return rv; 165 return rv;
166 } 166 }
167 if (svc_fdset_resize(fd, &rv->fdset, &rv->fdsize) == NULL) 167 if (svc_fdset_resize(fd, &rv->fdset, &rv->fdsize) == NULL)
168 return NULL; 168 return NULL;
169 return rv; 169 return rv;
170} 170}
171 171
172static fd_set * 172static fd_set *
173svc_fdset_get_internal(int fd) 173svc_fdset_get_internal(int fd)
174{ 174{
175 struct svc_fdset *rv; 175 struct my_svc_fdset *rv;
176 176
177 if (!__isthreaded || fdsetkey == -2) 177 if (!__isthreaded || fdsetkey == -2)
178 return svc_fdset_resize(fd, &__svc_fdset, &svc_fdsize); 178 return svc_fdset_resize(fd, &__svc_fdset, &svc_fdsize);
179 179
180 rv = svc_fdset_alloc(fd); 180 rv = svc_fdset_alloc(fd);
181 if (rv == NULL) 181 if (rv == NULL)
182 return NULL; 182 return NULL;
183 return rv->fdset; 183 return rv->fdset;
184} 184}
185 185
186 186
187/* allow each thread to have their own copy */ 187/* allow each thread to have their own copy */
188void 188void
@@ -260,41 +260,41 @@ svc_fdset_copy(const fd_set *orig) @@ -260,41 +260,41 @@ svc_fdset_copy(const fd_set *orig)
260} 260}
261 261
262fd_set * 262fd_set *
263svc_fdset_get(void) 263svc_fdset_get(void)
264{ 264{
265 fd_set *fds = svc_fdset_get_internal(0); 265 fd_set *fds = svc_fdset_get_internal(0);
266 DPRINTF_FDSET(fds, 0, "get"); 266 DPRINTF_FDSET(fds, 0, "get");
267 return fds; 267 return fds;
268} 268}
269 269
270int * 270int *
271svc_fdset_getmax(void) 271svc_fdset_getmax(void)
272{ 272{
273 struct svc_fdset *rv; 273 struct my_svc_fdset *rv;
274 274
275 if (!__isthreaded || fdsetkey == -2) 275 if (!__isthreaded || fdsetkey == -2)
276 return &svc_maxfd; 276 return &svc_maxfd;
277  277
278 rv = svc_fdset_alloc(0); 278 rv = svc_fdset_alloc(0);
279 if (rv == NULL) 279 if (rv == NULL)
280 return NULL; 280 return NULL;
281 return &rv->fdmax; 281 return &rv->fdmax;
282} 282}
283 283
284int 284int
285svc_fdset_getsize(int fd) 285svc_fdset_getsize(int fd)
286{ 286{
287 struct svc_fdset *rv; 287 struct my_svc_fdset *rv;
288 288
289 if (!__isthreaded || fdsetkey == -2) { 289 if (!__isthreaded || fdsetkey == -2) {
290 if (svc_fdset_resize(fd, &__svc_fdset, &svc_fdsize) == NULL) 290 if (svc_fdset_resize(fd, &__svc_fdset, &svc_fdsize) == NULL)
291 return -1; 291 return -1;
292 else 292 else
293 return svc_fdsize; 293 return svc_fdsize;
294 } 294 }
295 295
296 rv = svc_fdset_alloc(fd); 296 rv = svc_fdset_alloc(fd);
297 if (rv == NULL) 297 if (rv == NULL)
298 return -1; 298 return -1;
299 return rv->fdsize; 299 return rv->fdsize;
300} 300}