* outb(2) Text regarding optimizations
@ 2021-10-06 19:14 Alejandro Colomar (man-pages)
0 siblings, 0 replies; only message in thread
From: Alejandro Colomar (man-pages) @ 2021-10-06 19:14 UTC (permalink / raw)
To: linux-man, linux-kernel, Libc-alpha
Hi,
outb(2) says that users of these functions should optimize to avoid
having unresolved references at link time.
The text is:
[
They are primarily designed for internal kernel use, but
can be used from user space.
You must compile with -O or -O2 or similar. The functions
are defined as inline macros, and will not be substituted
in without optimization enabled, causing unresolved refer‐
ences at link time.
]
First of all, "inline macros" already is a misnomer. They are 'static
inline' functions. But 'static inline' functions _never_ cause
unresolved references, because they are 'static', so the function code
is added to each translation unit as an anonymous function (which is a
big problem of static inline: it may bloat code by repeating code in
translation units, C99 inline being preferable).
So is this an incorrect advice (maybe because of a veeery old
implementation)? (I couldn't find any relevant implementation changes
in the glibc git history.)
If there is any reason I'm missing (I don't understand the assembly
calls that these functions call, so maybe) that would cause these
functions to actually require optimization, I'd say it's a bug, and a
better solution would be to add the attribute
__attribute__((__always_inline__)) to the functions, so that they will
_always_ be inlined, no matter what optimization level the user chooses.
Right?
Thanks,
Alex
--
Alejandro Colomar
Linux man-pages comaintainer; https://www.kernel.org/doc/man-pages/
http://www.alejandro-colomar.es/
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2021-10-06 19:14 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-06 19:14 outb(2) Text regarding optimizations Alejandro Colomar (man-pages)
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).