From 6c168606a3ee3a028c03c69c435382385c3495f7 Mon Sep 17 00:00:00 2001 From: fincs Date: Sat, 6 Mar 2021 19:30:34 +0100 Subject: [PATCH] wutstdc++: Remove link-time dependency on libstdc++ --- libraries/wutstdc++/wut_gthread_cond.cpp | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/libraries/wutstdc++/wut_gthread_cond.cpp b/libraries/wutstdc++/wut_gthread_cond.cpp index 26a64a4..e4e2008 100644 --- a/libraries/wutstdc++/wut_gthread_cond.cpp +++ b/libraries/wutstdc++/wut_gthread_cond.cpp @@ -1,11 +1,11 @@ #include "wut_gthread.h" #include +#include #include #include #include -#include 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(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