kern_event.c (109609) | kern_event.c (109623) |
---|---|
1/*- 2 * Copyright (c) 1999,2000,2001 Jonathan Lemon <jlemon@FreeBSD.org> 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 9 unchanged lines hidden (view full) --- 18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 * | 1/*- 2 * Copyright (c) 1999,2000,2001 Jonathan Lemon <jlemon@FreeBSD.org> 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 9 unchanged lines hidden (view full) --- 18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 * |
26 * $FreeBSD: head/sys/kern/kern_event.c 109609 2003-01-21 04:05:49Z hsu $ | 26 * $FreeBSD: head/sys/kern/kern_event.c 109623 2003-01-21 08:56:16Z alfred $ |
27 */ 28 29#include <sys/param.h> 30#include <sys/systm.h> 31#include <sys/kernel.h> 32#include <sys/lock.h> 33#include <sys/mutex.h> 34#include <sys/proc.h> --- 289 unchanged lines hidden (view full) --- 324 kq_ncallouts++; 325 326 tv.tv_sec = kn->kn_sdata / 1000; 327 tv.tv_usec = (kn->kn_sdata % 1000) * 1000; 328 tticks = tvtohz(&tv); 329 330 kn->kn_flags |= EV_CLEAR; /* automatically set */ 331 MALLOC(calloutp, struct callout *, sizeof(*calloutp), | 27 */ 28 29#include <sys/param.h> 30#include <sys/systm.h> 31#include <sys/kernel.h> 32#include <sys/lock.h> 33#include <sys/mutex.h> 34#include <sys/proc.h> --- 289 unchanged lines hidden (view full) --- 324 kq_ncallouts++; 325 326 tv.tv_sec = kn->kn_sdata / 1000; 327 tv.tv_usec = (kn->kn_sdata % 1000) * 1000; 328 tticks = tvtohz(&tv); 329 330 kn->kn_flags |= EV_CLEAR; /* automatically set */ 331 MALLOC(calloutp, struct callout *, sizeof(*calloutp), |
332 M_KQUEUE, M_WAITOK); | 332 M_KQUEUE, 0); |
333 callout_init(calloutp, 0); 334 callout_reset(calloutp, tticks, filt_timerexpire, kn); 335 kn->kn_hook = calloutp; 336 337 return (0); 338} 339 340static void --- 25 unchanged lines hidden (view full) --- 366 struct file *fp; 367 int fd, error; 368 369 mtx_lock(&Giant); 370 fdp = td->td_proc->p_fd; 371 error = falloc(td, &fp, &fd); 372 if (error) 373 goto done2; | 333 callout_init(calloutp, 0); 334 callout_reset(calloutp, tticks, filt_timerexpire, kn); 335 kn->kn_hook = calloutp; 336 337 return (0); 338} 339 340static void --- 25 unchanged lines hidden (view full) --- 366 struct file *fp; 367 int fd, error; 368 369 mtx_lock(&Giant); 370 fdp = td->td_proc->p_fd; 371 error = falloc(td, &fp, &fd); 372 if (error) 373 goto done2; |
374 kq = malloc(sizeof(struct kqueue), M_KQUEUE, M_WAITOK | M_ZERO); | 374 kq = malloc(sizeof(struct kqueue), M_KQUEUE, M_ZERO); |
375 TAILQ_INIT(&kq->kq_head); 376 FILE_LOCK(fp); 377 fp->f_flag = FREAD | FWRITE; 378 fp->f_type = DTYPE_KQUEUE; 379 fp->f_ops = &kqueueops; 380 TAILQ_INIT(&kq->kq_head); 381 fp->f_data = kq; 382 FILE_UNLOCK(fp); --- 591 unchanged lines hidden (view full) --- 974 } 975 976 if (fdp->fd_knlistsize <= kn->kn_id) { 977 size = fdp->fd_knlistsize; 978 while (size <= kn->kn_id) 979 size += KQEXTENT; 980 FILEDESC_UNLOCK(fdp); 981 MALLOC(list, struct klist *, | 375 TAILQ_INIT(&kq->kq_head); 376 FILE_LOCK(fp); 377 fp->f_flag = FREAD | FWRITE; 378 fp->f_type = DTYPE_KQUEUE; 379 fp->f_ops = &kqueueops; 380 TAILQ_INIT(&kq->kq_head); 381 fp->f_data = kq; 382 FILE_UNLOCK(fp); --- 591 unchanged lines hidden (view full) --- 974 } 975 976 if (fdp->fd_knlistsize <= kn->kn_id) { 977 size = fdp->fd_knlistsize; 978 while (size <= kn->kn_id) 979 size += KQEXTENT; 980 FILEDESC_UNLOCK(fdp); 981 MALLOC(list, struct klist *, |
982 size * sizeof(struct klist *), M_KQUEUE, M_WAITOK); | 982 size * sizeof(struct klist *), M_KQUEUE, 0); |
983 FILEDESC_LOCK(fdp); 984 if (fdp->fd_knlistsize > kn->kn_id) { 985 FREE(list, M_KQUEUE); 986 goto bigenough; 987 } 988 if (fdp->fd_knlist != NULL) { 989 bcopy(fdp->fd_knlist, list, 990 fdp->fd_knlistsize * sizeof(struct klist *)); --- 77 unchanged lines hidden (view full) --- 1068 NULL, NULL, UMA_ALIGN_PTR, 0); 1069 1070} 1071SYSINIT(knote, SI_SUB_PSEUDO, SI_ORDER_ANY, knote_init, NULL) 1072 1073static struct knote * 1074knote_alloc(void) 1075{ | 983 FILEDESC_LOCK(fdp); 984 if (fdp->fd_knlistsize > kn->kn_id) { 985 FREE(list, M_KQUEUE); 986 goto bigenough; 987 } 988 if (fdp->fd_knlist != NULL) { 989 bcopy(fdp->fd_knlist, list, 990 fdp->fd_knlistsize * sizeof(struct klist *)); --- 77 unchanged lines hidden (view full) --- 1068 NULL, NULL, UMA_ALIGN_PTR, 0); 1069 1070} 1071SYSINIT(knote, SI_SUB_PSEUDO, SI_ORDER_ANY, knote_init, NULL) 1072 1073static struct knote * 1074knote_alloc(void) 1075{ |
1076 return ((struct knote *)uma_zalloc(knote_zone, M_WAITOK)); | 1076 return ((struct knote *)uma_zalloc(knote_zone, 0)); |
1077} 1078 1079static void 1080knote_free(struct knote *kn) 1081{ 1082 uma_zfree(knote_zone, kn); 1083} | 1077} 1078 1079static void 1080knote_free(struct knote *kn) 1081{ 1082 uma_zfree(knote_zone, kn); 1083} |