1 |
|
/* |
2 |
|
* timer_beos.cpp - Time Manager emulation, BeOS specific stuff |
3 |
|
* |
4 |
< |
* Basilisk II (C) 1997-1999 Christian Bauer |
4 |
> |
* Basilisk II (C) 1997-2008 Christian Bauer |
5 |
|
* |
6 |
|
* This program is free software; you can redistribute it and/or modify |
7 |
|
* it under the terms of the GNU General Public License as published by |
21 |
|
#include <KernelKit.h> |
22 |
|
|
23 |
|
#include "sysdeps.h" |
24 |
+ |
#include "macos_util.h" |
25 |
|
#include "timer.h" |
26 |
|
|
27 |
|
#define DEBUG 0 |
28 |
|
#include "debug.h" |
29 |
|
|
30 |
|
|
31 |
+ |
// From main_beos.cpp |
32 |
+ |
extern thread_id emul_thread; |
33 |
+ |
|
34 |
+ |
|
35 |
|
/* |
36 |
|
* Return microseconds since boot (64 bit) |
37 |
|
*/ |
49 |
|
* Return local date/time in Mac format (seconds since 1.1.1904) |
50 |
|
*/ |
51 |
|
|
47 |
– |
const uint32 TIME_OFFSET = 0x7c25cca0; // Offset Mac->BeOS time in seconds |
48 |
– |
|
52 |
|
uint32 TimerDateTime(void) |
53 |
|
{ |
54 |
< |
time_t uct_now = time(NULL); |
52 |
< |
struct tm tm; |
53 |
< |
localtime_r(&uct_now, &tm); |
54 |
< |
time_t local_now = mktime(&tm); |
55 |
< |
return (uint32)local_now + TIME_OFFSET; |
54 |
> |
return TimeToMacTime(time(NULL)); |
55 |
|
} |
56 |
|
|
57 |
|
|
124 |
|
else |
125 |
|
return -hosttime; // Time in negative microseconds |
126 |
|
} |
127 |
+ |
|
128 |
+ |
|
129 |
+ |
/* |
130 |
+ |
* Delay by specified number of microseconds (<1 second) |
131 |
+ |
*/ |
132 |
+ |
|
133 |
+ |
void Delay_usec(uint32 usec) |
134 |
+ |
{ |
135 |
+ |
snooze(usec); |
136 |
+ |
} |
137 |
+ |
|
138 |
+ |
|
139 |
+ |
/* |
140 |
+ |
* Suspend emulator thread, virtual CPU in idle mode |
141 |
+ |
*/ |
142 |
+ |
|
143 |
+ |
void idle_wait(void) |
144 |
+ |
{ |
145 |
+ |
#if 0 |
146 |
+ |
/* |
147 |
+ |
FIXME: add a semaphore (counter) to avoid a B_BAD_THREAD_STATE |
148 |
+ |
return if we call idle_resume() when thread is not suspended? |
149 |
+ |
|
150 |
+ |
Sorry, I can't test -- gb. |
151 |
+ |
*/ |
152 |
+ |
suspend_thread(emul_thread); |
153 |
+ |
#endif |
154 |
+ |
} |
155 |
+ |
|
156 |
+ |
|
157 |
+ |
/* |
158 |
+ |
* Resume execution of emulator thread, events just arrived |
159 |
+ |
*/ |
160 |
+ |
|
161 |
+ |
void idle_resume(void) |
162 |
+ |
{ |
163 |
+ |
#if 0 |
164 |
+ |
resume_thread(emul_thread); |
165 |
+ |
#endif |
166 |
+ |
} |