[PATCH] stdio.h: Use __POSIX_VISIBLE etc. guards for POSIX 1003.1:2001 functions
Sebastian Huber
sebastian.huber@embedded-brains.de
Wed Feb 10 06:52:00 GMT 2016
Hello Jon,
could you please check if the upstream FreeBSD feature checks are all right? Your patch looks a bit more complicated than necessary, e.g in FreeBSD we have only:
#if __POSIX_VISIBLE
[...]
int fileno(FILE *);
#endif /* __POSIX_VISIBLE */
There is some logic in the definition of the internal __*_VISIBLE defines in <sys/cdefs.h>. We should not repeat this logic throughout the code base.
----- Jon Turney <jon.turney@dronecode.org.uk> schrieb:
> Current mesa expects stdio.h to prototype fileno() when compiling with gcc
> -std=c99 -D_XOPEN_SOURCE
>
> Fix the 'POSIX 1003.1:2001' block in stdio.h to prototype functions if not
> __STRICT_ANSI__, or _BSD_SOURCE, _POSIX_C_SOURCE or _XOPEN_SOURCE are defined
> appropriately
>
> As far as I can tell, despite being in this block, setbuffer() and setlinebuf()
> are BSDisms which aren't in POSIX 1003.1:2001
>
> Signed-off-by: Jon Turney <jon.turney@dronecode.org.uk>
> ---
> newlib/libc/include/stdio.h | 14 ++++++++++----
> 1 file changed, 10 insertions(+), 4 deletions(-)
>
> diff --git a/newlib/libc/include/stdio.h b/newlib/libc/include/stdio.h
> index 9d8fd86..b7a9344 100644
> --- a/newlib/libc/include/stdio.h
> +++ b/newlib/libc/include/stdio.h
> @@ -311,17 +311,23 @@ int _EXFUN(vsscanf, (const char *__restrict, const char *__restrict, __VALIST)
> * Routines in POSIX 1003.1:2001.
> */
>
> -#ifndef __STRICT_ANSI__
> +#if !defined(__STRICT_ANSI__) || __XSI_VISIBLE || __POSIX_VISIBLE >= 200112
> #ifndef _REENT_ONLY
> FILE * _EXFUN(fdopen, (int, const char *));
> #endif
> int _EXFUN(fileno, (FILE *));
> -int _EXFUN(getw, (FILE *));
> int _EXFUN(pclose, (FILE *));
> FILE * _EXFUN(popen, (const char *, const char *));
> -int _EXFUN(putw, (int, FILE *));
> +#endif
> +
> +#if !defined(__STRICT_ANSI__) || __BSD_VISIBLE
> void _EXFUN(setbuffer, (FILE *, char *, int));
> int _EXFUN(setlinebuf, (FILE *));
> +#endif
> +
> +#if !defined(__STRICT_ANSI__) || __BSD_VISIBLE || __XSI_VISIBLE || __POSIX_VISIBLE >= 200112
> +int _EXFUN(getw, (FILE *));
> +int _EXFUN(putw, (int, FILE *));
> int _EXFUN(getc_unlocked, (FILE *));
> int _EXFUN(getchar_unlocked, (void));
> void _EXFUN(flockfile, (FILE *));
> @@ -329,7 +335,7 @@ int _EXFUN(ftrylockfile, (FILE *));
> void _EXFUN(funlockfile, (FILE *));
> int _EXFUN(putc_unlocked, (int, FILE *));
> int _EXFUN(putchar_unlocked, (int));
> -#endif /* ! __STRICT_ANSI__ */
> +#endif
>
> /*
> * Routines in POSIX 1003.1:200x.
> --
> 2.7.0
--
Sebastian Huber, embedded brains GmbH
Address : Dornierstr. 4, D-82178 Puchheim, Germany
Phone : +49 89 189 47 41-16
Fax : +49 89 189 47 41-09
E-Mail : sebastian.huber at embedded-brains.de
PGP : Public key available on request.
Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.
More information about the Newlib
mailing list