1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-04 09:09:56 +00:00

Simplify kqueue API slightly.

Discussed on:	-arch
This commit is contained in:
Jonathan Lemon 2000-07-18 19:31:52 +00:00
parent f8fc6141fb
commit a8e65b915e
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=63452
6 changed files with 29 additions and 38 deletions

View File

@ -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 .

View File

@ -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++;

View File

@ -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); }

View File

@ -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 */

View File

@ -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_ */

View File

@ -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 *)];