genmf.py: print dots instead of "Regenerating n of m" as progress indicator.
[AROS.git] / arch / m68k-amiga / timer / getsystime.c
blobf14227b406b1a6896684d4ab419cf07a3c634219
1 /*
2 Copyright © 1995-2013, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: GetSysTime() - Find out what time it is.
6 Lang: english
7 */
8 #include <proto/exec.h>
10 #define DEBUG 0
11 #include <aros/debug.h>
13 #include <timer_intern.h>
15 #include <devices/timer.h>
16 #include <proto/timer.h>
18 /* See rom/timer/getsystime.c for documentation */
20 AROS_LH1(void, GetSysTime,
21 AROS_LHA(struct timeval *, dest, A0),
22 struct Device *, TimerBase, 11, Timer)
24 AROS_LIBFUNC_INIT
26 struct TimerBase *timerBase = (struct TimerBase *)TimerBase;
27 ULONG tb_eclock_to_usec;
29 Disable();
30 tb_eclock_to_usec = timerBase->tb_eclock_to_usec + GetEClock(timerBase);
31 Enable();
32 dest->tv_secs = timerBase->tb_CurrentTime.tv_secs;
33 dest->tv_micro = (ULONG)(((long long)tb_eclock_to_usec * timerBase->tb_eclock_micro_mult) >> 16);
34 if (dest->tv_micro > timerBase->tb_lastsystime.tv_secs + timerBase->lastsystimetweak) {
35 timerBase->lastsystimetweak = 0;
36 } else {
37 timerBase->lastsystimetweak++;
39 timerBase->tb_lastsystime.tv_secs = dest->tv_secs;
40 timerBase->tb_lastsystime.tv_micro = dest->tv_micro;
41 dest->tv_micro += timerBase->lastsystimetweak;
42 // can only overflow once, e-clock interrupts happen more than once a second
43 if (dest->tv_micro >= 1000000) {
44 dest->tv_micro -= 1000000;
45 dest->tv_secs++;
47 D(bug("systime=%d/%d\n", dest->tv_secs, dest->tv_micro));
49 AROS_LIBFUNC_EXIT
50 } /* GetSysTime */