Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/kqueue]: src/sys/arch/shark/shark add kqfilter hook (code taken from i38...
details: https://anonhg.NetBSD.org/src/rev/0c82713fe452
branches: kqueue
changeset: 512485:0c82713fe452
user: jdolecek <jdolecek%NetBSD.org@localhost>
date: Sun Jun 23 18:16:19 2002 +0000
description:
add kqfilter hook (code taken from i386 olms)
diffstat:
sys/arch/shark/shark/opms.c | 50 ++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 49 insertions(+), 1 deletions(-)
diffs (61 lines):
diff -r 261aba88b4e4 -r 0c82713fe452 sys/arch/shark/shark/opms.c
--- a/sys/arch/shark/shark/opms.c Sun Jun 23 17:43:33 2002 +0000
+++ b/sys/arch/shark/shark/opms.c Sun Jun 23 18:16:19 2002 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: opms.c,v 1.1.8.2 2002/06/23 17:41:31 jdolecek Exp $ */
+/* $NetBSD: opms.c,v 1.1.8.3 2002/06/23 18:16:19 jdolecek Exp $ */
/*
* Copyright 1997
@@ -977,3 +977,51 @@
return (revents);
} /* End opmspoll */
+static void
+filt_opmsrdetach(struct knote *kn)
+{
+ struct opms_softc *sc = (void *) kn->kn_hook;
+ int s;
+
+ s = spltty();
+ SLIST_REMOVE(&sc->sc_rsel.si_klist, kn, knote, kn_selnext);
+ splx(s);
+}
+
+static int
+filt_opmsread(struct knote *kn, long hint)
+{
+ struct opms_softc *sc = (void *) kn->kn_hook;
+
+ kn->kn_data = sc->sc_q.c_cc;
+ return (kn->kn_data > 0);
+}
+
+static const struct filterops opmsread_filtops =
+ { 1, NULL, filt_opmsrdetach, filt_opmsread };
+
+int
+opmskqfilter(dev_t dev, struct knote *kn)
+{
+ struct opms_softc *sc = opms_cd.cd_devs[PMSUNIT(dev)];
+ struct klist *klist;
+ int s;
+
+ switch (kn->kn_filter) {
+ case EVFILT_READ:
+ klist = &sc->sc_rsel.si_klist;
+ kn->kn_fop = &opmsread_filtops;
+ break;
+
+ default:
+ return (1);
+ }
+
+ kn->kn_hook = (void *) sc;
+
+ s = spltty();
+ SLIST_INSERT_HEAD(klist, kn, kn_selnext);
+ splx(s);
+
+ return (0);
+}
Home |
Main Index |
Thread Index |
Old Index