Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/kqueue]: src/sys/arch/i386/i386 Add kqueue support. Note, kn_data seman...



details:   https://anonhg.NetBSD.org/src/rev/c934c2443fa2
branches:  kqueue
changeset: 512410:c934c2443fa2
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Sat Sep 08 21:47:32 2001 +0000

description:
Add kqueue support.  Note, kn_data semantics are slightly
different here, since an ioctl is used to fetch the events,
not a (*d_read)() entry point.

diffstat:

 sys/arch/i386/i386/apm.c |  51 ++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 49 insertions(+), 2 deletions(-)

diffs (69 lines):

diff -r e65997a6ae7f -r c934c2443fa2 sys/arch/i386/i386/apm.c
--- a/sys/arch/i386/i386/apm.c  Sat Sep 08 21:38:31 2001 +0000
+++ b/sys/arch/i386/i386/apm.c  Sat Sep 08 21:47:32 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: apm.c,v 1.60.2.2 2001/08/25 06:15:25 thorpej Exp $ */
+/*     $NetBSD: apm.c,v 1.60.2.3 2001/09/08 21:47:32 thorpej Exp $ */
 
 /*-
  * Copyright (c) 1996, 1997 The NetBSD Foundation, Inc.
@@ -601,7 +601,7 @@
        sc->event_ptr %= APM_NEVENTS;
        evp->type = event_type;
        evp->index = ++apm_evindex;
-       selwakeup(&sc->sc_rsel);
+       selnotify(&sc->sc_rsel, 0);
        return (sc->sc_flags & SCFLAG_OWRITE) ? 0 : 1; /* user may handle */
 }
 
@@ -1759,3 +1759,50 @@
 
        return (revents);
 }
+
+static void
+filt_apmrdetach(struct knote *kn)
+{
+       struct apm_softc *sc = (void *) kn->kn_hook;
+
+       APM_LOCK(sc);
+       SLIST_REMOVE(&sc->sc_rsel.si_klist, kn, knote, kn_selnext);
+       APM_UNLOCK(sc);
+}
+
+static int
+filt_apmread(struct knote *kn, long hint)
+{
+       struct apm_softc *sc = (void *) kn->kn_hook;
+
+       kn->kn_data = sc->event_count;
+       return (kn->kn_data > 0);
+}
+
+static const struct filterops apmread_filtops =
+       { 1, NULL, filt_apmrdetach, filt_apmread };
+
+int
+apmkqfilter(dev_t dev, struct knote *kn)
+{
+       struct apm_softc *sc = apm_cd.cd_devs[APMUNIT(dev)];
+       struct klist *klist;
+
+       switch (kn->kn_filter) {
+       case EVFILT_READ:
+               klist = &sc->sc_rsel.si_klist;
+               kn->kn_fop = &apmread_filtops;
+               break;
+
+       default:
+               return (1);
+       }
+
+       kn->kn_hook = (void *) sc;
+
+       APM_LOCK(sc);
+       SLIST_INSERT_HEAD(klist, kn, kn_selnext);
+       APM_UNLOCK(sc);
+
+       return (0);
+}



Home | Main Index | Thread Index | Old Index