* ext/dl/lib/dl/import.rb (handler): add a more helpful error message
when calling import_symbol or import_function without calling dlload. Thanks nobu! [ruby-core:30996] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28552 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
c27e0ebab6
commit
ff10d93563
@ -1,3 +1,9 @@
|
|||||||
|
Tue Jul 6 08:35:58 2010 Aaron Patterson <aaron@tenderlovemaking.com>
|
||||||
|
|
||||||
|
* ext/dl/lib/dl/import.rb (handler): add a more helpful error message
|
||||||
|
when calling import_symbol or import_function without calling
|
||||||
|
dlload. Thanks nobu! [ruby-core:30996]
|
||||||
|
|
||||||
Tue Jul 6 00:34:50 2010 Yusuke Endoh <mame@tsg.ne.jp>
|
Tue Jul 6 00:34:50 2010 Yusuke Endoh <mame@tsg.ne.jp>
|
||||||
|
|
||||||
* vm.c (thread_free): free altstack to prevent memory leak. a patch
|
* vm.c (thread_free): free altstack to prevent memory leak. a patch
|
||||||
|
@ -194,8 +194,12 @@ module DL
|
|||||||
return ptr
|
return ptr
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def handler
|
||||||
|
@handler or raise "call dlload before importing symbols and functions"
|
||||||
|
end
|
||||||
|
|
||||||
def import_symbol(name)
|
def import_symbol(name)
|
||||||
addr = @handler.sym(name)
|
addr = handler.sym(name)
|
||||||
if( !addr )
|
if( !addr )
|
||||||
raise(DLError, "cannot find the symbol: #{name}")
|
raise(DLError, "cannot find the symbol: #{name}")
|
||||||
end
|
end
|
||||||
@ -203,7 +207,7 @@ module DL
|
|||||||
end
|
end
|
||||||
|
|
||||||
def import_function(name, ctype, argtype, call_type = nil)
|
def import_function(name, ctype, argtype, call_type = nil)
|
||||||
addr = @handler.sym(name)
|
addr = handler.sym(name)
|
||||||
if( !addr )
|
if( !addr )
|
||||||
raise(DLError, "cannot find the function: #{name}()")
|
raise(DLError, "cannot find the function: #{name}()")
|
||||||
end
|
end
|
||||||
|
@ -41,6 +41,15 @@ module DL
|
|||||||
end
|
end
|
||||||
|
|
||||||
class TestImport < TestBase
|
class TestImport < TestBase
|
||||||
|
def test_ensure_call_dlload
|
||||||
|
err = assert_raises(RuntimeError) do
|
||||||
|
Class.new do
|
||||||
|
extend DL::Importer
|
||||||
|
extern "void *strcpy(char*, char*)"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def test_malloc()
|
def test_malloc()
|
||||||
s1 = LIBC::Timeval.malloc()
|
s1 = LIBC::Timeval.malloc()
|
||||||
s2 = LIBC::Timeval.malloc()
|
s2 = LIBC::Timeval.malloc()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user