public inbox for newlib@sourceware.org
 help / color / mirror / Atom feed
From: Richard Damon <Richard@Damon-Family.org>
To: newlib@sourceware.org
Subject: Re: When/how is global "errno" variable from reent.c to be used?
Date: Fri, 16 Oct 2020 15:06:42 -0400	[thread overview]
Message-ID: <766f7b8d-6e68-9c33-a3bc-c7bbd868d0f3@Damon-Family.org> (raw)
In-Reply-To: <rmcnmq$lsa$1@ciao.gmane.io>

On 10/16/20 2:10 PM, Grant Edwards via Newlib wrote:
> On 2020-10-16, Richard Damon <Richard@Damon-Family.org> wrote:
>
>> Software the explicitly declares errno as
>> extern int errno;
>> is broken, and violates the C standard, and creates explicitly stated
>> Undefined Behavior.
> So the LWIP source is just plain wrong.
>
> What is the global 'int errno' exported by reent.c for?
>
> --
> Grant
>
>
First, newlib considers itself as part of 'the implementation', as its
purpose is to provide the 'standard library' for an implementation, thus
it can do what it wants here (as long as the net result meets the
specifications).

I would have to dig into the actual implementation details to tell for
sure, but first check if when the statement int errno; is compiled, is
errno currently a macro, and after replacing that macro with its
definition what the statement actually defines, it might be creating the
pointer that is used to access the effective errno.

It could also be creating a global variable just to limit the breakage
that programs that do it wrong incur (though, I might prefer getting the
link error errno not defined rather than code that ends up checking the
wrong errno).

-- 
Richard Damon


  reply	other threads:[~2020-10-16 19:06 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-16 15:50 Grant Edwards
2020-10-16 16:38 ` Richard Damon
2020-10-16 18:10   ` Grant Edwards
2020-10-16 19:06     ` Richard Damon [this message]
2020-10-16 21:49       ` Grant Edwards

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=766f7b8d-6e68-9c33-a3bc-c7bbd868d0f3@Damon-Family.org \
    --to=richard@damon-family.org \
    --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).