Source-Changes-HG archive

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

[src/trunk]: src/sys/net80211 Make ieee80211_unref_node compile.



details:   https://anonhg.NetBSD.org/src/rev/38f4cdda3ae7
branches:  trunk
changeset: 552336:38f4cdda3ae7
user:      dyoung <dyoung%NetBSD.org@localhost>
date:      Tue Sep 23 15:59:09 2003 +0000

description:
Make ieee80211_unref_node compile.

#ifdef __FreeBSD__ a lot of lines, and put the NetBSDisms into the #else
half.

Add ieee80211_node_{dec,inc}ref to ieee80211_node.h.

diffstat:

 sys/net80211/ieee80211_node.c |  13 +++++++++++--
 sys/net80211/ieee80211_node.h |  35 +++++++++++++++++++++++++++++++++--
 2 files changed, 44 insertions(+), 4 deletions(-)

diffs (108 lines):

diff -r 5fee601c3045 -r 38f4cdda3ae7 sys/net80211/ieee80211_node.c
--- a/sys/net80211/ieee80211_node.c     Tue Sep 23 15:57:25 2003 +0000
+++ b/sys/net80211/ieee80211_node.c     Tue Sep 23 15:59:09 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ieee80211_node.c,v 1.3 2003/09/14 01:14:55 dyoung Exp $        */
+/*     $NetBSD: ieee80211_node.c,v 1.4 2003/09/23 15:59:09 dyoung Exp $        */
 /*-
  * Copyright (c) 2001 Atsushi Onoe
  * Copyright (c) 2002, 2003 Sam Leffler, Errno Consulting
@@ -35,7 +35,7 @@
 #ifdef __FreeBSD__
 __FBSDID("$FreeBSD: src/sys/net80211/ieee80211_node.c,v 1.6 2003/08/19 22:17:03 sam Exp $");
 #else
-__KERNEL_RCSID(0, "$NetBSD: ieee80211_node.c,v 1.3 2003/09/14 01:14:55 dyoung Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ieee80211_node.c,v 1.4 2003/09/23 15:59:09 dyoung Exp $");
 #endif
 
 #include "opt_inet.h"
@@ -49,7 +49,9 @@
 #include <sys/sockio.h>
 #include <sys/endian.h>
 #include <sys/errno.h>
+#ifdef __FreeBSD__
 #include <sys/bus.h>
+#endif
 #include <sys/proc.h>
 #include <sys/sysctl.h>
 
@@ -63,16 +65,23 @@
 #include <net/if_arp.h>
 #ifdef __FreeBSD__
 #include <net/ethernet.h>
+#else
+#include <net/if_ether.h>
 #endif
 #include <net/if_llc.h>
 
 #include <net80211/ieee80211_var.h>
+#include <net80211/ieee80211_compat.h>
 
 #include <net/bpf.h>
 
 #ifdef INET
 #include <netinet/in.h> 
+#ifdef __FreeBSD__
 #include <netinet/if_ether.h>
+#else
+#include <net/if_ether.h>
+#endif
 #endif
 
 static struct ieee80211_node *ieee80211_node_alloc(struct ieee80211com *);
diff -r 5fee601c3045 -r 38f4cdda3ae7 sys/net80211/ieee80211_node.h
--- a/sys/net80211/ieee80211_node.h     Tue Sep 23 15:57:25 2003 +0000
+++ b/sys/net80211/ieee80211_node.h     Tue Sep 23 15:59:09 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ieee80211_node.h,v 1.3 2003/09/14 01:14:55 dyoung Exp $        */
+/*     $NetBSD: ieee80211_node.h,v 1.4 2003/09/23 15:59:09 dyoung Exp $        */
 /*-
  * Copyright (c) 2001 Atsushi Onoe
  * Copyright (c) 2002, 2003 Sam Leffler, Errno Consulting
@@ -104,6 +104,37 @@
        int                     ni_txrate;      /* index to ni_rates[] */
 };
 
+#ifdef __NetBSD__
+#define ieee80211_node_incref(ni)                      \
+       do {                                            \
+               int _s = splnet();                      \
+               (ni)->ni_refcnt++;                      \
+               splx(_s);                               \
+       } while (0)
+
+static __inline int
+ieee80211_node_decref(struct ieee80211_node *ni)
+{
+       int refcnt, s;
+       s = splnet();
+       refcnt = --ni->ni_refcnt;
+       splx(s);
+       return refcnt;
+}
+
+#else
+#define ieee80211_node_incref(ni) atomic_add_int(&(ni)->ni_refcnt, 1)
+static __inline int
+ieee80211_node_decref(struct ieee80211_node *ni)
+{
+       int orefcnt;
+       do {
+               orefcnt = ni->ni_refcnt;
+       } while (atomic_cmpset_int(&ni->ni_refcnt, orefcnt, orefcnt - 1) == 0);
+       return orefcnt - 1;
+}
+#endif
+
 static __inline struct ieee80211_node *
 ieee80211_ref_node(struct ieee80211_node *ni)
 {
@@ -114,7 +145,7 @@
 static __inline void
 ieee80211_unref_node(struct ieee80211_node **ni)
 {
-       ieee80211_node_decref(ni);
+       ieee80211_node_decref(*ni);
        *ni = NULL;                     /* guard against use */
 }
 



Home | Main Index | Thread Index | Old Index