Open FGasper opened 2 years ago
I agree perlhost.h is too aggressive. Without using git blame, I can guess a few reasons why it was hooked.
Question, did any Unix libc ever dynamically change the behavior of htonl() or ntohl() , like if you made a socket with AF_BURROUGHS or AF_IBMSYS390 exotic proprietary mainframe protocols, suddenly the LE/BE logic table changed?
Also remember 1s complement CPUs exist, not sure if Perl 1-5 was ever compatible.
IMO the hooks and an exported Perl C function, can stay, because P5's implementation can be more efficient (CPU intrinsic 1 op) vs the OS (i386 and we mean it). Or in Win32 Perl's case, not current code base, but if I repair WIN32_NO_SOCKETS or do a sockets delay load DLL optimization.
Then Perl_htonl() is much "more efficient" since calling that alone, will not load winsock.dll into the process (very short runtime life scripts). Compared to Win32 native os htonl() func symbol. Why this a LINKED EXPORTED ABI C fn call in 2024, when BYTESWAP has been a x86 CPU intrinsic for decades https://www.felixcloutier.com/x86/bswap, another ticket, another day.
Other OSes, maybe some kind of 16 vs 32 vs 64b problem with the OS. My opinion, requiring pTHX? That can absolutely can be removed. Worst case, a "bug fix" is max 12 months away until next major Perl release.
My opinion, requiring pTHX? That can absolutely can be removed. Worst case, a "bug fix" is max 12 months away until next major Perl release.
That's because of IMPLICIT_SYS on Windows.
Description Earlier today I discovered that XSUB.h overwrites functions like htons. With Leon’s help I learned that it has to do with the implicit-sys logic, which itself depends on NO_XSLOCKS being undefined. While perlguts discusses NO_XSLOCKS, it makes no mention of its role vis-à-vis implicit-sys.
The overwrite is problematic because Perl’s versions of these functions require the thread-context local variable (
aTHX
), which means C functions that lack that local variable will break when calling these. For example:The overwrite’s rationale of things like open, per Leon, is that it allows different Perl interpreters to implement those differently. The problems are:
htons
are overwritten.This case documents:
So … should things like
htons
be overwritten? If not, this issue is to track that.