2 Copyright © 1995-2013, The AROS Development Team. All rights reserved.
5 Return the current time in seconds.
8 #include <proto/exec.h>
9 #include <proto/timer.h>
13 #include "__stdc_intbase.h"
16 #include <aros/debug.h>
18 static int __init_timerbase(struct StdCIntBase
*StdCBase
);
19 struct Device
*TimerBase
= NULL
;
21 /*****************************************************************************
32 time() returns the time since 00:00:00 GMT, January 1, 1970,
36 tloc - If this pointer is non-NULL, then the time is written into
37 this variable as well.
40 The number of seconds.
43 This function must not be used in a shared library or
44 in a threaded application.
49 // tt1 and tt2 are the same
58 ctime(), asctime(), localtime()
62 ******************************************************************************/
66 /* We get TimerBase here and not during LIBINIT because timer.device is not available
67 when stdc.library is initialized.
69 if (TimerBase
== NULL
)
70 __init_timerbase((struct StdCIntBase
*)__aros_getbase_StdCBase());
71 if (TimerBase
== NULL
)
78 tv
.tv_sec
+= 2922 * 1440 * 60;
80 tv
.tv_sec
+= __stdc_gmtoffset() * 60;
88 static int __init_timerbase(struct StdCIntBase
*StdCBase
)
90 D(bug("__init_timerbase\n"));
92 StdCBase
->timeport
.mp_Node
.ln_Type
= NT_MSGPORT
;
93 StdCBase
->timeport
.mp_Node
.ln_Pri
= 0;
94 StdCBase
->timeport
.mp_Node
.ln_Name
= NULL
;
95 StdCBase
->timeport
.mp_Flags
= PA_IGNORE
;
96 StdCBase
->timeport
.mp_SigTask
= FindTask(NULL
);
97 StdCBase
->timeport
.mp_SigBit
= 0;
98 NEWLIST(&StdCBase
->timeport
.mp_MsgList
);
100 StdCBase
->timereq
.tr_node
.io_Message
.mn_Node
.ln_Type
= NT_MESSAGE
;
101 StdCBase
->timereq
.tr_node
.io_Message
.mn_Node
.ln_Pri
= 0;
102 StdCBase
->timereq
.tr_node
.io_Message
.mn_Node
.ln_Name
= NULL
;
103 StdCBase
->timereq
.tr_node
.io_Message
.mn_ReplyPort
= &StdCBase
->timeport
;
104 StdCBase
->timereq
.tr_node
.io_Message
.mn_Length
= sizeof (StdCBase
->timereq
);
107 "timer.device", UNIT_VBLANK
,
108 (struct IORequest
*)&StdCBase
->timereq
, 0
112 TimerBase
= (struct Device
*)StdCBase
->timereq
.tr_node
.io_Device
;
113 D(bug("__init_timerbase TimerBase=%x\n", TimerBase
));
118 D(bug("__init_timerbase OpenDevice failed\n"));
124 static void __exit_timerbase(struct StdCIntBase
*StdCBase
)
126 D(bug("__exit_timerbase\n"));
128 if (TimerBase
!= NULL
)
130 CloseDevice((struct IORequest
*)&StdCBase
->timereq
);
135 ADD2EXPUNGELIB(__exit_timerbase
, 0);