From 485da29cbc5ae018ed2405223dd2df3caa5a84d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Colin=20G=C3=BCnther?= Date: Wed, 30 Dec 2009 01:00:51 +0000 Subject: [PATCH] Found a better solution for implementing ieee80211_node_dectestref(). Now the reference count get accessed only once, leading to true atomarity. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34823 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/libs/compat/freebsd_wlan/net80211/ieee80211_haiku.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/libs/compat/freebsd_wlan/net80211/ieee80211_haiku.c b/src/libs/compat/freebsd_wlan/net80211/ieee80211_haiku.c index 2a5f53c52b..aae09f559f 100644 --- a/src/libs/compat/freebsd_wlan/net80211/ieee80211_haiku.c +++ b/src/libs/compat/freebsd_wlan/net80211/ieee80211_haiku.c @@ -397,8 +397,6 @@ ieee80211_getmgtframe(uint8_t** frm, int headroom, int pktlen) /* * Decrements the reference-counter and * tests whether it became zero. - * NB: The negation of atomic_add is not atomar. Must work until sth. better is - * found. * * @return 1 reference-counter became zero * @return 0 reference-counter didn't became zero @@ -406,9 +404,8 @@ ieee80211_getmgtframe(uint8_t** frm, int headroom, int pktlen) int ieee80211_node_dectestref(struct ieee80211_node* ni) { - // XXX need equivalent of atomic_dec_and_test - atomic_add((vint32*)&ni->ni_refcnt, -1); - return !atomic_add((vint32*)&ni->ni_refcnt, 0); + // atomic_add returns old value + return 1 == atomic_add((vint32*)&ni->ni_refcnt, -1); }