Commit 0ca54a31
0ca54a313a97Merged
Yukihiro "Matz" Matsumoto <[email protected]> · 6 months ago · 8 files · +4 added · ~4 modified
Description
runtime: split sp_Time into libspinel_rt + Time.mktime/local/utc dispatch
Move the bulk of the Time implementation (~250 lines of libc-backed accessors, formatters, and arithmetic) from the static-inline sp_runtime.h block into lib/sp_time.{c,h}, compiled into libspinel_rt.a alongside sp_bigint / sp_crypto / sp_pack / sp_strscan. sp_runtime.h keeps only the GC-aware trampolines (sp_box_time and the *_gc string forwarders that sp_str_dup_external into the GC string heap).
The format helpers in libspinel_rt write into a caller-provided buffer; the GC-aware wrappers allocate a small stack buf, call the helper, then sp_str_dup_external the result. This keeps libspinel_rt zero-dependency on the runtime's static-inline helpers.
sp_time.h uses int64_t / double directly rather than mrb_int / mrb_float because sp_runtime.h and mruby_shim.h disagree on the mrb_bool typedef (bool vs int) — including either from sp_time.h would tip the conflict at every TU that consumes both.
Time.mktime / Time.local / Time.utc / Time.gm are now dispatched (aliases of Time.new in the local case; the UTC pair uses a new sp_time_new_utc that builds the epoch via days-from-civil so the value is timezone-independent — timegm is absent on MSVCRT).
Fixes #993
Co-Authored-By: Claude Opus 4.7 [email protected]
Details
- Commit
- 0ca54a313a97
- Parent
- 5baef77b8fb8
MakefilemodifiedView file
@mkdir -p build $(CC) -c -O2 -Wno-all $(SEC_FLAGS) -Ilib -Ilib/regexp lib/sp_strscan.c -o build/sp_strscan.obuild/sp_time.o: lib/sp_time.c lib/sp_time.h @mkdir -p build $(CC) -c -O2 -Wno-all $(SEC_FLAGS) -Ilib lib/sp_time.c -o build/sp_time.oSP_RT_LIB = lib/libspinel_rt.a$(SP_RT_LIB): $(RE_OBJ) build/sp_bigint.o build/sp_crypto.o build/sp_pack.o build/sp_strscan.o$(SP_RT_LIB): $(RE_OBJ) build/sp_bigint.o build/sp_crypto.o build/sp_pack.o build/sp_strscan.o build/sp_time.o ar rcs $@ $^regexp: $(SP_RT_LIB)lib/sp_runtime.hmodifiedView file
Loading diff…
lib/sp_time.caddedView file
Loading diff…
lib/sp_time.haddedView file
Loading diff…
spinel_analyze.rbmodifiedView file
Loading diff…
spinel_codegen.rbmodifiedView file
Loading diff…
test/time_mktime_local_utc.rbaddedView file
Loading diff…
test/time_mktime_local_utc.rb.expectedaddedView file
Loading diff…