Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Code brewing for the upcoming MCE 10 year anniversary

by marioroy (Prior)
on Oct 23, 2022 at 20:39 UTC ( [id://11147613]=note: print w/replies, xml ) Need Help??


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); }

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11147613]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (3)
As of 2024-04-24 21:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found