From: Sebastian Huber <sebastian.huber@embedded-brains.de>
To: Newlib <newlib@sourceware.org>
Subject: Why is __sglue initialized in _cygtls::init_thread()?
Date: Wed, 30 Mar 2022 10:58:50 +0200 [thread overview]
Message-ID: <e33a58f7-902c-165e-bbd5-478c9d8e8252@embedded-brains.de> (raw)
Hello,
I have a question to _cygtls::init_thread():
void
_cygtls::init_thread (void *x, DWORD (*func) (void *, void *))
{
if (x)
{
memset (this, 0, sizeof (*this));
_REENT_INIT_PTR (&local_clib);
stackptr = stack;
altstack.ss_flags = SS_DISABLE;
if (_GLOBAL_REENT)
{
local_clib._stdin = _GLOBAL_REENT->_stdin;
local_clib._stdout = _GLOBAL_REENT->_stdout;
local_clib._stderr = _GLOBAL_REENT->_stderr;
if (_GLOBAL_REENT->__cleanup)
local_clib.__cleanup = _cygtls::cleanup_early;
local_clib.__sglue._niobs = 3;
local_clib.__sglue._iobs = &_GLOBAL_REENT->__sf[0];
}
}
Why is __sglue initialized here? It seems to be unused in general for
local_clib.__sglue:
1. The __sglue::next member was still NULL, so even if someone calls
_reclaim_reent(), cleanup_glue() would not get called.
2. FILE objects are added to the __sglue list only by __sfp(). This
function only uses the __sglue member of _GLOBAL_REENT.
It could be used by _fcloseall_r() through _fwalk_reent() which seems to
be unused by Cygwin.
It could be used by __fp_lock_all() and __fp_unlock_all() through
_fwalk() which is used only by Cygwin in the pthread::atfork*() functions.
It could be used by _cleanup_r() through _fwalk_reent().
In the above three cases the file walk would operate on the three FILE
objects in _GLOBAL_REENT->__sf. I would like to change the __sglue
handling, so it would be great if someone could explain the Cygwin use
case for the __sglue initialization in _cygtls::init_thread().
--
embedded brains GmbH
Herr Sebastian HUBER
Dornierstr. 4
82178 Puchheim
Germany
email: sebastian.huber@embedded-brains.de
phone: +49-89-18 94 741 - 16
fax: +49-89-18 94 741 - 08
Registergericht: Amtsgericht München
Registernummer: HRB 157899
Vertretungsberechtigte Geschäftsführer: Peter Rasmussen, Thomas Dörfler
Unsere Datenschutzerklärung finden Sie hier:
https://embedded-brains.de/datenschutzerklaerung/
next reply other threads:[~2022-03-30 8:58 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-30 8:58 Sebastian Huber [this message]
2022-04-01 13:34 ` Corinna Vinschen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=e33a58f7-902c-165e-bbd5-478c9d8e8252@embedded-brains.de \
--to=sebastian.huber@embedded-brains.de \
--cc=newlib@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).