From: Florian Weimer <fweimer@redhat.com>
To: Paul Eggert <eggert@cs.ucla.edu>
Cc: Carlos O'Donell <carlos@redhat.com>, libc-alpha@sourceware.org
Subject: Re: [PATCH] free: preserve errno [BZ#17924]
Date: Mon, 21 Dec 2020 10:33:09 +0100 [thread overview]
Message-ID: <871rfjzep6.fsf@oldenburg2.str.redhat.com> (raw)
In-Reply-To: <f33d3233-58cc-12eb-e68f-2aee35490799@cs.ucla.edu> (Paul Eggert's message of "Sun, 20 Dec 2020 23:20:33 -0800")
* Paul Eggert:
> +/* The indirection through a volatile function pointer is necessary to prevent
> + a GCC optimization. Without it, when optimizing, GCC would "know" that errno
> + is unchanged by calling free(ptr), when ptr was the result of a malloc(...)
> + call in the same function. */
> +static int
> +get_errno (void)
Long line (80 characters).
I think you need to use this:
int __attribute__ ((weak))
get_errno (void)
{
return errno;
}
With that volatile construct, the read of errno is not actually behind a
compiler barrier.
Thanks,
Florian
--
Red Hat GmbH, https://de.redhat.com/ , Registered seat: Grasbrunn,
Commercial register: Amtsgericht Muenchen, HRB 153243,
Managing Directors: Charles Cachera, Brian Klemm, Laurie Krebs, Michael O'Neill
next prev parent reply other threads:[~2020-12-21 9:33 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-20 20:25 Paul Eggert
2020-12-21 2:03 ` Siddhesh Poyarekar
2020-12-21 4:27 ` Carlos O'Donell
2020-12-21 7:20 ` Paul Eggert
2020-12-21 7:43 ` Siddhesh Poyarekar
2020-12-21 9:33 ` Florian Weimer [this message]
2020-12-21 10:03 ` Siddhesh Poyarekar
2020-12-21 10:05 ` Siddhesh Poyarekar
2020-12-23 5:30 ` Paul Eggert
2020-12-23 19:19 ` Adhemerval Zanella
2020-12-24 1:03 ` Paul Eggert
2020-12-28 19:24 ` Adhemerval Zanella
2020-12-29 13:38 ` H.J. Lu
2020-12-29 18:32 ` Adhemerval Zanella
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=871rfjzep6.fsf@oldenburg2.str.redhat.com \
--to=fweimer@redhat.com \
--cc=carlos@redhat.com \
--cc=eggert@cs.ucla.edu \
--cc=libc-alpha@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).