Project

General

Profile

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.

The Language

  • Your C compiler must comply ISO/IEC 9899:1990.
  • 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.

Types

  • char must either be identical to signed char or identical to unsigned 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 of long, not that of pointers. This is true even when long is smaller than VALUE.
  • 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/to void * without loss.
  • Although the standard says enum is a signed int, there are parts in the source code where enum and long are assumed convertible without loss.

Pointers / Memories

  • Either long or long 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.

Floating point number

  • Infinity and NaN must exist somewhere in the double type.