mirror of
https://github.com/wiiu-env/wut.git
synced 2024-12-04 19:44:16 +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 <sys/errno.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
#include <coreinit/alarm.h>
|
||||
#include <coreinit/systeminfo.h>
|
||||
#include <coreinit/time.h>
|
||||
#include <chrono>
|
||||
|
||||
void
|
||||
__wut_cond_init_function(OSCondition *cond)
|
||||
@ -58,24 +58,21 @@ __wut_cond_timedwait(OSCondition *cond, OSMutex *mutex,
|
||||
data.timed_out = false;
|
||||
data.cond = cond;
|
||||
|
||||
auto time = std::chrono::system_clock::now();
|
||||
auto timeout = std::chrono::system_clock::time_point(
|
||||
std::chrono::seconds(abs_timeout->tv_sec) +
|
||||
std::chrono::nanoseconds(abs_timeout->tv_nsec));
|
||||
OSTime time = OSGetTime();
|
||||
OSTime timeout =
|
||||
OSSecondsToTicks(abs_timeout->tv_sec) +
|
||||
OSNanosecondsToTicks(abs_timeout->tv_nsec);
|
||||
|
||||
// Already timed out!
|
||||
if (timeout <= time) {
|
||||
return ETIMEDOUT;
|
||||
}
|
||||
|
||||
auto duration =
|
||||
std::chrono::duration_cast<std::chrono::nanoseconds>(timeout - time);
|
||||
|
||||
// Set an alarm
|
||||
OSAlarm alarm;
|
||||
OSCreateAlarm(&alarm);
|
||||
OSSetAlarmUserData(&alarm, &data);
|
||||
OSSetAlarm(&alarm, OSNanosecondsToTicks(duration.count()),
|
||||
OSSetAlarm(&alarm, timeout - time,
|
||||
&__wut_cond_timedwait_alarm_callback);
|
||||
|
||||
// Wait on the condition
|
||||
|
Loading…
Reference in New Issue
Block a user