[PATCH] free: preserve errno [BZ#17924]
Florian Weimer
fweimer@redhat.com
Mon Dec 21 09:33:09 GMT 2020
* 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
More information about the Libc-alpha
mailing list