Date: Tue, 27 Jan 2004 17:12:10 -0800 (PST) From: Sam Leffler <sam@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 46029 for review Message-ID: <200401280112.i0S1CAjb072837@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=46029 Change 46029 by sam@sam_ebb on 2004/01/27 17:11:35 o correct ieee80211_node_dectestref o add comments describing reference counting macros Affected files ... .. //depot/projects/netperf+sockets/sys/net80211/ieee80211_freebsd.h#2 edit .. //depot/projects/netperf+sockets/sys/net80211/ieee80211_netbsd.h#2 edit Differences ... ==== //depot/projects/netperf+sockets/sys/net80211/ieee80211_freebsd.h#2 (text+ko) ==== @@ -76,12 +76,19 @@ #define ALTQ_DECL(_x) /* - * Node reference counting definitions. + * Node reference counting definitions: + * + * ieee80211_node_initref initialize the reference count to 1 + * ieee80211_node_incref add a reference + * ieee80211_node_decref remove a reference + * ieee80211_node_dectestref remove a reference and return 1 if this + * is the last reference, otherwise 0 */ #define ieee80211_node_initref(_ni) ((_ni)->ni_refcnt = 1) #define ieee80211_node_incref(_ni) atomic_add_int(&(_ni)->ni_refcnt,1) #define ieee80211_node_decref(_ni) atomic_subtract_int(&(_ni)->ni_refcnt,1) +/* XXX handle circularity required by inline function */ #include <net80211/ieee80211.h> #include <net80211/ieee80211_node.h> @@ -92,7 +99,7 @@ do { orefcnt = ni->ni_refcnt; } while (atomic_cmpset_int(&ni->ni_refcnt, orefcnt, orefcnt - 1) == 0); - return orefcnt - 1; + return (orefcnt == 1); } extern struct mbuf *ieee80211_getmgtframe(u_int8_t **frm, u_int pktlen); ==== //depot/projects/netperf+sockets/sys/net80211/ieee80211_netbsd.h#2 (text+ko) ==== @@ -74,6 +74,15 @@ void if_printf(struct ifnet *, const char *, ...) __attribute__((__format__(__printf__,2,3))); +/* + * Node reference counting definitions: + * + * ieee80211_node_initref initialize the reference count to 1 + * ieee80211_node_incref add a reference + * ieee80211_node_decref remove a reference + * ieee80211_node_dectestref remove a reference and return 1 if this + * is the last reference, otherwise 0 + */ #define ieee80211_node_incref(ni) \ do { \ int _s = splnet(); \ @@ -94,10 +103,12 @@ s = splnet(); refcnt = --ni->ni_refcnt; splx(s); - return refcnt; + return (refcnt == 0); } #define ifmedia_removeall(_media) \ ifmedia_delete_instance((_media), IFM_INST_ANY) +extern struct mbuf *ieee80211_getmgtframe(u_int8_t **frm, u_int pktlen); + #endif /* _NET80211_IEEE80211_NETBSD_H_ */
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200401280112.i0S1CAjb072837>