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

In reply to Re: Code brewing for the upcoming MCE 10 year anniversary by marioroy
in thread Code brewing for the upcoming MCE 10 year anniversary by marioroy

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.