summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authorjlemon <jlemon@FreeBSD.org>2000-07-18 19:31:52 +0000
committerjlemon <jlemon@FreeBSD.org>2000-07-18 19:31:52 +0000
commit717104720438689588cc958bf3016b3f7930189b (patch)
tree05255c6232c0c7bad7137781cf031061e43a8d0d /sys
parent613d783c9563e8d6915c7b58a4d9fd84bd83c356 (diff)
downloadFreeBSD-src-717104720438689588cc958bf3016b3f7930189b.zip
FreeBSD-src-717104720438689588cc958bf3016b3f7930189b.tar.gz
Simplify kqueue API slightly.
Discussed on: -arch
Diffstat (limited to 'sys')
-rw-r--r--sys/kern/kern_event.c36
-rw-r--r--sys/kern/syscalls.master6
-rw-r--r--sys/sys/event.h6
-rw-r--r--sys/sys/eventvar.h9
-rw-r--r--sys/sys/sysproto.h6
5 files changed, 27 insertions, 36 deletions
diff --git a/sys/kern/kern_event.c b/sys/kern/kern_event.c
index d4d73ae..724b568 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 <sys/param.h>
@@ -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 bc9cfb6..5631a88 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 366b347..6182bcc 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 7046f51..3701d44 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 0ead29f..2696e5a 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 *)];
OpenPOWER on IntegriCloud