Ruby source code assumptions¶
Ruby's source code is written assuming the following. It is considered to be extremely difficult to port to an environment not satisfying (any of) them.
- Your C compiler complies ISO/IEC 9899:1999 at least for features in "Known supported features" of https://bugs.ruby-lang.org/projects/ruby-trunk/wiki/C99.
- The "execution character set" of your C environment (cf: the standard) must be ASCII, not something like EBCDIC.
- Your compiler should not limit user (re-)definitions of identifiers listed in the C standard library.
- (If you choose to opt-in instruction unification feature of the VM) Your C compiler must accept
switchstatement with more than 256 branches.
- Your C compiler must accept string literals of at least 7,000 characters.
charmust either be identical to
signed charor identical to
unsigned charand nothing else.
charmust be 8 bits long. There are a lot of places where 8 appear as magic numbers.
intmust be 32 bits long.
longmust either be 32 bits long or 64 bits long.
Fixnum's width is that of
long, not that of pointers. This is true even when
longis smaller than
time_tmust be an integer type (but signedness might vary).
- Unsigned 32 bits integer is required for character handlings due to due to GB18030. Signed 32 bits is insufficient.
- There must either be
intptr_t, or an integer type that can be casted from/to
void *without loss.
- Although the standard says
enumis a signed int, there are parts in the source code where
longare assumed convertible without loss.
sizeof(size_t) == sizeof(void*)holds.
sizeof(VALUE) == sizeof(void*)holds.
Pointers / Memories¶
_int64) must be convertible with pointers.
void *must exist.
- Function pointers and
void *must be convertible without loss.
- Arbitrary function pointers must be convertible via cast to each other and can be called via casting.
- Machine stack must exist; that is, automatic variables should be arranged in a high-order or low-order specific position of some memory address, not distributed.
- Least significant 2 bits of pointer type values must always be 0.
Floating point number¶
- Infinity and NaN must exist somewhere in the