Skip to content

Commit c74b455

Browse files
committed
Add SC_NPROCESSORS_ONLN sysconf variable
1 parent b28aaad commit c74b455

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/PosixModuleBuiltins.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2853,11 +2853,14 @@ static int getCpuCount() {
28532853
abstract static class SysconfNode extends PythonUnaryBuiltinNode {
28542854

28552855
public static final TruffleString T_SC_CLK_TCK = tsLiteral("SC_CLK_TCK");
2856+
public static final TruffleString T_SC_NPROCESSORS_ONLN = tsLiteral("SC_NPROCESSORS_ONLN");
28562857
public static final int SC_CLK_TCK = 2;
2858+
public static final int SC_NPROCESSORS_ONLN = 84;
28572859
public static final EconomicMapStorage SYSCONF_NAMES = EconomicMapStorage.create();
28582860
static {
28592861
// TODO populate from constants
28602862
SYSCONF_NAMES.putUncachedWithJavaEq(T_SC_CLK_TCK, SC_CLK_TCK);
2863+
SYSCONF_NAMES.putUncachedWithJavaEq(T_SC_NPROCESSORS_ONLN, SC_NPROCESSORS_ONLN);
28612864
}
28622865

28632866
@Specialization
@@ -2885,6 +2888,8 @@ static int sysconf(VirtualFrame frame, Object arg,
28852888
if (id == SC_CLK_TCK) {
28862889
return 100; // it's 100 on most default kernel configs. TODO: use real value through
28872890
// NFI
2891+
} else if (id == SC_NPROCESSORS_ONLN) {
2892+
return CpuCountNode.getCpuCount();
28882893
}
28892894
throw constructAndRaiseNode.get(inliningTarget).raiseOSError(frame, OSErrorEnum.EINVAL);
28902895
}

0 commit comments

Comments
 (0)