Commit 636ac4de
636ac4de0853Merged
Yukihiro "Matz" Matsumoto <[email protected]> · 6 months ago · 7 files · +4 added · ~3 modified
Description
codegen,runtime: RUBY_VERSION/PLATFORM/ENGINE + Process.pid/ppid
Four built-in identifiers that used to fall through to warn_unresolved_const / warn_unresolved_call (emitting 0):
RUBY_VERSION -> "4.0.0" (string literal) RUBY_ENGINE -> "spinel" RUBY_PLATFORM -> sp_ruby_platform_str() -- detected at C compile time from x86_64/aarch64/linux/etc. macros so cross-builds report the target. Process.pid -> getpid() (unistd.h already included) Process.ppid -> getppid()
Refs #890 #893
Co-Authored-By: Claude Opus 4.7 [email protected]
Details
- Commit
- 636ac4de0853
- Parent
- d55c86b47ed4
lib/sp_runtime.hmodifiedView file
@@ -362,6 +362,33 @@
362362
static const char sp_str_empty_data[] = "\xff";363363
#define sp_str_empty (sp_str_empty_data + 1)364364
365+
/* RUBY_PLATFORM string -- host arch + OS. Detected at C compile time366+
so cross-builds report the target platform. Issue #890. */367+
#if defined(__x86_64__) || defined(_M_X64)368+
# define SP_RUBY_ARCH "x86_64"369+
#elif defined(__aarch64__) || defined(_M_ARM64)370+
# define SP_RUBY_ARCH "aarch64"371+
#elif defined(__i386__) || defined(_M_IX86)372+
# define SP_RUBY_ARCH "i686"373+
#elif defined(__arm__)374+
# define SP_RUBY_ARCH "arm"375+
#else376+
# define SP_RUBY_ARCH "unknown"377+
#endif378+
#if defined(__linux__)379+
# define SP_RUBY_OS "linux"380+
#elif defined(__APPLE__)381+
# define SP_RUBY_OS "darwin"382+
#elif defined(_WIN32) || defined(_WIN64)383+
# define SP_RUBY_OS "mingw32"384+
#elif defined(__FreeBSD__)385+
# define SP_RUBY_OS "freebsd"386+
#else387+
# define SP_RUBY_OS "unknown"388+
#endif389+
static const char sp_ruby_platform_data[] = "\xff" SP_RUBY_ARCH "-" SP_RUBY_OS;390+
static inline const char *sp_ruby_platform_str(void) { return sp_ruby_platform_data + 1; }391+
365392
static void sp_oom_die(void);366393
static char *sp_str_alloc(size_t len) {367394
size_t total = sizeof(sp_str_hdr) + 1 + len + 1;spinel_analyze.rbmodifiedView file
Loading diff…
spinel_codegen.rbmodifiedView file
Loading diff…
test/process_pid.rbaddedView file
Loading diff…
test/process_pid.rb.expectedaddedView file
Loading diff…
test/ruby_version_constants.rbaddedView file
Loading diff…
test/ruby_version_constants.rb.expectedaddedView file
Loading diff…