Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions ext/etc/etc.c
Original file line number Diff line number Diff line change
Expand Up @@ -800,6 +800,8 @@ static VALUE
etc_uname(VALUE obj)
{
#ifdef _WIN32
typedef long (WINAPI version_func)(OSVERSIONINFOW *);
version_func *pRtlGetVersion;
OSVERSIONINFOW v;
SYSTEM_INFO s;
const char *sysname, *mach;
Expand All @@ -808,9 +810,11 @@ etc_uname(VALUE obj)
DWORD len = 0;
WCHAR *buf;

/* GetVersionEx reports 6.2 unless the manifest declares Windows 8.1 or later */
pRtlGetVersion = (version_func *)GetProcAddress(GetModuleHandleW(L"ntdll.dll"), "RtlGetVersion");
v.dwOSVersionInfoSize = sizeof(v);
if (!GetVersionExW(&v))
rb_sys_fail("GetVersionEx");
if (!pRtlGetVersion || pRtlGetVersion(&v))
rb_notimplement();

result = rb_hash_new();
sysname = "Windows_NT";
Expand Down
5 changes: 5 additions & 0 deletions test/etc/test_etc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,11 @@ def test_uname
}
end

def test_uname_release_on_windows
release = IO.popen(%w[cmd.exe /c ver], "rb", &:read)[/\d+\.\d+\.\d+/]
assert_equal(release, Etc.uname[:release])
end if /mswin|mingw/ =~ RUBY_PLATFORM

def test_sysconf
begin
Etc.sysconf
Expand Down
Loading