fwiw, this came up for Android recently... we'd never had the header before but the
https://blog.chromium.org/2024/06/building-faster-smarter-chromebook.html work meant we needed new x86-only stuff for the first time in a decade.
we basically went with this:
#if defined(__NR_iopl)
static __inline int ioperm(unsigned long __from, unsigned long __n, int __enabled) {
return syscall(__NR_ioperm, __from, __n, __enabled);
}
#endif
(which answers the "some architectures" part, even though for Android that's only x86/x86-64.)
here's my commit message with more rationale for why i made them static inlines:
"""
Add <sys/io.h>.
This is unusual in being inline-only, but these are (a) trivial functions, (b) ancient functions, and (c) unusable by apps. Plus they're arriving just too late for API 35, which definitely influenced by "this is silly" decision! They're also x86/x86-64 only, though that's a neutral argument because it would mean almost no-one will be affected no matter what choice we make here.
There is an argument for going the usual "callers should just have their own header-only implementation that they `-include` on the compiler command line" route, but the x86/x86-64 I/O port stuff isn't going away just yet, and LTP was also already working around the absence of these.
"""