timer.c (0:68f95e015346) | timer.c (1885:7bbaa5935f99) |
---|---|
1/* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the | 1/* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the |
5 * Common Development and Distribution License, Version 1.0 only 6 * (the "License"). You may not use this file except in compliance 7 * with the License. | 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. |
8 * 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10 * or http://www.opensolaris.org/os/licensing. 11 * See the License for the specific language governing permissions 12 * and limitations under the License. 13 * 14 * When distributing Covered Code, include this CDDL HEADER in each 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 * If applicable, add the following below this CDDL HEADER, with the 17 * fields enclosed by brackets "[]" replaced with your own identifying 18 * information: Portions Copyright [yyyy] [name of copyright owner] 19 * 20 * CDDL HEADER END 21 */ | 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 * or http://www.opensolaris.org/os/licensing. 10 * See the License for the specific language governing permissions 11 * and limitations under the License. 12 * 13 * When distributing Covered Code, include this CDDL HEADER in each 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ |
21 |
|
22/* | 22/* |
23 * Copyright 2004 Sun Microsystems, Inc. All rights reserved. | 23 * Copyright 2006 Sun Microsystems, Inc. All rights reserved. |
24 * Use is subject to license terms. 25 */ 26 27#pragma ident "%Z%%M% %I% %E% SMI" 28 29#include <sys/timer.h> 30#include <sys/systm.h> 31#include <sys/param.h> --- 398 unchanged lines hidden (view full) --- 430 431 if (it->it_pending > 0) { 432 if (it->it_pending < INT_MAX) 433 it->it_pending++; 434 mutex_exit(&it->it_mutex); 435 } else { 436 if (it->it_flags & IT_PORT) { 437 it->it_pending = 1; | 24 * Use is subject to license terms. 25 */ 26 27#pragma ident "%Z%%M% %I% %E% SMI" 28 29#include <sys/timer.h> 30#include <sys/systm.h> 31#include <sys/param.h> --- 398 unchanged lines hidden (view full) --- 430 431 if (it->it_pending > 0) { 432 if (it->it_pending < INT_MAX) 433 it->it_pending++; 434 mutex_exit(&it->it_mutex); 435 } else { 436 if (it->it_flags & IT_PORT) { 437 it->it_pending = 1; |
438 (void) port_send_event((port_kevent_t *)it->it_portev); | 438 port_send_event((port_kevent_t *)it->it_portev); |
439 mutex_exit(&it->it_mutex); 440 } else if (it->it_flags & IT_SIGNAL) { 441 it->it_pending = 1; 442 mutex_exit(&it->it_mutex); 443 sigaddqa(p, NULL, it->it_sigq); 444 } else { 445 mutex_exit(&it->it_mutex); 446 } --- 24 unchanged lines hidden (view full) --- 471 /* 472 * short copyin() for binary compatibility 473 * fetch oldsigevent to determine how much to copy in. 474 */ 475 if (get_udatamodel() == DATAMODEL_NATIVE) { 476 if (copyin(evp, &ev, sizeof (struct oldsigevent))) 477 return (set_errno(EFAULT)); 478 | 439 mutex_exit(&it->it_mutex); 440 } else if (it->it_flags & IT_SIGNAL) { 441 it->it_pending = 1; 442 mutex_exit(&it->it_mutex); 443 sigaddqa(p, NULL, it->it_sigq); 444 } else { 445 mutex_exit(&it->it_mutex); 446 } --- 24 unchanged lines hidden (view full) --- 471 /* 472 * short copyin() for binary compatibility 473 * fetch oldsigevent to determine how much to copy in. 474 */ 475 if (get_udatamodel() == DATAMODEL_NATIVE) { 476 if (copyin(evp, &ev, sizeof (struct oldsigevent))) 477 return (set_errno(EFAULT)); 478 |
479 if (ev.sigev_notify == SIGEV_PORT) { | 479 if (ev.sigev_notify == SIGEV_PORT || 480 ev.sigev_notify == SIGEV_THREAD) { |
480 if (copyin(ev.sigev_value.sival_ptr, &tim_pnevp, 481 sizeof (port_notify_t))) 482 return (set_errno(EFAULT)); 483 } 484#ifdef _SYSCALL32_IMPL 485 } else { 486 struct sigevent32 ev32; 487 port_notify32_t tim_pnevp32; 488 489 if (copyin(evp, &ev32, sizeof (struct oldsigevent32))) 490 return (set_errno(EFAULT)); 491 ev.sigev_notify = ev32.sigev_notify; 492 ev.sigev_signo = ev32.sigev_signo; 493 /* 494 * See comment in sigqueue32() on handling of 32-bit 495 * sigvals in a 64-bit kernel. 496 */ 497 ev.sigev_value.sival_int = ev32.sigev_value.sival_int; | 481 if (copyin(ev.sigev_value.sival_ptr, &tim_pnevp, 482 sizeof (port_notify_t))) 483 return (set_errno(EFAULT)); 484 } 485#ifdef _SYSCALL32_IMPL 486 } else { 487 struct sigevent32 ev32; 488 port_notify32_t tim_pnevp32; 489 490 if (copyin(evp, &ev32, sizeof (struct oldsigevent32))) 491 return (set_errno(EFAULT)); 492 ev.sigev_notify = ev32.sigev_notify; 493 ev.sigev_signo = ev32.sigev_signo; 494 /* 495 * See comment in sigqueue32() on handling of 32-bit 496 * sigvals in a 64-bit kernel. 497 */ 498 ev.sigev_value.sival_int = ev32.sigev_value.sival_int; |
498 if (ev.sigev_notify == SIGEV_PORT) { | 499 if (ev.sigev_notify == SIGEV_PORT || 500 ev.sigev_notify == SIGEV_THREAD) { |
499 if (copyin((void *)(uintptr_t) 500 ev32.sigev_value.sival_ptr, 501 (void *)&tim_pnevp32, 502 sizeof (port_notify32_t))) 503 return (set_errno(EFAULT)); 504 tim_pnevp.portnfy_port = 505 tim_pnevp32.portnfy_port; 506 tim_pnevp.portnfy_user = 507 (void *)(uintptr_t)tim_pnevp32.portnfy_user; 508 } 509#endif 510 } 511 switch (ev.sigev_notify) { 512 case SIGEV_NONE: 513 break; | 501 if (copyin((void *)(uintptr_t) 502 ev32.sigev_value.sival_ptr, 503 (void *)&tim_pnevp32, 504 sizeof (port_notify32_t))) 505 return (set_errno(EFAULT)); 506 tim_pnevp.portnfy_port = 507 tim_pnevp32.portnfy_port; 508 tim_pnevp.portnfy_user = 509 (void *)(uintptr_t)tim_pnevp32.portnfy_user; 510 } 511#endif 512 } 513 switch (ev.sigev_notify) { 514 case SIGEV_NONE: 515 break; |
514 | |
515 case SIGEV_SIGNAL: 516 if (ev.sigev_signo < 1 || ev.sigev_signo >= NSIG) 517 return (set_errno(EINVAL)); 518 break; | 516 case SIGEV_SIGNAL: 517 if (ev.sigev_signo < 1 || ev.sigev_signo >= NSIG) 518 return (set_errno(EINVAL)); 519 break; |
520 case SIGEV_THREAD: |
|
519 case SIGEV_PORT: 520 break; 521 default: 522 return (set_errno(EINVAL)); 523 } 524 } else { 525 /* 526 * Use the clock's default sigevent (this is a structure copy). --- 48 unchanged lines hidden (view full) --- 575 576 ASSERT(i < timer_max && itp[i] == NULL); 577 578 /* 579 * If we develop other notification mechanisms, this will need 580 * to call into (yet another) backend. 581 */ 582 sigq->sq_info.si_signo = ev.sigev_signo; | 521 case SIGEV_PORT: 522 break; 523 default: 524 return (set_errno(EINVAL)); 525 } 526 } else { 527 /* 528 * Use the clock's default sigevent (this is a structure copy). --- 48 unchanged lines hidden (view full) --- 577 578 ASSERT(i < timer_max && itp[i] == NULL); 579 580 /* 581 * If we develop other notification mechanisms, this will need 582 * to call into (yet another) backend. 583 */ 584 sigq->sq_info.si_signo = ev.sigev_signo; |
583 sigq->sq_info.si_value = ev.sigev_value; | 585 if (evp == NULL) 586 sigq->sq_info.si_value.sival_int = i; 587 else 588 sigq->sq_info.si_value = ev.sigev_value; |
584 sigq->sq_info.si_code = SI_TIMER; 585 sigq->sq_info.si_pid = p->p_pid; 586 sigq->sq_info.si_ctid = PRCTID(p); 587 sigq->sq_info.si_zoneid = getzoneid(); 588 sigq->sq_info.si_uid = crgetruid(cr); 589 sigq->sq_func = timer_signal; 590 sigq->sq_next = NULL; 591 sigq->sq_backptr = it; 592 it->it_sigq = sigq; 593 it->it_backend = backend; 594 it->it_lock = ITLK_LOCKED; 595 itp[i] = it; 596 597 | 589 sigq->sq_info.si_code = SI_TIMER; 590 sigq->sq_info.si_pid = p->p_pid; 591 sigq->sq_info.si_ctid = PRCTID(p); 592 sigq->sq_info.si_zoneid = getzoneid(); 593 sigq->sq_info.si_uid = crgetruid(cr); 594 sigq->sq_func = timer_signal; 595 sigq->sq_next = NULL; 596 sigq->sq_backptr = it; 597 it->it_sigq = sigq; 598 it->it_backend = backend; 599 it->it_lock = ITLK_LOCKED; 600 itp[i] = it; 601 602 |
598 if (ev.sigev_notify == SIGEV_PORT) { | 603 if (ev.sigev_notify == SIGEV_THREAD || 604 ev.sigev_notify == SIGEV_PORT) { |
599 int port; 600 601 /* 602 * This timer is programmed to use event port notification when 603 * the timer fires: 604 * - allocate a port event structure and prepare it to be sent 605 * to the port as soon as the timer fires. 606 * - when the timer fires : --- 383 unchanged lines hidden --- | 605 int port; 606 607 /* 608 * This timer is programmed to use event port notification when 609 * the timer fires: 610 * - allocate a port event structure and prepare it to be sent 611 * to the port as soon as the timer fires. 612 * - when the timer fires : --- 383 unchanged lines hidden --- |