From ef476ab20d02e7e6b3864313be25f76db6f049e3 Mon Sep 17 00:00:00 2001 From: Dimitrios Kechagias Date: Sat, 9 Sep 2023 01:10:30 +0100 Subject: [PATCH 1/2] MCE::Util::get_ncpu for android --- lib/MCE/Util.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/MCE/Util.pm b/lib/MCE/Util.pm index aefb40e..214721e 100644 --- a/lib/MCE/Util.pm +++ b/lib/MCE/Util.pm @@ -61,7 +61,7 @@ sub get_ncpu { OS_CHECK: { local $_ = lc $^O; - /linux/ && do { + /linux|android/ && do { my ( $count, $fh ); if ( open $fh, '<', '/proc/stat' ) { $count = grep { /^cpu\d/ } <$fh>; From af750443c6cb7692eafcb0ca3b82050ea2399eb1 Mon Sep 17 00:00:00 2001 From: Dimitrios Kechagias Date: Sat, 9 Sep 2023 01:40:14 +0100 Subject: [PATCH 2/2] /proc/cpuinfo --- lib/MCE/Util.pm | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/MCE/Util.pm b/lib/MCE/Util.pm index 214721e..c354a26 100644 --- a/lib/MCE/Util.pm +++ b/lib/MCE/Util.pm @@ -61,7 +61,7 @@ sub get_ncpu { OS_CHECK: { local $_ = lc $^O; - /linux|android/ && do { + /linux/ && do { my ( $count, $fh ); if ( open $fh, '<', '/proc/stat' ) { $count = grep { /^cpu\d/ } <$fh>; @@ -138,6 +138,16 @@ sub get_ncpu { last OS_CHECK; }; + /android/ && do { + my ( $count, $fh ); + if ( open $fh, '<', '/proc/cpuinfo' ) { + $count = grep { /^processor/ } <$fh>; + close $fh; + } + $ncpu = $count if $count; + last OS_CHECK; + }; + warn "MCE::Util::get_ncpu: command failed or unknown operating system\n"; }