]> git.saurik.com Git - apple/libdispatch.git/blob - testing/dispatch_timer_bit63.c
libdispatch-84.5.5.tar.gz
[apple/libdispatch.git] / testing / dispatch_timer_bit63.c
1 #include <assert.h>
2 #include <stdio.h>
3 #include <string.h>
4 #include <sys/time.h>
5
6 #include <dispatch/dispatch.h>
7
8 #include "dispatch_test.h"
9
10 int main(void)
11 {
12 test_start("Dispatch Source Timer, bit 63");
13
14 //uint64_t interval = 0xffffffffffffffffull;
15 uint64_t interval = 0x8000000000000001ull;
16
17 dispatch_queue_t mainq = dispatch_get_main_queue();
18
19 __block int i = 0;
20 struct timeval start_time;
21
22 gettimeofday(&start_time, NULL);
23
24 dispatch_source_t ds;
25 ds = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, mainq);
26 assert(ds);
27 dispatch_source_set_event_handler(ds, ^{
28 assert(i < 1);
29 printf("%d\n", i++);
30 });
31 dispatch_source_set_timer(ds, DISPATCH_TIME_NOW, interval, 0);
32 dispatch_resume(ds);
33
34 dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 1*NSEC_PER_SEC),
35 dispatch_get_main_queue(), ^{
36 test_stop();
37 });
38
39 dispatch_main();
40
41 return 0;
42 }