mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* ext/etc/etc.c (etc_nprocessors): Windows support.
see [Feature #10267] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47764 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
fe18cd011c
commit
56fa18c9d3
2 changed files with 12 additions and 1 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
Thu Oct 2 18:41:45 2014 NAKAMURA Usaku <usa@ruby-lang.org>
|
||||||
|
|
||||||
|
* ext/etc/etc.c (etc_nprocessors): Windows support.
|
||||||
|
see [Feature #10267]
|
||||||
|
|
||||||
Thu Oct 2 12:21:52 2014 Tanaka Akira <akr@fsij.org>
|
Thu Oct 2 12:21:52 2014 Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
* ext/etc/etc.c (etc_nprocessors): New method.
|
* ext/etc/etc.c (etc_nprocessors): New method.
|
||||||
|
|
|
@ -891,7 +891,7 @@ io_pathconf(VALUE io, VALUE arg)
|
||||||
#define io_pathconf rb_f_notimplement
|
#define io_pathconf rb_f_notimplement
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(HAVE_SYSCONF) && defined(_SC_NPROCESSORS_ONLN)
|
#if (defined(HAVE_SYSCONF) && defined(_SC_NPROCESSORS_ONLN)) || defined(_WIN32)
|
||||||
/*
|
/*
|
||||||
* Returns the number of online processors.
|
* Returns the number of online processors.
|
||||||
*
|
*
|
||||||
|
@ -912,11 +912,17 @@ etc_nprocessors(VALUE obj)
|
||||||
{
|
{
|
||||||
long ret;
|
long ret;
|
||||||
|
|
||||||
|
#if !defined(_WIN32)
|
||||||
errno = 0;
|
errno = 0;
|
||||||
ret = sysconf(_SC_NPROCESSORS_ONLN);
|
ret = sysconf(_SC_NPROCESSORS_ONLN);
|
||||||
if (ret == -1) {
|
if (ret == -1) {
|
||||||
rb_sys_fail("sysconf(_SC_NPROCESSORS_ONLN)");
|
rb_sys_fail("sysconf(_SC_NPROCESSORS_ONLN)");
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
SYSTEM_INFO si;
|
||||||
|
GetSystemInfo(&si);
|
||||||
|
ret = (long)si.dwNumberOfProcessors;
|
||||||
|
#endif
|
||||||
return LONG2NUM(ret);
|
return LONG2NUM(ret);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
|
Loading…
Add table
Reference in a new issue