Sujet : Re: errno (was Re: C23 thoughts and opinions - why so conservative?)
De : Keith.S.Thompson+u (at) *nospam* gmail.com (Keith Thompson)
Groupes : comp.lang.cDate : 26. May 2024, 00:45:28
Autres entêtes
Organisation : None to speak of
Message-ID : <875xv11mnb.fsf@nosuchdomain.example.com>
References : 1 2 3 4 5 6 7
User-Agent : Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
David Brown <
david.brown@hesbynett.no> writes:
[...]
The normal way for multi-threaded systems is to implement it as a
macro. It might be, for example :
>
#define errno __thread_data->_errno
>
or
>
#define errno *errno()
Both of those need more parentheses -- and I'm unconfortable using the
same identifier for the macro and the function.
That is precisely why it is specified in the C standards as a macro,
not an external linkage object with static or thread-local storage
duration. (The use of errno in multi-threading C code long predates
C11 and _Thread_local.)
[...]
glibc and musl both have :
# define errno (*__errno_location ())
newlib (used on Cygwin) has something similar :
#define errno (*__errno())
-- Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.comvoid Void(void) { Void(); } /* The recursive call of the void */