Skip to content

Commit 10daf35

Browse files
rework id types for clock_getres
1 parent 9f3c668 commit 10daf35

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

src/main/ruby/core/process.rb

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -116,11 +116,17 @@ def self.time
116116
end
117117

118118
def self.clock_getres(id, unit=:float_second)
119-
case id = normalize_clock_id(id)
120-
when CLOCK_REALTIME
121-
res = 1_000_000
122-
when CLOCK_MONOTONIC
123-
res = 1
119+
res = case id
120+
when :GETTIMEOFDAY_BASED_CLOCK_REALTIME,
121+
:GETRUSAGE_BASED_CLOCK_PROCESS_CPUTIME_ID,
122+
:CLOCK_BASED_CLOCK_PROCESS_CPUTIME_ID
123+
1_000
124+
when :TIME_BASED_CLOCK_REALTIME
125+
1_000_000_000
126+
when :MACH_ABSOLUTE_TIME_BASED_CLOCK_MONOTONIC,
127+
:TIMES_BASED_CLOCK_MONOTONIC
128+
1
129+
when :TIMES_BASED_CLOCK_PROCESS_CPUTIME_ID
124130
else
125131
res = Truffle::POSIX.truffleposix_clock_getres(id)
126132
Errno.handle if res == 0

0 commit comments

Comments
 (0)