Skip to content
  • dearblue's avatar
    42513d61
    Need to place static proc objects into 8-byte alignments · 42513d61
    dearblue authored
    Static proc objects defined as methods may be placed in 4-byte alignments in 32-bit environments.
    This may be misinterpreted as an immediate value depending on the address.
    
    Since C11 and C++11 have additional language features for byte alignment, corresponding compilers use them to define the `mrb_alignas()` macro.
    For earlier compilers, they use their own extensions to define the `mrb_alignas()` macro.
    
    GCC supports `__attribute__((aligned(alignment)))` since at least version 2.95.3 (1999).
    https://gcc.gnu.org/onlinedocs/gcc-2.95.3/gcc_4.html#IDX305
    According to GPT-4, support was added in version 2.7 (1995).
    
    It is not known which version of Visual C++ added support for `__declspec(align(n))`.
    According to GPT-4, at least Visual C++ 6.0 (1998) seems to support it.
    Also, the documentation of past Intel C/C++ compilers that support `__declspec(align(n))` makes reference to support with Visual C++ 4.2 (1996).
    https://www.intel.com/content/dam/www/public/ijkk/jp/ja/documents/developer/ccomp40j.pdf
    42513d61
    Need to place static proc objects into 8-byte alignments
    dearblue authored
    Static proc objects defined as methods may be placed in 4-byte alignments in 32-bit environments.
    This may be misinterpreted as an immediate value depending on the address.
    
    Since C11 and C++11 have additional language features for byte alignment, corresponding compilers use them to define the `mrb_alignas()` macro.
    For earlier compilers, they use their own extensions to define the `mrb_alignas()` macro.
    
    GCC supports `__attribute__((aligned(alignment)))` since at least version 2.95.3 (1999).
    https://gcc.gnu.org/onlinedocs/gcc-2.95.3/gcc_4.html#IDX305
    According to GPT-4, support was added in version 2.7 (1995).
    
    It is not known which version of Visual C++ added support for `__declspec(align(n))`.
    According to GPT-4, at least Visual C++ 6.0 (1998) seems to support it.
    Also, the documentation of past Intel C/C++ compilers that support `__declspec(align(n))` makes reference to support with Visual C++ 4.2 (1996).
    https://www.intel.com/content/dam/www/public/ijkk/jp/ja/documents/developer/ccomp40j.pdf
Loading