mirror of
https://github.com/wiiu-env/wut.git
synced 2024-12-05 02:44:19 +01:00
wutstdc++: Remove link-time dependency on libstdc++
This commit is contained in:
parent
2600a8ada0
commit
6c168606a3
@ -1,11 +1,11 @@
|
|||||||
#include "wut_gthread.h"
|
#include "wut_gthread.h"
|
||||||
|
|
||||||
#include <sys/errno.h>
|
#include <sys/errno.h>
|
||||||
|
#include <sys/time.h>
|
||||||
|
|
||||||
#include <coreinit/alarm.h>
|
#include <coreinit/alarm.h>
|
||||||
#include <coreinit/systeminfo.h>
|
#include <coreinit/systeminfo.h>
|
||||||
#include <coreinit/time.h>
|
#include <coreinit/time.h>
|
||||||
#include <chrono>
|
|
||||||
|
|
||||||
void
|
void
|
||||||
__wut_cond_init_function(OSCondition *cond)
|
__wut_cond_init_function(OSCondition *cond)
|
||||||
@ -58,24 +58,21 @@ __wut_cond_timedwait(OSCondition *cond, OSMutex *mutex,
|
|||||||
data.timed_out = false;
|
data.timed_out = false;
|
||||||
data.cond = cond;
|
data.cond = cond;
|
||||||
|
|
||||||
auto time = std::chrono::system_clock::now();
|
OSTime time = OSGetTime();
|
||||||
auto timeout = std::chrono::system_clock::time_point(
|
OSTime timeout =
|
||||||
std::chrono::seconds(abs_timeout->tv_sec) +
|
OSSecondsToTicks(abs_timeout->tv_sec) +
|
||||||
std::chrono::nanoseconds(abs_timeout->tv_nsec));
|
OSNanosecondsToTicks(abs_timeout->tv_nsec);
|
||||||
|
|
||||||
// Already timed out!
|
// Already timed out!
|
||||||
if (timeout <= time) {
|
if (timeout <= time) {
|
||||||
return ETIMEDOUT;
|
return ETIMEDOUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto duration =
|
|
||||||
std::chrono::duration_cast<std::chrono::nanoseconds>(timeout - time);
|
|
||||||
|
|
||||||
// Set an alarm
|
// Set an alarm
|
||||||
OSAlarm alarm;
|
OSAlarm alarm;
|
||||||
OSCreateAlarm(&alarm);
|
OSCreateAlarm(&alarm);
|
||||||
OSSetAlarmUserData(&alarm, &data);
|
OSSetAlarmUserData(&alarm, &data);
|
||||||
OSSetAlarm(&alarm, OSNanosecondsToTicks(duration.count()),
|
OSSetAlarm(&alarm, timeout - time,
|
||||||
&__wut_cond_timedwait_alarm_callback);
|
&__wut_cond_timedwait_alarm_callback);
|
||||||
|
|
||||||
// Wait on the condition
|
// Wait on the condition
|
||||||
|
Loading…
Reference in New Issue
Block a user