Author: kib
Date: Fri Dec 16 17:41:20 2016
New Revision: 310159
URL: https://svnweb.freebsd.org/changeset/base/310159

Log:
  Switch from stdatomic.h to atomic.h for kernel.
  
  Apparently stdatomic.h implementation for gcc 4.2 on sparc64 does not
  work properly.  This effectively reverts r251803.
  
  Reported and tested by:       lidl
  Discussed with:       ed
  Sponsored by: The FreeBSD Foundation
  MFC after:    1 week

Modified:
  head/sys/kern/kern_event.c

Modified: head/sys/kern/kern_event.c
==============================================================================
--- head/sys/kern/kern_event.c  Fri Dec 16 15:45:09 2016        (r310158)
+++ head/sys/kern/kern_event.c  Fri Dec 16 17:41:20 2016        (r310159)
@@ -48,7 +48,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>
@@ -69,6 +68,7 @@ __FBSDID("$FreeBSD$");
 #ifdef KTRACE
 #include <sys/ktrace.h>
 #endif
+#include <machine/atomic.h>
 
 #include <vm/uma.h>
 
@@ -188,7 +188,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");
@@ -672,13 +672,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 */
@@ -703,7 +701,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 */
 }
_______________________________________________
[email protected] mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "[email protected]"

Reply via email to