Source-Changes-HG archive

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

[src/trunk]: src/sys Add sel{record,remove}_knote(), so hide some of the deta...



details:   https://anonhg.NetBSD.org/src/rev/d21d246936cb
branches:  trunk
changeset: 1017038:d21d246936cb
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Fri Dec 11 01:25:29 2020 +0000

description:
Add sel{record,remove}_knote(), so hide some of the details surrounding
knote / kevent registration in the selinfo structure.

diffstat:

 sys/kern/sys_select.c |  26 ++++++++++++++++++++++++--
 sys/sys/select.h      |   5 ++++-
 2 files changed, 28 insertions(+), 3 deletions(-)

diffs (70 lines):

diff -r 9f45c16115fc -r d21d246936cb sys/kern/sys_select.c
--- a/sys/kern/sys_select.c     Fri Dec 11 01:08:51 2020 +0000
+++ b/sys/kern/sys_select.c     Fri Dec 11 01:25:29 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: sys_select.c,v 1.54 2020/04/19 20:35:29 ad Exp $       */
+/*     $NetBSD: sys_select.c,v 1.55 2020/12/11 01:25:29 thorpej Exp $  */
 
 /*-
  * Copyright (c) 2007, 2008, 2009, 2010, 2019, 2020 The NetBSD Foundation, Inc.
@@ -84,7 +84,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sys_select.c,v 1.54 2020/04/19 20:35:29 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sys_select.c,v 1.55 2020/12/11 01:25:29 thorpej Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -668,6 +668,28 @@
 }
 
 /*
+ * Record a knote.
+ *
+ * The caller holds the same lock as for selrecord().
+ */
+void
+selrecord_knote(struct selinfo *sip, struct knote *kn)
+{
+       SLIST_INSERT_HEAD(&sip->sel_klist, kn, kn_selnext);
+}
+
+/*
+ * Remove a knote.
+ *
+ * The caller holds the same lock as for selrecord().
+ */
+void
+selremove_knote(struct selinfo *sip, struct knote *kn)
+{
+       SLIST_REMOVE(&sip->sel_klist, kn, knote, kn_selnext);
+}
+
+/*
  * sel_setevents: a helper function for selnotify(), to set the events
  * for LWP sleeping in selcommon() or pollcommon().
  */
diff -r 9f45c16115fc -r d21d246936cb sys/sys/select.h
--- a/sys/sys/select.h  Fri Dec 11 01:08:51 2020 +0000
+++ b/sys/sys/select.h  Fri Dec 11 01:25:29 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: select.h,v 1.37 2014/04/25 15:52:45 pooka Exp $        */
+/*     $NetBSD: select.h,v 1.38 2020/12/11 01:25:29 thorpej Exp $      */
 
 /*-
  * Copyright (c) 1992, 1993
@@ -47,10 +47,13 @@
 struct timespec;
 struct cpu_info;
 struct socket;
+struct knote;
 
 int    selcommon(register_t *, int, fd_set *, fd_set *, fd_set *,
     struct timespec *, sigset_t *);
 void   selrecord(struct lwp *selector, struct selinfo *);
+void   selrecord_knote(struct selinfo *, struct knote *);
+void   selremove_knote(struct selinfo *, struct knote *);
 void   selnotify(struct selinfo *, int, long);
 void   selsysinit(struct cpu_info *);
 void   selinit(struct selinfo *);



Home | Main Index | Thread Index | Old Index