Skip to content

Commit

Permalink
Android update
Browse files Browse the repository at this point in the history
  • Loading branch information
marioroy committed Sep 12, 2023
1 parent ae5250e commit 4841c8f
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 16 deletions.
5 changes: 3 additions & 2 deletions lib/MCE.pm
Original file line number Diff line number Diff line change
Expand Up @@ -629,8 +629,9 @@ sub spawn {
MCE::Util::_sock_pair($self, qw(_dat_r_sock _dat_w_sock), $_, 1)
for (1 .. $_data_channels);

setsockopt($self->{_dat_r_sock}->[0], SOL_SOCKET, SO_RCVBUF, pack('i', 4096))
if ($^O ne 'aix' && $^O ne 'linux');
if ($^O !~ /linux|android|aix/) {
setsockopt($self->{_dat_r_sock}->[0], SOL_SOCKET, SO_RCVBUF, pack('i', 4096));
}

if (defined $self->{init_relay}) { # relay
unless ($INC{'MCE/Relay.pm'}) {
Expand Down
2 changes: 1 addition & 1 deletion lib/MCE/Channel.pm
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ sub new {
my $impl = defined( $argv{impl} ) ? ucfirst( lc $argv{impl} ) : 'Mutex';

# Replace 'fast' with 'Fast' in the implementation value.
$impl =~ s/fast$/Fast/;
$impl =~ s/fast/Fast/;

$impl = 'Threads' if ( $impl eq 'Mutex' && $^O eq 'MSWin32' );
$impl = 'ThreadsFast' if ( $impl eq 'MutexFast' && $^O eq 'MSWin32' );
Expand Down
3 changes: 3 additions & 0 deletions lib/MCE/Signal.pm
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,9 @@ sub _make_tmpdir {
$_tmp_base_dir = $ENV{TEMP};
}
}
elsif (! -w '/tmp' && -e $ENV{TMPDIR} && -d $ENV{TMPDIR} && -w _) {
$_tmp_base_dir = $ENV{TMPDIR};
}
else {
$_tmp_base_dir = ($_use_dev_shm && -d '/dev/shm' && -w _)
? '/dev/shm' : '/tmp';
Expand Down
20 changes: 7 additions & 13 deletions lib/MCE/Util.pm
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,16 @@ 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>;
close $fh;
}
elsif ( open $fh, '<', '/proc/cpuinfo' ) {
$count = grep { /^processor/ } <$fh>;
close $fh;
}
$ncpu = $count if $count;
last OS_CHECK;
};
Expand Down Expand Up @@ -138,16 +142,6 @@ 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";
}

Expand Down Expand Up @@ -254,7 +248,7 @@ sub _sock_pair {
AF_UNIX, Socket::SOCK_STREAM(), 0 ) or die "socketpair: $!\n";
}

if ($^O ne 'aix' && $^O ne 'linux') {
if ($^O !~ /aix|linux|android/) {
setsockopt($_obj->{$_r_sock}[$_i], SOL_SOCKET, SO_SNDBUF, int $_size);
setsockopt($_obj->{$_r_sock}[$_i], SOL_SOCKET, SO_RCVBUF, int $_size);
setsockopt($_obj->{$_w_sock}[$_i], SOL_SOCKET, SO_SNDBUF, int $_size);
Expand All @@ -277,7 +271,7 @@ sub _sock_pair {
AF_UNIX, Socket::SOCK_STREAM(), 0 ) or die "socketpair: $!\n";
}

if ($^O ne 'aix' && $^O ne 'linux') {
if ($^O !~ /aix|linux|android/) {
setsockopt($_obj->{$_r_sock}, SOL_SOCKET, SO_SNDBUF, int $_size);
setsockopt($_obj->{$_r_sock}, SOL_SOCKET, SO_RCVBUF, int $_size);
setsockopt($_obj->{$_w_sock}, SOL_SOCKET, SO_SNDBUF, int $_size);
Expand Down

0 comments on commit 4841c8f

Please sign in to comment.