summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2018-12-22 22:47:03 +0900
committerGitHub <[email protected]>2018-12-22 22:47:03 +0900
commit30dae4742bc2cb284549413a1c104d3c50f84ce7 (patch)
treeb99371c524bd6e90d9d00b5f9196409bf4f21001
parent281d0ff4ea3660917c015bd3728f19064931c7b2 (diff)
parentb7a832bf4f20f9e0a82607fa3e313a333f9aecd8 (diff)
downloadmruby-30dae4742bc2cb284549413a1c104d3c50f84ce7.tar.gz
mruby-30dae4742bc2cb284549413a1c104d3c50f84ce7.zip
Merge pull request #4195 from dearblue/fix-byteorder
Fix byte order
-rw-r--r--include/mrbconf.h3
-rw-r--r--mrbgems/mruby-pack/src/pack.c10
2 files changed, 12 insertions, 1 deletions
diff --git a/include/mrbconf.h b/include/mrbconf.h
index 9bdd11af6..b1aec8334 100644
--- a/include/mrbconf.h
+++ b/include/mrbconf.h
@@ -60,7 +60,8 @@
/* define on big endian machines; used by MRB_NAN_BOXING, etc. */
#ifndef MRB_ENDIAN_BIG
-# if BYTE_ORDER == BIG_ENDIAN
+# if (defined(BYTE_ORDER) && defined(BIG_ENDIAN) && BYTE_ORDER == BIG_ENDIAN) || \
+ (defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)
# define MRB_ENDIAN_BIG
# endif
#endif
diff --git a/mrbgems/mruby-pack/src/pack.c b/mrbgems/mruby-pack/src/pack.c
index 1b1f86a88..f274ff11e 100644
--- a/mrbgems/mruby-pack/src/pack.c
+++ b/mrbgems/mruby-pack/src/pack.c
@@ -64,6 +64,16 @@ const static unsigned char base64chars[] =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
static unsigned char base64_dec_tab[128];
+#if !defined(BYTE_ORDER) && defined(__BYTE_ORDER__)
+# define BYTE_ORDER __BYTE_ORDER__
+#endif
+#if !defined(BIG_ENDIAN) && defined(__ORDER_BIG_ENDIAN__)
+# define BIG_ENDIAN __ORDER_BIG_ENDIAN__
+#endif
+#if !defined(LITTLE_ENDIAN) && defined(__ORDER_LITTLE_ENDIAN__)
+# define LITTLE_ENDIAN __ORDER_LITTLE_ENDIAN__
+#endif
+
#ifdef BYTE_ORDER
# if BYTE_ORDER == BIG_ENDIAN
# define littleendian 0