typo..
[AROS.git] / test / timer / getsystime.c
blob218d45277bb5cd9f6a9414a763b0bd7f8ce71074
1 /*
2 Copyright © 1995-2016, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include <stdio.h>
7 #include <stdlib.h>
8 #include <devices/timer.h>
10 #include <proto/timer.h>
11 #include <proto/exec.h>
12 #include <proto/dos.h>
13 #include <clib/alib_protos.h>
15 struct Device *TimerBase;
16 struct MsgPort *TimerMP;
17 struct timerequest *TimerIO;
19 int main(int argc, char **argv)
21 struct timeval t1, t2;
22 ULONG secs = 10;
24 if (argc == 2)
25 secs = atoi(argv[1]);
27 printf("Waiting %u seconds\n", (unsigned int)secs);
29 if (TimerMP = CreatePort(NULL, 0))
31 if (TimerIO = (struct timerequest *)CreateExtIO(TimerMP,
32 sizeof(struct timerequest)))
34 if (!(OpenDevice(TIMERNAME, UNIT_MICROHZ,
35 (struct IORequest *)TimerIO, 0)))
37 TimerBase = TimerIO->tr_node.io_Device;
39 GetSysTime(&t1);
41 Delay(secs * 50);
43 GetSysTime(&t2);
45 SubTime(&t2, &t1);
46 printf("result %u secs %u micros\n",
47 (unsigned int)t2.tv_secs,
48 (unsigned int)t2.tv_micro);
49 CloseDevice((struct IORequest *)TimerIO);
51 DeleteExtIO((struct IORequest *)TimerIO);
53 DeletePort(TimerMP);
55 return 0;