Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src use __BITMAP_TYPE



details:   https://anonhg.NetBSD.org/src/rev/e2d3c611144b
branches:  trunk
changeset: 783127:e2d3c611144b
user:      christos <christos%NetBSD.org@localhost>
date:      Fri Dec 07 02:27:29 2012 +0000

description:
use __BITMAP_TYPE

diffstat:

 sbin/sysctl/sysctl.c   |  27 ++++++++++++++-------------
 sys/netinet/portalgo.c |  19 ++++++++++---------
 2 files changed, 24 insertions(+), 22 deletions(-)

diffs (172 lines):

diff -r c756f64604fb -r e2d3c611144b sbin/sysctl/sysctl.c
--- a/sbin/sysctl/sysctl.c      Fri Dec 07 01:54:41 2012 +0000
+++ b/sbin/sysctl/sysctl.c      Fri Dec 07 02:27:29 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: sysctl.c,v 1.147 2012/12/05 13:53:39 christos Exp $ */
+/*     $NetBSD: sysctl.c,v 1.148 2012/12/07 02:27:29 christos Exp $ */
 
 /*-
  * Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -68,7 +68,7 @@
 #if 0
 static char sccsid[] = "@(#)sysctl.c   8.1 (Berkeley) 6/6/93";
 #else
-__RCSID("$NetBSD: sysctl.c,v 1.147 2012/12/05 13:53:39 christos Exp $");
+__RCSID("$NetBSD: sysctl.c,v 1.148 2012/12/07 02:27:29 christos Exp $");
 #endif
 #endif /* not lint */
 
@@ -2692,8 +2692,10 @@
        }
 }
 
+typedef __BITMAP_TYPE(, uint32_t, 0x10000) bitmap;
+
 static char *
-bitmask_print(const uint32_t *o)
+bitmask_print(const bitmap *o)
 {
        char *s, *os;
 
@@ -2717,12 +2719,13 @@
 }
 
 static void
-bitmask_scan(const void *v, uint32_t *o)
+bitmask_scan(const void *v, bitmap *o)
 {
        char *s = strdup(v);
        if (s == NULL)
                err(1, "");
 
+       __BITMAP_ZERO(o);
        for (s = strtok(s, ","); s; s = strtok(NULL, ",")) {
                char *e;
                errno = 0;
@@ -2741,17 +2744,15 @@
 {
        int rc;
        size_t osz, nsz;
-       uint32_t o[__BITMAP_SIZE(uint32_t, MAXPORTS)];
-       uint32_t n[__BITMAP_SIZE(uint32_t, MAXPORTS)];
+       bitmap o, n;
 
        if (fn)
                trim_whitespace(value, 3);
 
        osz = sizeof(o);
        if (value) {
-               __BITMAP_ZERO(n);
-               bitmask_scan(value, n);
-               value = (char *)n;
+               bitmask_scan(value, &n);
+               value = (char *)&n;
                nsz = sizeof(n);
        } else
                nsz = 0;
@@ -2766,10 +2767,10 @@
                return;
 
        if (rflag || xflag)
-               display_struct(pnode, sname, o, sizeof(o),
+               display_struct(pnode, sname, &o, sizeof(o),
                    value ? DISPLAY_OLD : DISPLAY_VALUE);
        else {
-               char *s = bitmask_print(o);
+               char *s = bitmask_print(&o);
                display_string(pnode, sname, s, strlen(s),
                    value ? DISPLAY_OLD : DISPLAY_VALUE);
                free(s);
@@ -2777,10 +2778,10 @@
 
        if (value) {
                if (rflag || xflag)
-                       display_struct(pnode, sname, n, sizeof(n),
+                       display_struct(pnode, sname, &n, sizeof(n),
                            DISPLAY_NEW);
                else {
-                       char *s = bitmask_print(n);
+                       char *s = bitmask_print(&n);
                        display_string(pnode, sname, s, strlen(s), DISPLAY_NEW);
                        free(s);
                }
diff -r c756f64604fb -r e2d3c611144b sys/netinet/portalgo.c
--- a/sys/netinet/portalgo.c    Fri Dec 07 01:54:41 2012 +0000
+++ b/sys/netinet/portalgo.c    Fri Dec 07 02:27:29 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: portalgo.c,v 1.3 2012/12/01 15:11:43 christos Exp $    */
+/*     $NetBSD: portalgo.c,v 1.4 2012/12/07 02:27:41 christos Exp $    */
 
 /*
  * Copyright 2011 Vlad Balan
@@ -34,7 +34,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: portalgo.c,v 1.3 2012/12/01 15:11:43 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: portalgo.c,v 1.4 2012/12/07 02:27:41 christos Exp $");
 
 #include "opt_inet.h"
 
@@ -86,13 +86,14 @@
 #define DPRINTF while (/*CONSTCOND*/0) printf
 #endif
 
+typedef __BITMAP_TYPE(, uint32_t, 0x10000) bitmap;
 #ifdef INET
 static int inet4_portalgo = PORTALGO_BSD;
-static uint32_t inet4_reserve[__BITMAP_SIZE(uint32_t, 0x10000)];
+static bitmap inet4_reserve;
 #endif
 #ifdef INET6
 static int inet6_portalgo = PORTALGO_BSD;
-static uint32_t inet6_reserve[__BITMAP_SIZE(uint32_t, 0x10000)];
+static bitmap inet6_reserve;
 #endif
 
 typedef struct {
@@ -253,7 +254,7 @@
                struct inpcb *pcb;
                struct sockaddr_in sin;
 
-               if (__BITMAP_ISSET(port, inet4_reserve))
+               if (__BITMAP_ISSET(port, &inet4_reserve))
                        return false;
 
                sin.sin_addr = inp->inp_laddr;
@@ -298,7 +299,7 @@
                struct sockaddr_in6 sin6;
                void *t;
 
-               if (__BITMAP_ISSET(port, inet6_reserve))
+               if (__BITMAP_ISSET(port, &inet6_reserve))
                        return false;
 
                sin6.sin6_addr = in6p->in6p_laddr;
@@ -901,7 +902,7 @@
 }
 
 static int
-sysctl_portalgo_reserve(SYSCTLFN_ARGS, uint32_t *bt)
+sysctl_portalgo_reserve(SYSCTLFN_ARGS, bitmap *bt)
 {
        struct sysctlnode node;
        int error;
@@ -942,7 +943,7 @@
 sysctl_portalgo_reserve4(SYSCTLFN_ARGS)
 {
 
-       return sysctl_portalgo_reserve(SYSCTLFN_CALL(rnode), inet4_reserve);
+       return sysctl_portalgo_reserve(SYSCTLFN_CALL(rnode), &inet4_reserve);
 }
 #endif
 
@@ -957,7 +958,7 @@
 int
 sysctl_portalgo_reserve6(SYSCTLFN_ARGS)
 {
-       return sysctl_portalgo_reserve(SYSCTLFN_CALL(rnode), inet6_reserve);
+       return sysctl_portalgo_reserve(SYSCTLFN_CALL(rnode), &inet6_reserve);
 }
 #endif
 



Home | Main Index | Thread Index | Old Index