Commit f3191b94 authored by Yukihiro "Matz" Matsumoto's avatar Yukihiro "Matz" Matsumoto

Merge pull request #555 from masuidrive/define_mrb_int_as_64bit

define MRB_INT64 flag for mrb_int as 64bit
parents ac0233bc 7a20ab0f
...@@ -13,6 +13,9 @@ ...@@ -13,6 +13,9 @@
/* add -DMRB_USE_FLOAT to use float instead of double for floating point numbers */ /* add -DMRB_USE_FLOAT to use float instead of double for floating point numbers */
//#define MRB_USE_FLOAT //#define MRB_USE_FLOAT
/* add -DMRB_INT64 to use 64bit integer for mrb_int */
//#define MRB_INT64
/* represent mrb_value in boxed double; conflict with MRB_USE_FLOAT */ /* represent mrb_value in boxed double; conflict with MRB_USE_FLOAT */
//#define MRB_NAN_BOXING //#define MRB_NAN_BOXING
...@@ -54,27 +57,39 @@ ...@@ -54,27 +57,39 @@
/* end of configuration */ /* end of configuration */
#ifdef MRB_USE_FLOAT #ifdef MRB_USE_FLOAT
typedef float mrb_float; typedef float mrb_float;
#define mrb_float_to_str(buf, i) sprintf((buf), "%.7e", (i)) # define mrb_float_to_str(buf, i) sprintf((buf), "%.7e", (i))
#define str_to_mrb_float(buf) (mrb_float)strtof((buf),NULL) # define str_to_mrb_float(buf) (mrb_float)strtof((buf),NULL)
#else #else
typedef double mrb_float; typedef double mrb_float;
#define mrb_float_to_str(buf, i) sprintf((buf), "%.16e", (i)) # define mrb_float_to_str(buf, i) sprintf((buf), "%.16e", (i))
#define str_to_mrb_float(buf) (mrb_float)strtod((buf),NULL) # define str_to_mrb_float(buf) (mrb_float)strtod((buf),NULL)
#endif #endif
#ifdef MRB_NAN_BOXING #ifdef MRB_NAN_BOXING
typedef int32_t mrb_int; # ifdef MRB_INT64
#define MRB_INT_MIN INT32_MIN # error Cannot use NaN boxing when mrb_int is 64bit
#define MRB_INT_MAX INT32_MAX # else
#define mrb_int_to_str(buf, i) sprintf((buf), "%d", (i)) typedef int32_t mrb_int;
#define str_to_mrb_int(buf) (mrb_int)strtol((buf), NULL, 10); # define MRB_INT_MIN INT32_MIN
# define MRB_INT_MAX INT32_MAX
# define mrb_int_to_str(buf, i) sprintf((buf), "%d", (i))
# define str_to_mrb_int(buf) (mrb_int)strtol((buf), NULL, 10)
# endif
#else #else
typedef int mrb_int; # ifdef MRB_INT64
#define MRB_INT_MIN INT_MIN typedef int64_t mrb_int;
#define MRB_INT_MAX INT_MAX # define MRB_INT_MIN INT64_MIN
#define mrb_int_to_str(buf, i) sprintf((buf), "%d", (i)) # define MRB_INT_MAX INT64_MAX
#define str_to_mrb_int(buf) (mrb_int)strtol((buf), NULL, 10); # define mrb_int_to_str(buf, i) sprintf((buf), "%ld", (i))
# define str_to_mrb_int(buf) (mrb_int)strtoll((buf), NULL, 10)
# else
typedef int mrb_int;
# define MRB_INT_MIN INT_MIN
# define MRB_INT_MAX INT_MAX
# define mrb_int_to_str(buf, i) sprintf((buf), "%d", (i))
# define str_to_mrb_int(buf) (mrb_int)strtol((buf), NULL, 10)
# endif
#endif #endif
typedef short mrb_sym; typedef short mrb_sym;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment