Skip to content

Commit

Permalink
Only fix the specifically broken error handling on Crystal::System::T…
Browse files Browse the repository at this point in the history
…ime.monotonic
compumike committed Dec 23, 2024
1 parent de6aaa1 commit 0b89f8d
Showing 2 changed files with 2 additions and 4 deletions.
3 changes: 1 addition & 2 deletions src/crystal/system/unix/pthread_condition_variable.cr
Original file line number Diff line number Diff line change
@@ -42,8 +42,7 @@ class Thread

LibC.pthread_cond_timedwait_relative_np(self, mutex, pointerof(ts))
{% else %}
clock_gettime_ret = LibC.clock_gettime(LibC::CLOCK_MONOTONIC, out ts)
raise RuntimeError.from_errno("clock_gettime(CLOCK_MONOTONIC)") unless clock_gettime_ret == 0
LibC.clock_gettime(LibC::CLOCK_MONOTONIC, out ts)
ts.tv_sec += time.to_i
ts.tv_nsec += time.nanoseconds

3 changes: 1 addition & 2 deletions src/crystal/system/unix/time.cr
Original file line number Diff line number Diff line change
@@ -50,8 +50,7 @@ module Crystal::System::Time
info = mach_timebase_info
LibC.mach_absolute_time &* info.numer // info.denom
{% else %}
ret = LibC.clock_gettime(LibC::CLOCK_MONOTONIC, out tp)
raise RuntimeError.from_errno("clock_gettime(CLOCK_MONOTONIC)") unless ret == 0
LibC.clock_gettime(LibC::CLOCK_MONOTONIC, out tp)
tp.tv_sec.to_u64! &* NANOSECONDS_PER_SECOND &+ tp.tv_nsec.to_u64!
{% end %}
end

0 comments on commit 0b89f8d

Please sign in to comment.