This is the mail archive of the
newlib@sourceware.org
mailing list for the newlib project.
Re: [patch] Include some c99 functions in __STRICT_ANSI__ for cygwin c99.
- From: Corinna Vinschen <vinschen at redhat dot com>
- To: newlib at sourceware dot org
- Date: Fri, 16 Oct 2009 19:16:41 +0200
- Subject: Re: [patch] Include some c99 functions in __STRICT_ANSI__ for cygwin c99.
- References: <4AD6A0FB.5080505@gmail.com> <4AD8A597.7020508@redhat.com>
- Reply-to: newlib at sourceware dot org
On Oct 16 12:55, Jeff Johnston wrote:
> I think the better solution is to emulate glibc which uses the flag
> __USE_XOPEN2K to determine if fseeko and ftello are to be used.
>
> So I made the following patch which sets the __USE_XOPEN2K flag for Cygwin
> and uses to check for fseeko, ftello when __STRICT_ANSI__ is set.
>
> The remainder of the I/O functions in that chunk are included if C99.
>
> A patch is attached. Let me know if you have any concerns, otherwise I'll
> check it in.
I don't think this patch is correct. It sets the __USE_XOPEN2K
flag only when building newlib. However, this is a header file
and we need the right definition at compile time of any subsequent
application, not only when building newlib.
So, I assume what we need is a definition in config.h, similar to
what Dave suggested:
#if __STDC_VERSION__ >= 199901L
#define __USE_XOPEN2K 1
#endif
Corinna
> Index: configure.host
> ===================================================================
> RCS file: /cvs/src/src/newlib/configure.host,v
> retrieving revision 1.110
> diff -u -p -r1.110 configure.host
> --- configure.host 8 Oct 2009 16:44:09 -0000 1.110
> +++ configure.host 16 Oct 2009 16:50:08 -0000
> @@ -536,7 +536,7 @@ case "${host}" in
> default_newlib_io_long_double="yes"
> default_newlib_io_pos_args="yes"
> CC="${CC} -I${cygwin_srcdir}/include"
> - newlib_cflags="${newlib_cflags} -DHAVE_OPENDIR -DHAVE_RENAME -DSIGNAL_PROVIDED -D_COMPILING_NEWLIB -DHAVE_BLKSIZE -DHAVE_FCNTL -DMALLOC_PROVIDED"
> + newlib_cflags="${newlib_cflags} -DHAVE_OPENDIR -DHAVE_RENAME -DSIGNAL_PROVIDED -D_COMPILING_NEWLIB -DHAVE_BLKSIZE -DHAVE_FCNTL -DMALLOC_PROVIDED -D__USE_XOPEN2K"
> syscall_dir=syscalls
> ;;
> # RTEMS supplies its own versions of some routines:
> Index: libc/include/stdio.h
> ===================================================================
> RCS file: /cvs/src/src/newlib/libc/include/stdio.h,v
> retrieving revision 1.58
> diff -u -p -r1.58 stdio.h
> --- libc/include/stdio.h 3 Jul 2009 11:58:04 -0000 1.58
> +++ libc/include/stdio.h 16 Oct 2009 16:50:08 -0000
> @@ -232,7 +232,7 @@ int _EXFUN(sprintf, (char *, const char
> int _EXFUN(remove, (const char *));
> int _EXFUN(rename, (const char *, const char *));
> #endif
> -#ifndef __STRICT_ANSI__
> +#if !defined(__STRICT_ANSI__) || defined(__USE_XOPEN2K)
> #ifdef _COMPILING_NEWLIB
> int _EXFUN(fseeko, (FILE *, _off_t, int));
> _off_t _EXFUN(ftello, ( FILE *));
> @@ -240,6 +240,7 @@ _off_t _EXFUN(ftello, ( FILE *));
> int _EXFUN(fseeko, (FILE *, off_t, int));
> off_t _EXFUN(ftello, ( FILE *));
> #endif
> +#if !defined(__STRICT_ANSI__) || __STDC_VERSION__ >= 199901L)
> #ifndef _REENT_ONLY
> int _EXFUN(asiprintf, (char **, const char *, ...)
> _ATTRIBUTE ((__format__ (__printf__, 2, 3))));
--
Corinna Vinschen
Cygwin Project Co-Leader
Red Hat