Commit 649380a2
649380a20848Merged
Yusuke Endoh <[email protected]> · 6 months ago · 2 files · +1 added · ~1 modified
Description
feat(codegen): Process.clock_gettime
Process.clock_gettime(Process::CLOCK_MONOTONIC) lowers to a
GCC statement-expression wrapping the libc clock_gettime call,
returning seconds as an mrb_float. The clock_id argument is not
modeled — CLOCK_MONOTONIC is assumed.
infer_call_type's constant-recv branch reports float so
callers see the right type at compile time.
Co-Authored-By: Claude Opus 4.7 (1M context) [email protected]
Details
- Commit
- 649380a20848
- Parent
- c64c82b343ed
spinel_codegen.rbmodifiedView file
@@ -3143,6 +3143,11 @@
31433143
if recv >= 031443144
if @nd_type[recv] == "ConstantReadNode"31453145
rcname = @nd_name[recv]3146+
if rcname == "Process"3147+
if mname == "clock_gettime"3148+
return "float"3149+
end3150+
end31463151
if rcname == "File"31473152
if mname == "read"31483153
return "string"@@ -18574,6 +18579,13 @@
1857418579
return "((mrb_int)time(NULL))"1857518580
end1857618581
end18582+
# Process.clock_gettime — assume CLOCK_MONOTONIC; the clock_id18583+
# arg is not modeled. Returns seconds as a float.18584+
if rcname == "Process"18585+
if mname == "clock_gettime"18586+
return "({ struct timespec _ts; clock_gettime(CLOCK_MONOTONIC, &_ts); (mrb_float)_ts.tv_sec + (mrb_float)_ts.tv_nsec / 1e9; })"18587+
end18588+
end1857718589
# ENV1857818590
if rcname == "ENV"1857918591
if mname == "[]"test/process_clock_gettime.rbaddedView file
Loading diff…