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