in reply to Code brewing for the upcoming MCE 10 year anniversary
I'm still undecided about including the count method in MCE::Semaphore. Most platforms are supported.
The count method may be helpful for a future MCE::Barrior module. I obtained the FIONREAD value using QEMU. Oh what fun it was running a s390x emulated machine. Likewise for Alpha, AArch64, MIPS, PA-RISC, PowerPC, RISC-V, and SPARC.
What about the Haiku OS? Yep, this one too is supported :)
my $FIONREAD = do { use Config qw(config_re); my ($archname) = config_re('archname'); if ($archname =~ /(?:irix|mips)/i) { # IRIX; Linux on MIPS 0x467f; } elsif ($archname =~ /(?:alpha|powerpc|ppc|sparc)/i) { # OSF/1, Tru64; Linux on Alpha, PowerPC, SPARC 0x4004667f; } elsif ($^O =~ /(?:hp-?ux|linux)/i) { # HP-UX; Linux on AArch64, ARM, PA-RISC, RISC-V, s390x, x86_64 0x541b; } elsif ($^O =~ /(?:aix|bsd|darwin|dragonfly|mswin|mingw|msys|cygwin +|solaris)/i) { # AIX, BSD derivatives, macOS, Windows/Cygwin, Solaris 0x4004667f; } elsif ($^O =~ /haiku/i) { # Haiku (BeOS-like OS) 0xbe000001; } else { ## # MCE::Semaphore::count() unimplemented in this platform. # Pull request or email the author $^O, archname, and FIONREAD +. # # $ perl -MConfig -le 'print $^O, ": ", $Config{archname}' # $ python3 -c 'import termios; print(hex(termios.FIONREAD))' # # $ cat fionread.c # # #include <stdio.h> # #include <sys/ioctl.h> # int main() { # printf("%#08lx\n", FIONREAD); # return 0; # } # # $ cc -o fionread fionread.c # $ ./fionread ## 0x0; } }; # $sem->count sub count { die 'MCE::Semaphore::count() unimplemented in this platform' unless $FIONREAD; my $count = pack('L', 0); ioctl($_[0]->{r_sock}, $FIONREAD, $count); unpack('L', $count); }
|
|---|