compiler/clib: Don't hide access to aroscbase behind a #define.
[AROS.git] / compiler / clib / clock.c
blob5fa895af7ffdb6acecf2d5198dd138da09420b3f
1 /*
2 Copyright © 1995-2012, The AROS Development Team. All rights reserved.
3 $Id$
5 Returns time passed since start of program.
6 */
8 #include "__arosc_privdata.h"
10 #include <dos/dos.h>
11 #include <proto/dos.h>
12 #include <aros/symbolsets.h>
14 /*****************************************************************************
16 NAME */
17 #include <time.h>
19 clock_t clock (
21 /* SYNOPSIS */
22 void)
24 /* FUNCTION
25 clock() returns an approximation of the time passed since
26 the program was started
28 INPUTS
30 RESULT
31 The time passed in CLOCKS_PER_SEC units. To get the
32 number of seconds divide by CLOCKS_PER_SEC.
34 NOTES
35 This function must not be used in a shared library or
36 in a threaded application.
38 EXAMPLE
40 BUGS
42 SEE ALSO
43 time()
45 INTERNALS
47 ******************************************************************************/
49 struct aroscbase *aroscbase = __GM_GetBase();
50 struct DateStamp t;
51 clock_t retval;
53 DateStamp (&t); /* Get timestamp */
55 /* Day difference */
56 retval = (t.ds_Days - aroscbase->acb_datestamp.ds_Days);
58 /* Convert into minutes */
59 retval *= (24 * 60);
61 /* Minute difference */
62 retval += (t.ds_Minute - aroscbase->acb_datestamp.ds_Minute);
64 /* Convert into CLOCKS_PER_SEC (which is the same as TICKS_PER_SECOND) units */
65 retval *= (60 * TICKS_PER_SECOND);
67 /* Add tick difference */
68 retval += (t.ds_Tick - aroscbase->acb_datestamp.ds_Tick);
70 return retval;
72 } /* clock */
74 int __init_clock(struct aroscbase *aroscbase)
76 DateStamp(&aroscbase->acb_datestamp);
78 return 1;
81 ADD2OPENLIB(__init_clock, 20);