Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions include/mruby/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,26 @@ MRB_BEGIN_DECL
# define mrb_deprecated
#endif

/** Declare a type or object as an alignment requirement. */
#ifndef mrb_alignas
# if defined(__cplusplus) && __cplusplus >= 201103L
# // https://en.cppreference.com/w/cpp/language/alignas
# define mrb_alignas(n) alignas(n)
# elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L
# // https://en.cppreference.com/w/c/language/_Alignas
# define mrb_alignas(n) _Alignas(n)
# elif defined(_MSC_VER) || defined(__INTEL_COMPILER)
# // https://learn.microsoft.com/en-us/cpp/cpp/align-cpp?view=msvc-170
# define mrb_alignas(n) __declspec(align(n))
# elif defined(__GNUC__) || defined(__clang__)
# // https://gcc.gnu.org/onlinedocs/gcc/Common-Type-Attributes.html#index-aligned-type-attribute
# define mrb_alignas(n) __attribute__((aligned(n)))
# else
# // `mrb_alignas` defined as dummy. If necessary, send issues to https://github.com/mruby/mruby .
# define mrb_alignas(n)
# endif
#endif

/** Declare a function as always inlined. */
#if defined _MSC_VER && _MSC_VER < 1900
# ifndef __cplusplus
Expand Down
1 change: 1 addition & 0 deletions mrbgems/mruby-catch/src/catch.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ static const mrb_irep catch_irep = {
NULL,
sizeof(catch_iseq),0,3,0,0
};
mrb_alignas(8)
static const struct RProc catch_proc = {
NULL, NULL, MRB_TT_PROC, MRB_GC_RED, MRB_FL_OBJ_IS_FROZEN | MRB_PROC_SCOPE | MRB_PROC_STRICT,
{ &catch_irep }, NULL, { NULL }
Expand Down
1 change: 1 addition & 0 deletions src/class.c
Original file line number Diff line number Diff line change
Expand Up @@ -2915,6 +2915,7 @@ static const mrb_irep new_irep = {
sizeof(new_iseq), 0, 2, 0, 0,
};

mrb_alignas(8)
static const struct RProc new_proc = {
NULL, NULL, MRB_TT_PROC, MRB_GC_RED, MRB_FL_OBJ_IS_FROZEN | MRB_PROC_SCOPE | MRB_PROC_STRICT,
{ &new_irep }, NULL, { NULL }
Expand Down
1 change: 1 addition & 0 deletions src/proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ static const mrb_irep call_irep = {
0, /* refcnt */
};

mrb_alignas(8)
static const struct RProc call_proc = {
NULL, NULL, MRB_TT_PROC, MRB_GC_RED, MRB_FL_OBJ_IS_FROZEN | MRB_PROC_SCOPE | MRB_PROC_STRICT,
{ &call_irep }, NULL, { NULL }
Expand Down