diff --git a/lib/libc/sys/kqueue.2 b/lib/libc/sys/kqueue.2 index 0ea64bbe0801..afb7e9869bae 100644 --- a/lib/libc/sys/kqueue.2 +++ b/lib/libc/sys/kqueue.2 @@ -39,7 +39,7 @@ .Ft int .Fn kqueue "void" .Ft int -.Fn kevent "int kq" "int nchanges" "struct kevent **changelist" "int nevents" "struct kevent *eventlist" "struct timespec *timeout" +.Fn kevent "int kq" "const struct kevent *changelist" "int nchanges" "struct kevent *eventlist" "int nevents" "const struct timespec *timeout" .Sh DESCRIPTION .Fn kqueue provides a generic method of notifying the user when an event @@ -77,7 +77,7 @@ which will allow sharing of the kqueue between two processes. is used to register events with the queue, and return any pending events to the user. .Fa changelist -is a pointer to an array of pointers to +is a pointer to an array of .Va kevent structures, as defined in .Aq Pa event.h . diff --git a/sys/kern/kern_event.c b/sys/kern/kern_event.c index d4d73ae22b08..724b568456a4 100644 --- a/sys/kern/kern_event.c +++ b/sys/kern/kern_event.c @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD$ + * $FreeBSD$ */ #include @@ -319,20 +319,20 @@ kqueue(struct proc *p, struct kqueue_args *uap) #ifndef _SYS_SYSPROTO_H_ struct kevent_args { int fd; + struct kevent *changelist; int nchanges; - struct kevent **changelist; - int nevents; struct kevent *eventlist; + int nevents; struct timespec *timeout; }; #endif int kevent(struct proc *p, struct kevent_args *uap) { - struct filedesc* fdp = p->p_fd; - struct kevent kev; + struct filedesc* fdp = p->p_fd; + struct kevent *kevp; struct kqueue *kq; - struct file *fp; + struct file *fp; struct timespec ts; int i, n, nerrors, error; @@ -342,8 +342,7 @@ kevent(struct proc *p, struct kevent_args *uap) return (EBADF); if (uap->timeout != NULL) { - error = copyin((caddr_t)uap->timeout, (caddr_t)&ts, - sizeof(ts)); + error = copyin(uap->timeout, &ts, sizeof(ts)); if (error) return error; uap->timeout = &ts; @@ -354,24 +353,21 @@ kevent(struct proc *p, struct kevent_args *uap) while (uap->nchanges > 0) { n = uap->nchanges > KQ_NEVENTS ? KQ_NEVENTS : uap->nchanges; - error = copyin((caddr_t)uap->changelist, (caddr_t)kq->kq_kevp, - n * sizeof(struct kevent *)); + error = copyin(uap->changelist, kq->kq_kev, + n * sizeof(struct kevent)); if (error) return (error); for (i = 0; i < n; i++) { - error = copyin((caddr_t)kq->kq_kevp[i], - (caddr_t)&kev, sizeof(kev)); - if (error) - return (error); - kev.flags &= ~EV_SYSFLAGS; - error = kqueue_register(kq, &kev, p); + kevp = &kq->kq_kev[i]; + kevp->flags &= ~EV_SYSFLAGS; + error = kqueue_register(kq, kevp, p); if (error) { if (uap->nevents != 0) { - kev.flags = EV_ERROR; - kev.data = error; - (void) copyout((caddr_t)&kev, + kevp->flags = EV_ERROR; + kevp->data = error; + (void) copyout((caddr_t)kevp, (caddr_t)uap->eventlist, - sizeof(kev)); + sizeof(*kevp)); uap->eventlist++; uap->nevents--; nerrors++; diff --git a/sys/kern/syscalls.master b/sys/kern/syscalls.master index bc9cfb6b233c..5631a8856e41 100644 --- a/sys/kern/syscalls.master +++ b/sys/kern/syscalls.master @@ -517,9 +517,9 @@ 361 STD BSD { int getresgid(gid_t *rgid, gid_t *egid, gid_t *sgid); } 362 STD BSD { int kqueue(void); } 363 STD BSD { int kevent(int fd, \ - int nchanges, struct kevent **changelist, \ - int nevents, struct kevent *eventlist, \ - struct timespec *timeout); } + const struct kevent *changelist, int nchanges, \ + struct kevent *eventlist, int nevents, \ + const struct timespec *timeout); } 364 STD BSD { int __cap_get_proc(struct cap *cap_p); } 365 STD BSD { int __cap_set_proc(struct cap *cap_p); } 366 STD BSD { int __cap_get_fd(int fd, struct cap *cap_p); } diff --git a/sys/sys/event.h b/sys/sys/event.h index 366b3476f81b..6182bccd0926 100644 --- a/sys/sys/event.h +++ b/sys/sys/event.h @@ -155,9 +155,9 @@ struct timespec; __BEGIN_DECLS int kqueue __P((void)); -int kevent __P((int kq, int nchanges, struct kevent **changelist, - int nevents, struct kevent *eventlist, - struct timespec *timeout)); +int kevent __P((int kq, const struct kevent *changelist, int nchanges, + struct kevent *eventlist, int nevents, + const struct timespec *timeout)); __END_DECLS #endif /* !_KERNEL */ diff --git a/sys/sys/eventvar.h b/sys/sys/eventvar.h index 7046f511057a..3701d4411b70 100644 --- a/sys/sys/eventvar.h +++ b/sys/sys/eventvar.h @@ -29,7 +29,7 @@ #ifndef _SYS_EVENTVAR_H_ #define _SYS_EVENTVAR_H_ -#define KQ_NEVENTS 8 /* minimize copyout calls */ +#define KQ_NEVENTS 8 /* minimize copy{in,out} calls */ #define KQEXTENT 256 /* linear growth by this amount */ struct kqueue { @@ -40,12 +40,7 @@ struct kqueue { int kq_state; #define KQ_SEL 0x01 #define KQ_SLEEP 0x02 - union { - struct kevent *b_kevp[KQ_NEVENTS]; - struct kevent b_kev[KQ_NEVENTS]; - } kq_buf; -#define kq_kevp kq_buf.b_kevp -#define kq_kev kq_buf.b_kev + struct kevent kq_kev[KQ_NEVENTS]; }; #endif /* !_SYS_EVENTVAR_H_ */ diff --git a/sys/sys/sysproto.h b/sys/sys/sysproto.h index 0ead29f88e82..2696e5a93d13 100644 --- a/sys/sys/sysproto.h +++ b/sys/sys/sysproto.h @@ -1015,11 +1015,11 @@ struct kqueue_args { }; struct kevent_args { int fd; char fd_[PAD_(int)]; + const struct kevent * changelist; char changelist_[PAD_(const struct kevent *)]; int nchanges; char nchanges_[PAD_(int)]; - struct kevent ** changelist; char changelist_[PAD_(struct kevent **)]; - int nevents; char nevents_[PAD_(int)]; struct kevent * eventlist; char eventlist_[PAD_(struct kevent *)]; - struct timespec * timeout; char timeout_[PAD_(struct timespec *)]; + int nevents; char nevents_[PAD_(int)]; + const struct timespec * timeout; char timeout_[PAD_(const struct timespec *)]; }; struct __cap_get_proc_args { struct cap * cap_p; char cap_p_[PAD_(struct cap *)];