Feature #10267 » etc-nprocessors3.patch
| test/etc/test_etc.rb (working copy) | ||
|---|---|---|
|
}
|
||
|
end if defined?(Etc::PC_PIPE_BUF)
|
||
|
def test_nprocessors
|
||
|
n = Etc.nprocessors
|
||
|
assert_operator(1, :<=, n)
|
||
|
end
|
||
|
end
|
||
| ext/etc/etc.c (working copy) | ||
|---|---|---|
|
#define io_pathconf rb_f_notimplement
|
||
|
#endif
|
||
|
#if defined(HAVE_SYSCONF) && defined(_SC_NPROCESSORS_ONLN)
|
||
|
/*
|
||
|
* Returns the number of online processors.
|
||
|
*
|
||
|
* The result is intended as the number of processes to
|
||
|
* use all available processors.
|
||
|
*
|
||
|
* This method is implemented as:
|
||
|
* - sysconf(_SC_NPROCESSORS_ONLN): GNU/Linux, NetBSD, FreeBSD, OpenBSD, DragonFly BSD, OpenIndiana, Mac OS X, AIX
|
||
|
*
|
||
|
* Example:
|
||
|
*
|
||
|
* require 'etc'
|
||
|
* p Etc.nprocessors #=> 4
|
||
|
*
|
||
|
*/
|
||
|
static VALUE
|
||
|
etc_nprocessors(VALUE obj)
|
||
|
{
|
||
|
long ret;
|
||
|
errno = 0;
|
||
|
ret = sysconf(_SC_NPROCESSORS_ONLN);
|
||
|
if (ret == -1) {
|
||
|
rb_sys_fail("sysconf(_SC_NPROCESSORS_ONLN)");
|
||
|
}
|
||
|
return LONG2NUM(ret);
|
||
|
}
|
||
|
#else
|
||
|
#define etc_nprocessors rb_f_notimplement
|
||
|
#endif
|
||
|
/*
|
||
|
* The Etc module provides access to information typically stored in
|
||
|
* files in the /etc directory on Unix systems.
|
||
| ... | ... | |
|
rb_define_module_function(mEtc, "sysconf", etc_sysconf, 1);
|
||
|
rb_define_module_function(mEtc, "confstr", etc_confstr, 1);
|
||
|
rb_define_method(rb_cIO, "pathconf", io_pathconf, 1);
|
||
|
rb_define_module_function(mEtc, "nprocessors", etc_nprocessors, 0);
|
||
|
sPasswd = rb_struct_define_under(mEtc, "Passwd",
|
||
|
"name",
|
||
| ChangeLog (working copy) | ||
|---|---|---|
|
Sat Sep 20 10:22:17 2014 Tanaka Akira <akr@fsij.org>
|
||
|
* ext/etc/etc.c (etc_nprocessors_online): New method.
|
||
|
Accepted by matz at RubyKaigi 2014.
|
||
|
Sat Sep 20 10:02:51 2014 Tanaka Akira <akr@fsij.org>
|
||
|
* ext/openssl/lib/openssl/x509.rb (OpenSSL::X509::Name#pretty_print):
|
||