Deleted Added
full compact
timer.c (156265) timer.c (156267)
1/*
2 * Copyright (c) 2006 David Xu <davidxu@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 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 *
1/*
2 * Copyright (c) 2006 David Xu <davidxu@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 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 *
26 * $FreeBSD: head/lib/librt/timer.c 156265 2006-03-04 00:08:24Z davidxu $
26 * $FreeBSD: head/lib/librt/timer.c 156267 2006-03-04 00:18:19Z davidxu $
27 *
28 */
29
30#include <sys/cdefs.h>
31#include <sys/types.h>
32#include <sys/syscall.h>
33
34#include "namespace.h"

--- 26 unchanged lines hidden (view full) ---

61__weak_reference(__timer_delete, _timer_delete);
62__weak_reference(__timer_gettime, timer_gettime);
63__weak_reference(__timer_gettime, _timer_gettime);
64__weak_reference(__timer_settime, timer_settime);
65__weak_reference(__timer_settime, _timer_settime);
66__weak_reference(__timer_getoverrun, timer_getoverrun);
67__weak_reference(__timer_getoverrun, _timer_getoverrun);
68
27 *
28 */
29
30#include <sys/cdefs.h>
31#include <sys/types.h>
32#include <sys/syscall.h>
33
34#include "namespace.h"

--- 26 unchanged lines hidden (view full) ---

61__weak_reference(__timer_delete, _timer_delete);
62__weak_reference(__timer_gettime, timer_gettime);
63__weak_reference(__timer_gettime, _timer_gettime);
64__weak_reference(__timer_settime, timer_settime);
65__weak_reference(__timer_settime, _timer_settime);
66__weak_reference(__timer_getoverrun, timer_getoverrun);
67__weak_reference(__timer_getoverrun, _timer_getoverrun);
68
69typedef void (*timer_func)(union sigval val, int timerid, int overrun);
69typedef void (*timer_func)(union sigval val, int overrun);
70
71static void
70
71static void
72timer_dispatch(struct sigev_node *sn, siginfo_t *si)
72timer_dispatch(struct sigev_node *sn)
73{
74 timer_func f = sn->sn_func;
75
76 /* I want to avoid expired notification. */
73{
74 timer_func f = sn->sn_func;
75
76 /* I want to avoid expired notification. */
77 if (si->si_value.sival_int == sn->sn_gen)
78 f(sn->sn_value, si->si_timerid, si->si_overrun);
77 if (sn->sn_info.si_value.sival_int == sn->sn_gen)
78 f(sn->sn_value, sn->sn_info.si_overrun);
79}
80
81int
82__timer_create(clockid_t clockid, struct sigevent *evp, timer_t *timerid)
83{
84 struct __timer *timer;
85 struct sigevent ev;
86 struct sigev_node *sn;

--- 16 unchanged lines hidden (view full) ---

103 return (0);
104 }
105
106 if (__sigev_check_init()) {
107 errno = EINVAL;
108 return (-1);
109 }
110
79}
80
81int
82__timer_create(clockid_t clockid, struct sigevent *evp, timer_t *timerid)
83{
84 struct __timer *timer;
85 struct sigevent ev;
86 struct sigev_node *sn;

--- 16 unchanged lines hidden (view full) ---

103 return (0);
104 }
105
106 if (__sigev_check_init()) {
107 errno = EINVAL;
108 return (-1);
109 }
110
111 sn = __sigev_alloc(SI_TIMER, evp);
111 sn = __sigev_alloc(SI_TIMER, evp, NULL, 0);
112 if (sn == NULL) {
113 errno = EAGAIN;
114 return (-1);
115 }
116
117 __sigev_get_sigevent(sn, &ev, sn->sn_gen);
118 ret = __sys_ktimer_create(clockid, &ev, &timer->oshandle);
119 if (ret != 0) {

--- 63 unchanged lines hidden ---
112 if (sn == NULL) {
113 errno = EAGAIN;
114 return (-1);
115 }
116
117 __sigev_get_sigevent(sn, &ev, sn->sn_gen);
118 ret = __sys_ktimer_create(clockid, &ev, &timer->oshandle);
119 if (ret != 0) {

--- 63 unchanged lines hidden ---