summaryrefslogtreecommitdiff
path: root/ext/bigdecimal/util
diff options
context:
space:
mode:
authormrkn <mrkn@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-12-02 05:21:54 +0000
committermrkn <mrkn@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-12-02 05:21:54 +0000
commita0e438cd3c28d2eaf4efa18243d5b6edafa14d88 (patch)
treec8a0e8d7a8553034c2cc4957890ea48ad7277693 /ext/bigdecimal/util
parent096d362939816b569b22ed3de87c06277ef4c3fb (diff)
Import bigdecimal-1.4.0.pre-20181130a
* https://github.com/ruby/bigdecimal/compare/74d25ef..v1.4.0.pre.20181130a git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66124 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/bigdecimal/util')
-rw-r--r--ext/bigdecimal/util/extconf.rb40
-rw-r--r--ext/bigdecimal/util/util.c9
2 files changed, 49 insertions, 0 deletions
diff --git a/ext/bigdecimal/util/extconf.rb b/ext/bigdecimal/util/extconf.rb
new file mode 100644
index 00000000000..023b19ba7ea
--- /dev/null
+++ b/ext/bigdecimal/util/extconf.rb
@@ -0,0 +1,40 @@
+# frozen_string_literal: false
+require 'mkmf'
+
+def windows_platform?
+ /cygwin|mingw|mswin/ === RUBY_PLATFORM
+end
+
+if windows_platform?
+ library_base_name = "ruby-bigdecimal"
+ case RUBY_PLATFORM
+ when /cygwin|mingw/
+ import_library_name = "libruby-bigdecimal.a"
+ when /mswin/
+ import_library_name = "bigdecimal-$(arch).lib"
+ end
+end
+
+checking_for(checking_message("Windows")) do
+ if windows_platform?
+ if defined?($extlist)
+ build_dir = "$(TARGET_SO_DIR)../"
+ else
+ base_dir = File.expand_path('../../../..', __FILE__)
+ build_dir = File.join(base_dir, "tmp", RUBY_PLATFORM, "bigdecimal", RUBY_VERSION)
+ end
+ case RUBY_PLATFORM
+ when /cygwin|mingw/
+ $LDFLAGS << " -L#{build_dir} -L.. -L .."
+ $libs << " -l#{library_base_name}"
+ when /mswin/
+ $DLDFLAGS << " /libpath:#{build_dir} /libpath:.."
+ $libs << " #{import_library_name}"
+ end
+ true
+ else
+ false
+ end
+end
+
+create_makefile('bigdecimal/util')
diff --git a/ext/bigdecimal/util/util.c b/ext/bigdecimal/util/util.c
new file mode 100644
index 00000000000..8d38d87852d
--- /dev/null
+++ b/ext/bigdecimal/util/util.c
@@ -0,0 +1,9 @@
+#include "ruby.h"
+
+RUBY_EXTERN VALUE rmpd_util_str_to_d(VALUE str);
+
+void
+Init_util(void)
+{
+ rb_define_method(rb_cString, "to_d", rmpd_util_str_to_d, 0);
+}