Module Name: src Committed By: thorpej Date: Fri Dec 11 01:25:29 UTC 2020
Modified Files: src/sys/kern: sys_select.c src/sys/sys: select.h Log Message: Add sel{record,remove}_knote(), so hide some of the details surrounding knote / kevent registration in the selinfo structure. To generate a diff of this commit: cvs rdiff -u -r1.54 -r1.55 src/sys/kern/sys_select.c cvs rdiff -u -r1.37 -r1.38 src/sys/sys/select.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/kern/sys_select.c diff -u src/sys/kern/sys_select.c:1.54 src/sys/kern/sys_select.c:1.55 --- src/sys/kern/sys_select.c:1.54 Sun Apr 19 20:35:29 2020 +++ src/sys/kern/sys_select.c Fri Dec 11 01:25:29 2020 @@ -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 @@ selrecord(lwp_t *selector, struct selinf } /* + * 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(). */ Index: src/sys/sys/select.h diff -u src/sys/sys/select.h:1.37 src/sys/sys/select.h:1.38 --- src/sys/sys/select.h:1.37 Fri Apr 25 15:52:45 2014 +++ src/sys/sys/select.h Fri Dec 11 01:25:29 2020 @@ -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 proc; 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 *);