Bug #11579 ยป fix-fiddle-win32_last_error.diff
ext/fiddle/function.c | ||
---|---|---|
rb_funcall(mFiddle, rb_intern("last_error="), 1, INT2NUM(errno));
|
||
#if defined(_WIN32)
|
||
rb_funcall(mFiddle, rb_intern("win32_last_error="), 1, INT2NUM(errno));
|
||
rb_funcall(mFiddle, rb_intern("win32_last_error="), 1, ULONG2NUM(GetLastError()));
|
||
#endif
|
||
ALLOCV_END(alloc_buffer);
|
test/fiddle/test_function.rb | ||
---|---|---|
def setup
|
||
super
|
||
Fiddle.last_error = nil
|
||
Fiddle.win32_last_error = nil if WINDOWS
|
||
end
|
||
def test_default_abi
|
||
... | ... | |
refute_nil Fiddle.last_error
|
||
end
|
||
def test_win32_last_error
|
||
kernel32 = dlopen('kernel32')
|
||
args = [kernel32['SetLastError'], [TYPE_LONG], TYPE_VOID]
|
||
args << Function::STDCALL if Function.const_defined?(:STDCALL)
|
||
func = Function.new(*args)
|
||
assert_nil(Fiddle.win32_last_error)
|
||
n = 1 << 29 | 1
|
||
func.call(n)
|
||
assert_equal(n, Fiddle.win32_last_error)
|
||
end if WINDOWS
|
||
def test_strcpy
|
||
f = Function.new(@libc['strcpy'], [TYPE_VOIDP, TYPE_VOIDP], TYPE_VOIDP)
|
||
buff = "000"
|