Permalink
Browse files

Merge pull request #29 from MagLev/revert-maglev-ffi

MagLev supports c-extensions now: backout MagLev FFI patch
  • Loading branch information...
2 parents cbe335a + 588c074 commit 46f928a1077e3edb563fa02255f080cb27367536 @tenderlove tenderlove committed Sep 26, 2011
Showing with 1 addition and 62 deletions.
  1. +0 −23 ext/mri/extconf.rb
  2. +1 −5 lib/bcrypt.rb
  3. +0 −34 lib/bcrypt_engine.rb
View
@@ -9,29 +9,6 @@
f.puts "\t@true"
end
exit 0
-elsif defined?(RUBY_ENGINE) && RUBY_ENGINE == "maglev"
- # Maglev doesn't support C extensions, fall back to compiling an FFI usable
- # library
- File.open('Makefile', 'w') do |f|
- f.puts <<-MAKEFILE
-CFLAGS = -fPIC
-OBJS = bcrypt.o blowfish.o
-DLIB = bcrypt_ext.so
-OS ?= $(strip $(shell uname -s | tr '[:upper:]' '[:lower:]'))
-ifeq ($(OS),darwin)
- DLIB = bcrypt_ext.dylib
- CFLAGS += -dynamiclib
-endif
-
-all: $(OBJS)
- cc -shared -o $(DLIB) $(OBJS)
-install:
- install $(DLIB) "../../lib/"
-clean:
- $(RM) $(OBJS) bcrypt_ext.so
- MAKEFILE
- end
- exit 0
else
require "mkmf"
dir_config("bcrypt_ext")
View
@@ -6,11 +6,7 @@
require "openssl"
end
-if defined?(RUBY_ENGINE) and RUBY_ENGINE == "maglev"
- require 'bcrypt_engine'
-else
- require 'bcrypt_ext'
-end
+require 'bcrypt_ext'
# A Ruby library implementing OpenBSD's bcrypt()/crypt_blowfish algorithm for
# hashing passwords.
View
@@ -1,34 +0,0 @@
-require 'ffi'
-
-module BCrypt
- class Engine
- extend FFI::Library
-
- BCRYPT_MAXSALT = 16
- BCRYPT_SALT_OUTPUT_SIZE = 7 + (BCRYPT_MAXSALT * 4 + 2) / 3 + 1
- BCRYPT_OUTPUT_SIZE = 128
-
- ffi_lib File.expand_path("../bcrypt_ext", __FILE__)
-
- attach_function :ruby_bcrypt, [:buffer_out, :string, :string], :string
- attach_function :ruby_bcrypt_gensalt, [:buffer_out, :uint8, :pointer], :string
-
- def self.__bc_salt(cost, seed)
- buffer_out = FFI::Buffer.alloc_out(BCRYPT_SALT_OUTPUT_SIZE, 1)
- seed_ptr = FFI::MemoryPointer.new(:uint8, BCRYPT_MAXSALT)
- seed.bytes.to_a.each_with_index { |b, i| seed_ptr.int8_put(i, b) }
- out = ruby_bcrypt_gensalt(buffer_out, cost, seed_ptr)
- seed_ptr.free
- buffer_out.free
- out || ""
- end
-
- def self.__bc_crypt(key, salt, cost)
- buffer_out = FFI::Buffer.alloc_out(BCRYPT_OUTPUT_SIZE, 1)
- out = ruby_bcrypt(buffer_out, key || "", salt)
- buffer_out.free
- out && out.any? ? out : nil
- end
- end
-end
-

0 comments on commit 46f928a

Please sign in to comment.