public inbox for newlib@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 0/3] Reentrancy
@ 2023-08-30  9:16 Pekka Seppänen
  2023-08-31  9:23 ` Corinna Vinschen
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Pekka Seppänen @ 2023-08-30  9:16 UTC (permalink / raw)
  To: newlib

Hi,

The following patch series provides small (one line) fixes for 
newlib/libc
reentrancy when using --enable-newlib-reent-thread-local and uses the 
existing
infrastructure to do that:

   - There were a few locations on which _errno member was directly 
accessed.
As struct _reent is not available if _REENT_THREAD_LOCAL is defined, any
accesses to errno shall be done using the corresponding _REENT_ERRNO() 
macro.
Should be self-explanatory.

   - __getreent() did not check that struct _reent and _impure_ptr were
available.  Both <sys/reent.h> and impure.c, that declare and define
_impure_ptr, use similar #ifdef/ifndef gate.  If thread-local storage is 
used
the allocated objects are not related to each other.  Therefore 
__getreent()
does not exist even at a concept level, hence should not be provided at 
all.

   - As _Thread_local might not be available (as in that particular 
keyword),
<sys/reent.h> shall include <sys/cdefs.h> that will provide a correct 
mapping,
should the compiler actually support thread-local storage.  A prime 
example is
libstdc++ configure, which uses #include <math.h> in some of the 
generated
checks.  Essentially any C++ target is affected and possibly C targets 
in
near future as C23 uses thread_local, not _Thread_local.

It should be noted that libgloss is affected by similar reentrancy 
issues, but
I decided not to touch those.

-- Pekka

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-09-11  8:09 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-30  9:16 [PATCH 0/3] Reentrancy Pekka Seppänen
2023-08-31  9:23 ` Corinna Vinschen
2023-08-31 10:40   ` Pekka Seppänen
2023-08-31  9:24 ` Corinna Vinschen
2023-09-11  8:09 ` Sebastian Huber

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 read-only IMAP folder(s) and NNTP newsgroup(s).