On 05/15/2013 09:52 PM, Paul Eggert wrote:
> ---
>  ChangeLog      | 10 ++++++++++
>  lib/stdio.in.h | 19 +++++++++++++------
>  2 files changed, 23 insertions(+), 6 deletions(-)
> 
> diff --git a/ChangeLog b/ChangeLog
> index dfb2e5c..3544972 100644
> --- a/ChangeLog
> +++ b/ChangeLog
> @@ -1,5 +1,15 @@
>  2013-05-15  Paul Eggert  <egg...@cs.ucla.edu>
>  
> +     stdio: use __REDIRECT for fwrite, fwrite_unlocked

My first worry is that __REDIRECT is non-standard; but then I realized:

>  #  if (0 < __USE_FORTIFY_LEVEL                                          \
>         && __GLIBC__ == 2 && 4 <= __GLIBC_MINOR__ && __GLIBC_MINOR__ <= 15 \

We only get here on glibc, where system headers give us __REDIRECT, so

> +#   undef fwrite
> +#   undef fwrite_unlocked
> +extern size_t __REDIRECT (rpl_fwrite,
> +                          (const void *__restrict, size_t, size_t,
> +                           FILE *__restrict),
> +                          fwrite);

this usage only has to work for glibc, which it does.  Interesting solution.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to