Set ERROR_NO_FREE_STORE upon failure if called from a process (this is
[tangerine.git] / rom / timer / getsystime.c
blob87f16ad6efc162885550ed4200e8b6384de011cf
1 /*
2 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: GetSysTime() - Find out what time it is.
6 Lang: english
7 */
8 #include "timer_intern.h"
9 #include <proto/exec.h>
11 /*****************************************************************************
13 NAME */
14 #include <devices/timer.h>
15 #include <proto/timer.h>
17 AROS_LH1(void, GetSysTime,
19 /* SYNOPSIS */
20 AROS_LHA(struct timeval *, dest, A0),
22 /* LOCATION */
23 struct Device *, TimerBase, 11, Timer)
25 /* FUNCTION
26 GetSysTime() will fill in the supplied timeval with the current
27 system time.
29 INPUTS
30 dest - A pointer to the timeval you want the time stored in.
32 RESULT
33 The timeval "dest" will be filled with the current system time.
35 NOTES
36 This function is safe to call from interrupts.
38 EXAMPLE
40 BUGS
42 SEE ALSO
43 TR_GETSYSTIME, TR_SETSYSTIME
45 INTERNALS
47 HISTORY
48 18-02-1997 iaint Implemented.
50 *****************************************************************************/
52 AROS_LIBFUNC_INIT
54 struct TimerBase *timerBase = (struct TimerBase *)TimerBase;
56 Disable();
57 dest->tv_secs = timerBase->tb_CurrentTime.tv_secs;
58 dest->tv_micro = timerBase->tb_CurrentTime.tv_micro;
59 #if 0 /* Messes up (accelerates) time if called very often
60 in short period of time (Doom). */
62 timerBase->tb_CurrentTime.tv_micro += 1;
63 if(timerBase->tb_CurrentTime.tv_micro > 999999)
65 timerBase->tb_CurrentTime.tv_secs += 1;
66 /* MUST be zero since we are only adding 1 */
67 timerBase->tb_CurrentTime.tv_micro = 0;
69 #endif
70 Enable();
72 AROS_LIBFUNC_EXIT
73 } /* GetSysTime */