summaryrefslogtreecommitdiff
path: root/ext/bigdecimal
diff options
context:
space:
mode:
authorKenta Murata <mrkn@mrkn.jp>2020-12-29 17:14:36 +0900
committerKenta Murata <mrkn@mrkn.jp>2020-12-29 17:46:37 +0900
commit47a1f5ff738c5f14f4ffd7def3536b61ce1f9ff0 (patch)
treeb36eaf73b81fea138ba92aa362807715cd64ee42 /ext/bigdecimal
parent29d012c9641fa53464a03cc682b6a0f5bf7888df (diff)
[ruby/bigdecimal] Define bool, true, and false for old Ruby
https://github.com/ruby/bigdecimal/commit/a6d3bd2d44
Diffstat (limited to 'ext/bigdecimal')
-rw-r--r--ext/bigdecimal/bigdecimal.h14
-rw-r--r--ext/bigdecimal/extconf.rb2
2 files changed, 16 insertions, 0 deletions
diff --git a/ext/bigdecimal/bigdecimal.h b/ext/bigdecimal/bigdecimal.h
index 28f3363..c89f212 100644
--- a/ext/bigdecimal/bigdecimal.h
+++ b/ext/bigdecimal/bigdecimal.h
@@ -14,6 +14,20 @@
#include "ruby/ruby.h"
#include <float.h>
+#if defined(__bool_true_false_are_defined)
+# /* Take that. */
+
+#elif defined(HAVE_STDBOOL_H)
+# include <stdbool.h>
+
+#else
+typedef unsigned char _Bool;
+# define bool _Bool
+# define true ((_Bool)+1)
+# define false ((_Bool)-1)
+# define __bool_true_false_are_defined
+#endif
+
#ifndef RB_UNUSED_VAR
# ifdef __GNUC__
# define RB_UNUSED_VAR(x) x __attribute__ ((unused))
diff --git a/ext/bigdecimal/extconf.rb b/ext/bigdecimal/extconf.rb
index 63123e2..41b8df8 100644
--- a/ext/bigdecimal/extconf.rb
+++ b/ext/bigdecimal/extconf.rb
@@ -28,6 +28,8 @@ end
check_bigdecimal_version(gemspec_path)
+have_header("stdbool.h")
+
have_func("labs", "stdlib.h")
have_func("llabs", "stdlib.h")
have_func("finite", "math.h")