- Notifications
You must be signed in to change notification settings - Fork5.4k
Assumptions
Jemma Issroff edited this pageMay 30, 2023 ·2 revisions
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" ofhttps://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
switch
statement with more than 256 branches. - Your C compiler must accept string literals of at least 7,000 characters.
char
must either be identical tosigned char
or identical tounsigned char
and nothing else.char
must be 8 bits long. There are a lot of places where 8 appear as magic numbers.int
must be 32 bits long.long
must either be 32 bits long or 64 bits long.Fixnum
's width is that oflong
, not that of pointers. This is true even whenlong
is smaller thanVALUE
.time_t
must 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/tovoid *
without loss. - Although the standard says
enum
is a signed int, there are parts in the source code whereenum
andlong
are assumed convertible without loss. sizeof(size_t) == sizeof(void*)
holds.sizeof(VALUE) == sizeof(void*)
holds.
- Either
long
orlong long
(_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.
- Infinity and NaN must exist somewhere in the
double
type.