summaryrefslogtreecommitdiffstats
path: root/sys/kern
diff options
context:
space:
mode:
authorkib <kib@FreeBSD.org>2016-12-23 09:35:39 +0000
committerkib <kib@FreeBSD.org>2016-12-23 09:35:39 +0000
commit0bf02ea0a8e54cbc0e9fdda6b3f88cebc9a4d609 (patch)
treec8fe60a22af8380c72ab51bae00d5bd971a78f7e /sys/kern
parent3da535c57bb49c6358142724612703ba7299610c (diff)
downloadFreeBSD-src-0bf02ea0a8e54cbc0e9fdda6b3f88cebc9a4d609.zip
FreeBSD-src-0bf02ea0a8e54cbc0e9fdda6b3f88cebc9a4d609.tar.gz
MFC r310159:
Switch from stdatomic.h to atomic.h for kernel.
Diffstat (limited to 'sys/kern')
-rw-r--r--sys/kern/kern_event.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/sys/kern/kern_event.c b/sys/kern/kern_event.c
index d26c437..a65bcbb 100644
--- a/sys/kern/kern_event.c
+++ b/sys/kern/kern_event.c
@@ -47,7 +47,6 @@ __FBSDID("$FreeBSD$");
#include <sys/fcntl.h>
#include <sys/kthread.h>
#include <sys/selinfo.h>
-#include <sys/stdatomic.h>
#include <sys/queue.h>
#include <sys/event.h>
#include <sys/eventvar.h>
@@ -66,6 +65,7 @@ __FBSDID("$FreeBSD$");
#ifdef KTRACE
#include <sys/ktrace.h>
#endif
+#include <machine/atomic.h>
#include <vm/uma.h>
@@ -184,7 +184,7 @@ static struct filterops user_filtops = {
};
static uma_zone_t knote_zone;
-static atomic_uint kq_ncallouts = ATOMIC_VAR_INIT(0);
+static unsigned int kq_ncallouts = 0;
static unsigned int kq_calloutmax = 4 * 1024;
SYSCTL_UINT(_kern, OID_AUTO, kq_calloutmax, CTLFLAG_RW,
&kq_calloutmax, 0, "Maximum number of callouts allocated for kqueue");
@@ -652,13 +652,11 @@ filt_timerattach(struct knote *kn)
if (to < 0)
return (EINVAL);
- ncallouts = atomic_load_explicit(&kq_ncallouts, memory_order_relaxed);
do {
+ ncallouts = kq_ncallouts;
if (ncallouts >= kq_calloutmax)
return (ENOMEM);
- } while (!atomic_compare_exchange_weak_explicit(&kq_ncallouts,
- &ncallouts, ncallouts + 1, memory_order_relaxed,
- memory_order_relaxed));
+ } while (!atomic_cmpset_int(&kq_ncallouts, ncallouts, ncallouts + 1));
kn->kn_flags |= EV_CLEAR; /* automatically set */
kn->kn_status &= ~KN_DETACHED; /* knlist_add clears it */
@@ -683,7 +681,7 @@ filt_timerdetach(struct knote *kn)
callout_drain(calloutp);
free(calloutp, M_KQUEUE);
free(kn->kn_ptr.p_nexttime, M_KQUEUE);
- old = atomic_fetch_sub_explicit(&kq_ncallouts, 1, memory_order_relaxed);
+ old = atomic_fetchadd_int(&kq_ncallouts, -1);
KASSERT(old > 0, ("Number of callouts cannot become negative"));
kn->kn_status |= KN_DETACHED; /* knlist_remove sets it */
}
OpenPOWER on IntegriCloud