summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2014-11-04 07:10:41 +0900
committerYukihiro "Matz" Matsumoto <[email protected]>2014-11-04 07:10:41 +0900
commit0e40468809eddddfed4c7ae02de1ea4be8e7218e (patch)
treec8d285b027022777f0e3f646de0c5666468fd7d0
parentbe844f9284c692355189165a7a2fc19ecaebb1f6 (diff)
downloadmruby-0e40468809eddddfed4c7ae02de1ea4be8e7218e.tar.gz
mruby-0e40468809eddddfed4c7ae02de1ea4be8e7218e.zip
specify alignment specifier for GCC and MSC; ref #2630
-rw-r--r--src/dump.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/dump.c b/src/dump.c
index ea19bee60..67dd82e43 100644
--- a/src/dump.c
+++ b/src/dump.c
@@ -1032,7 +1032,15 @@ mrb_dump_irep_cfunc(mrb_state *mrb, mrb_irep *irep, int debug_info, FILE *fp, co
mrb_free(mrb, bin);
return MRB_DUMP_WRITE_FAULT;
}
- if (fprintf(fp, "const uint8_t %s[] = {", initname) < 0) {
+ if (fprintf(fp,
+ "const uint8_t\n"
+ "#if defined __GNUC__\n"
+ "__attribute__((aligned(%zu)))\n"
+ "#elif defined _MSC_VER\n"
+ "__declspec(align(%zu))\n"
+ "#endif\n"
+ "%s[] = {",
+ MRB_DUMP_ALIGNMENT, MRB_DUMP_ALIGNMENT, initname) < 0) {
mrb_free(mrb, bin);
return MRB_DUMP_WRITE_FAULT;
}