diff --git a/sys/net80211/ieee80211_node.c b/sys/net80211/ieee80211_node.c index 697acb2430a7..d3c7b2441c4e 100644 --- a/sys/net80211/ieee80211_node.c +++ b/sys/net80211/ieee80211_node.c @@ -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 @@ __KERNEL_RCSID(0, "$NetBSD: ieee80211_node.c,v 1.3 2003/09/14 01:14:55 dyoung Ex #include #include #include +#ifdef __FreeBSD__ #include +#endif #include #include @@ -63,16 +65,23 @@ __KERNEL_RCSID(0, "$NetBSD: ieee80211_node.c,v 1.3 2003/09/14 01:14:55 dyoung Ex #include #ifdef __FreeBSD__ #include +#else +#include #endif #include #include +#include #include #ifdef INET #include +#ifdef __FreeBSD__ #include +#else +#include +#endif #endif static struct ieee80211_node *ieee80211_node_alloc(struct ieee80211com *); diff --git a/sys/net80211/ieee80211_node.h b/sys/net80211/ieee80211_node.h index 79feb3a4d344..ac38f7c3e2a3 100644 --- a/sys/net80211/ieee80211_node.h +++ b/sys/net80211/ieee80211_node.h @@ -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 @@ struct ieee80211_node { 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 @@ ieee80211_ref_node(struct ieee80211_node *ni) static __inline void ieee80211_unref_node(struct ieee80211_node **ni) { - ieee80211_node_decref(ni); + ieee80211_node_decref(*ni); *ni = NULL; /* guard against use */ }