2 Copyright © 1995-2013, The AROS Development Team. All rights reserved.
5 Return the current time in seconds.
8 #include <proto/exec.h>
10 #define __NOBLIBBASE__
12 #include <proto/timer.h>
16 #include "__stdc_intbase.h"
19 #include <aros/debug.h>
21 static int __init_timerbase(struct StdCIntBase
*StdCBase
);
22 #define TimerBase StdCBase->StdCTimerBase
24 /*****************************************************************************
35 time() returns the time since 00:00:00 GMT, January 1, 1970,
39 tloc - If this pointer is non-NULL, then the time is written into
40 this variable as well.
43 The number of seconds.
46 This function must not be used in a shared library or
47 in a threaded application.
52 // tt1 and tt2 are the same
61 ctime(), asctime(), localtime()
65 ******************************************************************************/
67 struct StdCIntBase
*StdCBase
= (struct StdCIntBase
*)__aros_getbase_StdCBase();
70 /* We get TimerBase here and not during LIBINIT because timer.device is not available
71 when stdc.library is initialized.
73 if (TimerBase
== NULL
)
74 __init_timerbase(StdCBase
);
75 if (TimerBase
== NULL
)
82 tv
.tv_sec
+= 2922 * 1440 * 60;
84 tv
.tv_sec
+= __stdc_gmtoffset() * 60;
92 static int __init_timerbase(struct StdCIntBase
*StdCBase
)
94 D(bug("__init_timerbase\n"));
96 memset( &StdCBase
->timeport
, 0, sizeof( StdCBase
->timeport
) );
97 StdCBase
->timeport
.mp_Node
.ln_Type
= NT_MSGPORT
;
98 StdCBase
->timeport
.mp_Flags
= PA_IGNORE
;
99 StdCBase
->timeport
.mp_SigTask
= FindTask(NULL
);
100 NEWLIST(&StdCBase
->timeport
.mp_MsgList
);
102 StdCBase
->timereq
.tr_node
.io_Message
.mn_Node
.ln_Type
= NT_MESSAGE
;
103 StdCBase
->timereq
.tr_node
.io_Message
.mn_Node
.ln_Pri
= 0;
104 StdCBase
->timereq
.tr_node
.io_Message
.mn_Node
.ln_Name
= NULL
;
105 StdCBase
->timereq
.tr_node
.io_Message
.mn_ReplyPort
= &StdCBase
->timeport
;
106 StdCBase
->timereq
.tr_node
.io_Message
.mn_Length
= sizeof (StdCBase
->timereq
);
109 "timer.device", UNIT_VBLANK
,
110 (struct IORequest
*)&StdCBase
->timereq
, 0
114 TimerBase
= (struct Device
*)StdCBase
->timereq
.tr_node
.io_Device
;
115 D(bug("__init_timerbase TimerBase=%x\n", TimerBase
));
120 D(bug("__init_timerbase OpenDevice failed\n"));
126 static void __exit_timerbase(struct StdCIntBase
*StdCBase
)
128 D(bug("__exit_timerbase\n"));
130 if (TimerBase
!= NULL
)
132 CloseDevice((struct IORequest
*)&StdCBase
->timereq
);
137 ADD2EXPUNGELIB(__exit_timerbase
, 0);