зеркало из https://github.com/github/ruby.git
[ruby/fiddle] windows: use GetLastError() for win32_last_error
Ruby: [Bug #11579] Patch by cremno phobia. Thanks!!! https://github.com/ruby/fiddle/commit/760a8f9b14
This commit is contained in:
Родитель
c0f9191ab6
Коммит
d1eeb9fec9
|
@ -378,9 +378,10 @@ function_call(int argc, VALUE argv[], VALUE self)
|
|||
{
|
||||
int errno_keep = errno;
|
||||
#if defined(_WIN32)
|
||||
DWORD error = WSAGetLastError();
|
||||
int socket_error = WSAGetLastError();
|
||||
rb_funcall(mFiddle, rb_intern("win32_last_error="), 1,
|
||||
INT2NUM(errno_keep));
|
||||
ULONG2NUM(error));
|
||||
rb_funcall(mFiddle, rb_intern("win32_last_socket_error="), 1,
|
||||
INT2NUM(socket_error));
|
||||
#endif
|
||||
|
|
|
@ -9,6 +9,7 @@ module Fiddle
|
|||
def setup
|
||||
super
|
||||
Fiddle.last_error = nil
|
||||
Fiddle.win32_last_error = nil if WINDOWS
|
||||
end
|
||||
|
||||
def test_default_abi
|
||||
|
@ -94,6 +95,19 @@ module Fiddle
|
|||
refute_nil Fiddle.last_error
|
||||
end
|
||||
|
||||
if WINDOWS
|
||||
def test_win32_last_error
|
||||
kernel32 = dlopen('kernel32')
|
||||
args = [kernel32['SetLastError'], [TYPE_LONG], TYPE_VOID]
|
||||
args << Function::STDCALL if Function.const_defined?(:STDCALL)
|
||||
set_last_error = Function.new(*args)
|
||||
assert_nil(Fiddle.win32_last_error)
|
||||
n = 1 << 29 | 1
|
||||
set_last_error.call(n)
|
||||
assert_equal(n, Fiddle.win32_last_error)
|
||||
end
|
||||
end
|
||||
|
||||
def test_strcpy
|
||||
f = Function.new(@libc['strcpy'], [TYPE_VOIDP, TYPE_VOIDP], TYPE_VOIDP)
|
||||
buff = +"000"
|
||||
|
|
Загрузка…
Ссылка в новой задаче