@@ -138,7 +138,7 @@ def self.clock_getres(id, unit=:float_second)
138
138
if _res == 0 then
139
139
Errno . handle
140
140
else
141
- _res
141
+ _res
142
142
end
143
143
end
144
144
@@ -150,7 +150,24 @@ def self.clock_getres(id, unit=:float_second)
150
150
end
151
151
152
152
def self . clock_gettime ( id , unit = :float_second )
153
- case id = normalize_clock_id ( id )
153
+ if id . is_a? ( Symbol )
154
+ id = case id
155
+ when :GETTIMEOFDAY_BASED_CLOCK_REALTIME ,
156
+ :TIME_BASED_CLOCK_REALTIME
157
+ CLOCK_REALTIME
158
+ when :MACH_ABSOLUTE_TIME_BASED_CLOCK_MONOTONIC ,
159
+ :TIMES_BASED_CLOCK_MONOTONIC
160
+ CLOCK_MONOTONIC
161
+ when :GETRUSAGE_BASED_CLOCK_PROCESS_CPUTIME_ID ,
162
+ :TIMES_BASED_CLOCK_PROCESS_CPUTIME_ID ,
163
+ :CLOCK_BASED_CLOCK_PROCESS_CPUTIME_ID
164
+ CLOCK_THREAD_CPUTIME_ID
165
+ else
166
+ raise Errno ::EINVAL
167
+ end
168
+ end
169
+
170
+ case id
154
171
when CLOCK_REALTIME
155
172
time = Truffle . invoke_primitive ( :process_time_currenttimemillis ) * 1_000_000
156
173
when CLOCK_MONOTONIC
@@ -163,24 +180,6 @@ def self.clock_gettime(id, unit=:float_second)
163
180
nanoseconds_to_unit ( time , unit )
164
181
end
165
182
166
- def self . normalize_clock_id ( id )
167
- return id unless id . is_a? ( Symbol )
168
- case id
169
- when :GETTIMEOFDAY_BASED_CLOCK_REALTIME ,
170
- :TIME_BASED_CLOCK_REALTIME
171
- CLOCK_REALTIME
172
- when :MACH_ABSOLUTE_TIME_BASED_CLOCK_MONOTONIC ,
173
- :TIMES_BASED_CLOCK_MONOTONIC
174
- CLOCK_MONOTONIC
175
- when :GETRUSAGE_BASED_CLOCK_PROCESS_CPUTIME_ID ,
176
- :TIMES_BASED_CLOCK_PROCESS_CPUTIME_ID ,
177
- :CLOCK_BASED_CLOCK_PROCESS_CPUTIME_ID
178
- CLOCK_THREAD_CPUTIME_ID
179
- else
180
- raise Errno ::EINVAL
181
- end
182
- end
183
-
184
183
def self . nanoseconds_to_unit ( nanoseconds , unit )
185
184
case unit
186
185
when :nanosecond
0 commit comments