1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33#include <linux/mm.h>
34#include <linux/interrupt.h>
35#include <linux/slab.h>
36#include <linux/time.h>
37#include <linux/mutex.h>
38
39#include <asm/uaccess.h>
40#include <linux/list.h>
41#include <linux/init.h>
42#include <linux/compiler.h>
43#include <linux/idr.h>
44#include <linux/posix-timers.h>
45#include <linux/syscalls.h>
46#include <linux/wait.h>
47#include <linux/workqueue.h>
48#include <linux/module.h>
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71static struct kmem_cache *posix_timers_cache;
72static struct idr posix_timers_id;
73static DEFINE_SPINLOCK(idr_lock);
74
75
76
77
78
79#if SIGEV_THREAD_ID != (SIGEV_THREAD_ID & \
80 ~(SIGEV_SIGNAL | SIGEV_NONE | SIGEV_THREAD))
81#error "SIGEV_THREAD_ID must not share bit with other SIGEV values!"
82#endif
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134static struct k_clock posix_clocks[MAX_CLOCKS];
135
136
137
138
139static int common_nsleep(const clockid_t, int flags, struct timespec *t,
140 struct timespec __user *rmtp);
141static void common_timer_get(struct k_itimer *, struct itimerspec *);
142static int common_timer_set(struct k_itimer *, int,
143 struct itimerspec *, struct itimerspec *);
144static int common_timer_del(struct k_itimer *timer);
145
146static enum hrtimer_restart posix_timer_fn(struct hrtimer *data);
147
148static struct k_itimer *lock_timer(timer_t timer_id, unsigned long *flags);
149
150static inline void unlock_timer(struct k_itimer *timr, unsigned long flags)
151{
152 spin_unlock_irqrestore(&timr->it_lock, flags);
153}
154
155
156
157
158#define CLOCK_DISPATCH(clock, call, arglist) \
159 ((clock) < 0 ? posix_cpu_##call arglist : \
160 (posix_clocks[clock].call != NULL \
161 ? (*posix_clocks[clock].call) arglist : common_##call arglist))
162
163
164
165
166
167
168
169
170
171static inline int common_clock_getres(const clockid_t which_clock,
172 struct timespec *tp)
173{
174 tp->tv_sec = 0;
175 tp->tv_nsec = posix_clocks[which_clock].res;
176 return 0;
177}
178
179
180
181
182static int common_clock_get(clockid_t which_clock, struct timespec *tp)
183{
184 ktime_get_real_ts(tp);
185 return 0;
186}
187
188static inline int common_clock_set(const clockid_t which_clock,
189 struct timespec *tp)
190{
191 return do_sys_settimeofday(tp, NULL);
192}
193
194static int common_timer_create(struct k_itimer *new_timer)
195{
196 hrtimer_init(&new_timer->it.real.timer, new_timer->it_clock, 0);
197 return 0;
198}
199
200static int no_timer_create(struct k_itimer *new_timer)
201{
202 return -EOPNOTSUPP;
203}
204
205
206
207
208static inline int invalid_clockid(const clockid_t which_clock)
209{
210 if (which_clock < 0)
211 return 0;
212 if ((unsigned) which_clock >= MAX_CLOCKS)
213 return 1;
214 if (posix_clocks[which_clock].clock_getres != NULL)
215 return 0;
216 if (posix_clocks[which_clock].res != 0)
217 return 0;
218 return 1;
219}
220
221
222
223
224static int posix_ktime_get_ts(clockid_t which_clock, struct timespec *tp)
225{
226 ktime_get_ts(tp);
227 return 0;
228}
229
230
231
232
233static int posix_get_monotonic_raw(clockid_t which_clock, struct timespec *tp)
234{
235 getrawmonotonic(tp);
236 return 0;
237}
238
239
240
241
242static __init int init_posix_timers(void)
243{
244 struct k_clock clock_realtime = {
245 .clock_getres = hrtimer_get_res,
246 };
247 struct k_clock clock_monotonic = {
248 .clock_getres = hrtimer_get_res,
249 .clock_get = posix_ktime_get_ts,
250 .clock_set = do_posix_clock_nosettime,
251 };
252 struct k_clock clock_monotonic_raw = {
253 .clock_getres = hrtimer_get_res,
254 .clock_get = posix_get_monotonic_raw,
255 .clock_set = do_posix_clock_nosettime,
256 .timer_create = no_timer_create,
257 };
258
259 register_posix_clock(CLOCK_REALTIME, &clock_realtime);
260 register_posix_clock(CLOCK_MONOTONIC, &clock_monotonic);
261 register_posix_clock(CLOCK_MONOTONIC_RAW, &clock_monotonic_raw);
262
263 posix_timers_cache = kmem_cache_create("posix_timers_cache",
264 sizeof (struct k_itimer), 0, SLAB_PANIC,
265 NULL);
266 idr_init(&posix_timers_id);
267 return 0;
268}
269
270__initcall(init_posix_timers);
271
272static void schedule_next_timer(struct k_itimer *timr)
273{
274 struct hrtimer *timer = &timr->it.real.timer;
275
276 if (timr->it.real.interval.tv64 == 0)
277 return;
278
279 timr->it_overrun += (unsigned int) hrtimer_forward(timer,
280 timer->base->get_time(),
281 timr->it.real.interval);
282
283 timr->it_overrun_last = timr->it_overrun;
284 timr->it_overrun = -1;
285 ++timr->it_requeue_pending;
286 hrtimer_restart(timer);
287}
288
289
290
291
292
293
294
295
296
297
298
299
300void do_schedule_next_timer(struct siginfo *info)
301{
302 struct k_itimer *timr;
303 unsigned long flags;
304
305 timr = lock_timer(info->si_tid, &flags);
306
307 if (timr && timr->it_requeue_pending == info->si_sys_private) {
308 if (timr->it_clock < 0)
309 posix_cpu_timer_schedule(timr);
310 else
311 schedule_next_timer(timr);
312
313 info->si_overrun += timr->it_overrun_last;
314 }
315
316 if (timr)
317 unlock_timer(timr, flags);
318}
319
320int posix_timer_event(struct k_itimer *timr, int si_private)
321{
322 int shared, ret;
323
324
325
326
327
328
329
330
331
332
333
334 timr->sigq->info.si_sys_private = si_private;
335
336 shared = !(timr->it_sigev_notify & SIGEV_THREAD_ID);
337 ret = send_sigqueue(timr->sigq, timr->it_process, shared);
338
339 return ret > 0;
340}
341EXPORT_SYMBOL_GPL(posix_timer_event);
342
343
344
345
346
347
348
349
350static enum hrtimer_restart posix_timer_fn(struct hrtimer *timer)
351{
352 struct k_itimer *timr;
353 unsigned long flags;
354 int si_private = 0;
355 enum hrtimer_restart ret = HRTIMER_NORESTART;
356
357 timr = container_of(timer, struct k_itimer, it.real.timer);
358 spin_lock_irqsave(&timr->it_lock, flags);
359
360 if (timr->it.real.interval.tv64 != 0)
361 si_private = ++timr->it_requeue_pending;
362
363 if (posix_timer_event(timr, si_private)) {
364
365
366
367
368
369 if (timr->it.real.interval.tv64 != 0) {
370 ktime_t now = hrtimer_cb_get_time(timer);
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394#ifdef CONFIG_HIGH_RES_TIMERS
395 {
396 ktime_t kj = ktime_set(0, NSEC_PER_SEC / HZ);
397
398 if (timr->it.real.interval.tv64 < kj.tv64)
399 now = ktime_add(now, kj);
400 }
401#endif
402 timr->it_overrun += (unsigned int)
403 hrtimer_forward(timer, now,
404 timr->it.real.interval);
405 ret = HRTIMER_RESTART;
406 ++timr->it_requeue_pending;
407 }
408 }
409
410 unlock_timer(timr, flags);
411 return ret;
412}
413
414static struct task_struct * good_sigevent(sigevent_t * event)
415{
416 struct task_struct *rtn = current->group_leader;
417
418 if ((event->sigev_notify & SIGEV_THREAD_ID ) &&
419 (!(rtn = find_task_by_vpid(event->sigev_notify_thread_id)) ||
420 !same_thread_group(rtn, current) ||
421 (event->sigev_notify & ~SIGEV_THREAD_ID) != SIGEV_SIGNAL))
422 return NULL;
423
424 if (((event->sigev_notify & ~SIGEV_THREAD_ID) != SIGEV_NONE) &&
425 ((event->sigev_signo <= 0) || (event->sigev_signo > SIGRTMAX)))
426 return NULL;
427
428 return rtn;
429}
430
431void register_posix_clock(const clockid_t clock_id, struct k_clock *new_clock)
432{
433 if ((unsigned) clock_id >= MAX_CLOCKS) {
434 printk("POSIX clock register failed for clock_id %d\n",
435 clock_id);
436 return;
437 }
438
439 posix_clocks[clock_id] = *new_clock;
440}
441EXPORT_SYMBOL_GPL(register_posix_clock);
442
443static struct k_itimer * alloc_posix_timer(void)
444{
445 struct k_itimer *tmr;
446 tmr = kmem_cache_zalloc(posix_timers_cache, GFP_KERNEL);
447 if (!tmr)
448 return tmr;
449 if (unlikely(!(tmr->sigq = sigqueue_alloc()))) {
450 kmem_cache_free(posix_timers_cache, tmr);
451 return NULL;
452 }
453 memset(&tmr->sigq->info, 0, sizeof(siginfo_t));
454 return tmr;
455}
456
457#define IT_ID_SET 1
458#define IT_ID_NOT_SET 0
459static void release_posix_timer(struct k_itimer *tmr, int it_id_set)
460{
461 if (it_id_set) {
462 unsigned long flags;
463 spin_lock_irqsave(&idr_lock, flags);
464 idr_remove(&posix_timers_id, tmr->it_id);
465 spin_unlock_irqrestore(&idr_lock, flags);
466 }
467 sigqueue_free(tmr->sigq);
468 kmem_cache_free(posix_timers_cache, tmr);
469}
470
471
472
473asmlinkage long
474sys_timer_create(const clockid_t which_clock,
475 struct sigevent __user *timer_event_spec,
476 timer_t __user * created_timer_id)
477{
478 struct k_itimer *new_timer;
479 int error, new_timer_id;
480 struct task_struct *process;
481 sigevent_t event;
482 int it_id_set = IT_ID_NOT_SET;
483
484 if (invalid_clockid(which_clock))
485 return -EINVAL;
486
487 new_timer = alloc_posix_timer();
488 if (unlikely(!new_timer))
489 return -EAGAIN;
490
491 spin_lock_init(&new_timer->it_lock);
492 retry:
493 if (unlikely(!idr_pre_get(&posix_timers_id, GFP_KERNEL))) {
494 error = -EAGAIN;
495 goto out;
496 }
497 spin_lock_irq(&idr_lock);
498 error = idr_get_new(&posix_timers_id, new_timer, &new_timer_id);
499 spin_unlock_irq(&idr_lock);
500 if (error) {
501 if (error == -EAGAIN)
502 goto retry;
503
504
505
506
507 error = -EAGAIN;
508 goto out;
509 }
510
511 it_id_set = IT_ID_SET;
512 new_timer->it_id = (timer_t) new_timer_id;
513 new_timer->it_clock = which_clock;
514 new_timer->it_overrun = -1;
515 error = CLOCK_DISPATCH(which_clock, timer_create, (new_timer));
516 if (error)
517 goto out;
518
519
520
521
522
523 if (copy_to_user(created_timer_id,
524 &new_timer_id, sizeof (new_timer_id))) {
525 error = -EFAULT;
526 goto out;
527 }
528 if (timer_event_spec) {
529 if (copy_from_user(&event, timer_event_spec, sizeof (event))) {
530 error = -EFAULT;
531 goto out;
532 }
533 rcu_read_lock();
534 process = good_sigevent(&event);
535 if (process)
536 get_task_struct(process);
537 rcu_read_unlock();
538 if (!process) {
539 error = -EINVAL;
540 goto out;
541 }
542 } else {
543 event.sigev_notify = SIGEV_SIGNAL;
544 event.sigev_signo = SIGALRM;
545 event.sigev_value.sival_int = new_timer->it_id;
546 process = current->group_leader;
547 get_task_struct(process);
548 }
549
550 new_timer->it_sigev_notify = event.sigev_notify;
551 new_timer->sigq->info.si_signo = event.sigev_signo;
552 new_timer->sigq->info.si_value = event.sigev_value;
553 new_timer->sigq->info.si_tid = new_timer->it_id;
554 new_timer->sigq->info.si_code = SI_TIMER;
555
556 spin_lock_irq(¤t->sighand->siglock);
557 new_timer->it_process = process;
558 list_add(&new_timer->list, ¤t->signal->posix_timers);
559 spin_unlock_irq(¤t->sighand->siglock);
560
561 return 0;
562
563
564
565
566
567
568out:
569 release_posix_timer(new_timer, it_id_set);
570 return error;
571}
572
573
574
575
576
577
578
579
580static struct k_itimer *lock_timer(timer_t timer_id, unsigned long *flags)
581{
582 struct k_itimer *timr;
583
584
585
586
587
588 spin_lock_irqsave(&idr_lock, *flags);
589 timr = idr_find(&posix_timers_id, (int)timer_id);
590 if (timr) {
591 spin_lock(&timr->it_lock);
592 if (timr->it_process &&
593 same_thread_group(timr->it_process, current)) {
594 spin_unlock(&idr_lock);
595 return timr;
596 }
597 spin_unlock(&timr->it_lock);
598 }
599 spin_unlock_irqrestore(&idr_lock, *flags);
600
601 return NULL;
602}
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620static void
621common_timer_get(struct k_itimer *timr, struct itimerspec *cur_setting)
622{
623 ktime_t now, remaining, iv;
624 struct hrtimer *timer = &timr->it.real.timer;
625
626 memset(cur_setting, 0, sizeof(struct itimerspec));
627
628 iv = timr->it.real.interval;
629
630
631 if (iv.tv64)
632 cur_setting->it_interval = ktime_to_timespec(iv);
633 else if (!hrtimer_active(timer) &&
634 (timr->it_sigev_notify & ~SIGEV_THREAD_ID) != SIGEV_NONE)
635 return;
636
637 now = timer->base->get_time();
638
639
640
641
642
643
644 if (iv.tv64 && (timr->it_requeue_pending & REQUEUE_PENDING ||
645 (timr->it_sigev_notify & ~SIGEV_THREAD_ID) == SIGEV_NONE))
646 timr->it_overrun += (unsigned int) hrtimer_forward(timer, now, iv);
647
648 remaining = ktime_sub(hrtimer_get_expires(timer), now);
649
650 if (remaining.tv64 <= 0) {
651
652
653
654
655 if ((timr->it_sigev_notify & ~SIGEV_THREAD_ID) != SIGEV_NONE)
656 cur_setting->it_value.tv_nsec = 1;
657 } else
658 cur_setting->it_value = ktime_to_timespec(remaining);
659}
660
661
662asmlinkage long
663sys_timer_gettime(timer_t timer_id, struct itimerspec __user *setting)
664{
665 struct k_itimer *timr;
666 struct itimerspec cur_setting;
667 unsigned long flags;
668
669 timr = lock_timer(timer_id, &flags);
670 if (!timr)
671 return -EINVAL;
672
673 CLOCK_DISPATCH(timr->it_clock, timer_get, (timr, &cur_setting));
674
675 unlock_timer(timr, flags);
676
677 if (copy_to_user(setting, &cur_setting, sizeof (cur_setting)))
678 return -EFAULT;
679
680 return 0;
681}
682
683
684
685
686
687
688
689
690
691
692asmlinkage long
693sys_timer_getoverrun(timer_t timer_id)
694{
695 struct k_itimer *timr;
696 int overrun;
697 unsigned long flags;
698
699 timr = lock_timer(timer_id, &flags);
700 if (!timr)
701 return -EINVAL;
702
703 overrun = timr->it_overrun_last;
704 unlock_timer(timr, flags);
705
706 return overrun;
707}
708
709
710
711static int
712common_timer_set(struct k_itimer *timr, int flags,
713 struct itimerspec *new_setting, struct itimerspec *old_setting)
714{
715 struct hrtimer *timer = &timr->it.real.timer;
716 enum hrtimer_mode mode;
717
718 if (old_setting)
719 common_timer_get(timr, old_setting);
720
721
722 timr->it.real.interval.tv64 = 0;
723
724
725
726
727 if (hrtimer_try_to_cancel(timer) < 0)
728 return TIMER_RETRY;
729
730 timr->it_requeue_pending = (timr->it_requeue_pending + 2) &
731 ~REQUEUE_PENDING;
732 timr->it_overrun_last = 0;
733
734
735 if (!new_setting->it_value.tv_sec && !new_setting->it_value.tv_nsec)
736 return 0;
737
738 mode = flags & TIMER_ABSTIME ? HRTIMER_MODE_ABS : HRTIMER_MODE_REL;
739 hrtimer_init(&timr->it.real.timer, timr->it_clock, mode);
740 timr->it.real.timer.function = posix_timer_fn;
741
742 hrtimer_set_expires(timer, timespec_to_ktime(new_setting->it_value));
743
744
745 timr->it.real.interval = timespec_to_ktime(new_setting->it_interval);
746
747
748 if (((timr->it_sigev_notify & ~SIGEV_THREAD_ID) == SIGEV_NONE)) {
749
750 if (mode == HRTIMER_MODE_REL) {
751 hrtimer_add_expires(timer, timer->base->get_time());
752 }
753 return 0;
754 }
755
756 hrtimer_start_expires(timer, mode);
757 return 0;
758}
759
760
761asmlinkage long
762sys_timer_settime(timer_t timer_id, int flags,
763 const struct itimerspec __user *new_setting,
764 struct itimerspec __user *old_setting)
765{
766 struct k_itimer *timr;
767 struct itimerspec new_spec, old_spec;
768 int error = 0;
769 unsigned long flag;
770 struct itimerspec *rtn = old_setting ? &old_spec : NULL;
771
772 if (!new_setting)
773 return -EINVAL;
774
775 if (copy_from_user(&new_spec, new_setting, sizeof (new_spec)))
776 return -EFAULT;
777
778 if (!timespec_valid(&new_spec.it_interval) ||
779 !timespec_valid(&new_spec.it_value))
780 return -EINVAL;
781retry:
782 timr = lock_timer(timer_id, &flag);
783 if (!timr)
784 return -EINVAL;
785
786 error = CLOCK_DISPATCH(timr->it_clock, timer_set,
787 (timr, flags, &new_spec, rtn));
788
789 unlock_timer(timr, flag);
790 if (error == TIMER_RETRY) {
791 rtn = NULL;
792 goto retry;
793 }
794
795 if (old_setting && !error &&
796 copy_to_user(old_setting, &old_spec, sizeof (old_spec)))
797 error = -EFAULT;
798
799 return error;
800}
801
802static inline int common_timer_del(struct k_itimer *timer)
803{
804 timer->it.real.interval.tv64 = 0;
805
806 if (hrtimer_try_to_cancel(&timer->it.real.timer) < 0)
807 return TIMER_RETRY;
808 return 0;
809}
810
811static inline int timer_delete_hook(struct k_itimer *timer)
812{
813 return CLOCK_DISPATCH(timer->it_clock, timer_del, (timer));
814}
815
816
817asmlinkage long
818sys_timer_delete(timer_t timer_id)
819{
820 struct k_itimer *timer;
821 unsigned long flags;
822
823retry_delete:
824 timer = lock_timer(timer_id, &flags);
825 if (!timer)
826 return -EINVAL;
827
828 if (timer_delete_hook(timer) == TIMER_RETRY) {
829 unlock_timer(timer, flags);
830 goto retry_delete;
831 }
832
833 spin_lock(¤t->sighand->siglock);
834 list_del(&timer->list);
835 spin_unlock(¤t->sighand->siglock);
836
837
838
839
840 put_task_struct(timer->it_process);
841 timer->it_process = NULL;
842
843 unlock_timer(timer, flags);
844 release_posix_timer(timer, IT_ID_SET);
845 return 0;
846}
847
848
849
850
851static void itimer_delete(struct k_itimer *timer)
852{
853 unsigned long flags;
854
855retry_delete:
856 spin_lock_irqsave(&timer->it_lock, flags);
857
858 if (timer_delete_hook(timer) == TIMER_RETRY) {
859 unlock_timer(timer, flags);
860 goto retry_delete;
861 }
862 list_del(&timer->list);
863
864
865
866
867 put_task_struct(timer->it_process);
868 timer->it_process = NULL;
869
870 unlock_timer(timer, flags);
871 release_posix_timer(timer, IT_ID_SET);
872}
873
874
875
876
877
878void exit_itimers(struct signal_struct *sig)
879{
880 struct k_itimer *tmr;
881
882 while (!list_empty(&sig->posix_timers)) {
883 tmr = list_entry(sig->posix_timers.next, struct k_itimer, list);
884 itimer_delete(tmr);
885 }
886}
887
888
889int do_posix_clock_nosettime(const clockid_t clockid, struct timespec *tp)
890{
891 return -EINVAL;
892}
893EXPORT_SYMBOL_GPL(do_posix_clock_nosettime);
894
895int do_posix_clock_nonanosleep(const clockid_t clock, int flags,
896 struct timespec *t, struct timespec __user *r)
897{
898#ifndef ENOTSUP
899 return -EOPNOTSUPP;
900#else
901 return -ENOTSUP;
902#endif
903}
904EXPORT_SYMBOL_GPL(do_posix_clock_nonanosleep);
905
906asmlinkage long sys_clock_settime(const clockid_t which_clock,
907 const struct timespec __user *tp)
908{
909 struct timespec new_tp;
910
911 if (invalid_clockid(which_clock))
912 return -EINVAL;
913 if (copy_from_user(&new_tp, tp, sizeof (*tp)))
914 return -EFAULT;
915
916 return CLOCK_DISPATCH(which_clock, clock_set, (which_clock, &new_tp));
917}
918
919asmlinkage long
920sys_clock_gettime(const clockid_t which_clock, struct timespec __user *tp)
921{
922 struct timespec kernel_tp;
923 int error;
924
925 if (invalid_clockid(which_clock))
926 return -EINVAL;
927 error = CLOCK_DISPATCH(which_clock, clock_get,
928 (which_clock, &kernel_tp));
929 if (!error && copy_to_user(tp, &kernel_tp, sizeof (kernel_tp)))
930 error = -EFAULT;
931
932 return error;
933
934}
935
936asmlinkage long
937sys_clock_getres(const clockid_t which_clock, struct timespec __user *tp)
938{
939 struct timespec rtn_tp;
940 int error;
941
942 if (invalid_clockid(which_clock))
943 return -EINVAL;
944
945 error = CLOCK_DISPATCH(which_clock, clock_getres,
946 (which_clock, &rtn_tp));
947
948 if (!error && tp && copy_to_user(tp, &rtn_tp, sizeof (rtn_tp))) {
949 error = -EFAULT;
950 }
951
952 return error;
953}
954
955
956
957
958static int common_nsleep(const clockid_t which_clock, int flags,
959 struct timespec *tsave, struct timespec __user *rmtp)
960{
961 return hrtimer_nanosleep(tsave, rmtp, flags & TIMER_ABSTIME ?
962 HRTIMER_MODE_ABS : HRTIMER_MODE_REL,
963 which_clock);
964}
965
966asmlinkage long
967sys_clock_nanosleep(const clockid_t which_clock, int flags,
968 const struct timespec __user *rqtp,
969 struct timespec __user *rmtp)
970{
971 struct timespec t;
972
973 if (invalid_clockid(which_clock))
974 return -EINVAL;
975
976 if (copy_from_user(&t, rqtp, sizeof (struct timespec)))
977 return -EFAULT;
978
979 if (!timespec_valid(&t))
980 return -EINVAL;
981
982 return CLOCK_DISPATCH(which_clock, nsleep,
983 (which_clock, flags, &t, rmtp));
984}
985
986
987
988
989static int common_nsleep_restart(struct restart_block *restart_block)
990{
991 return hrtimer_nanosleep_restart(restart_block);
992}
993
994
995
996
997
998long
999clock_nanosleep_restart(struct restart_block *restart_block)
1000{
1001 clockid_t which_clock = restart_block->arg0;
1002
1003 return CLOCK_DISPATCH(which_clock, nsleep_restart,
1004 (restart_block));
1005}