refactored some code. compiles now without suppresing any warning with gcc-6.3.0.
[AROS.git] / rom / timer / readeclock.c
blobf3743d116fe3e55a9a2d2b8867c04e7044b97de0
1 /*
2 Copyright © 1995-2011, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: ReadEClock() - read the base frequency of timers.
6 Lang: english
7 */
9 /*****************************************************************************
11 NAME */
12 #include <exec/execbase.h>
13 #include <devices/timer.h>
14 #include <proto/timer.h>
15 #include <proto/exec.h>
17 #include "timer_intern.h"
19 AROS_LH1(ULONG, ReadEClock,
21 /* SYNOPSIS */
22 AROS_LHA(struct EClockVal *, dest, A0),
24 /* LOCATION */
25 struct TimerBase *, TimerBase, 10, Timer)
27 /* FUNCTION
28 ReadEClock() reads current value of E-Clock and stores
29 it in the destination EClockVal structure passed as
30 argument. It also returns the frequency of EClock of the
31 system.
33 This call is supposed to be very fast.
34 INPUTS
35 dest - Destination EClockVal
37 RESULT
38 The EClock frequency (tics/s)
40 NOTES
41 This function is safe to call from interrupts.
43 EXAMPLE
45 BUGS
47 SEE ALSO
49 INTERNALS
51 HISTORY
52 19-08-2005 schulz Implemented.
54 *****************************************************************************/
56 AROS_LIBFUNC_INIT
58 Disable();
60 EClockUpdate(TimerBase);
61 dest->ev_hi = (ULONG)(TimerBase->tb_ticks_total >> 32);
62 dest->ev_lo = (ULONG)(TimerBase->tb_ticks_total & 0xffffffff);
64 Enable();
66 /* We could use SysBase->ex_EClockFrequency here, but we avoid it for
67 the case if some dumb head attempts to change it */
68 return TimerBase->tb_eclock_rate;
70 AROS_LIBFUNC_EXIT
71 } /* CmpTime */