[2/2] don't compile gcvt if posix < 200112

Message ID 20190722231445.15990-2-uchan0+newlib@gmail.com
State New
Headers show
Series
  • [1/2] fix conflicting types (wint_t)
Related show

Commit Message

Kota Uchida July 22, 2019, 11:14 p.m.
From: uchan-nos <uchan0@gmail.com>


---
 newlib/libc/stdlib/efgcvt.c | 4 ++++
 1 file changed, 4 insertions(+)

-- 
2.17.1

Comments

Yaakov Selkowitz July 23, 2019, 3:56 a.m. | #1
On Tue, 2019-07-23 at 08:14 +0900, uchan0+newlib@gmail.com wrote:
> From: uchan-nos <uchan0@gmail.com>

> 

> ---

>  newlib/libc/stdlib/efgcvt.c | 4 ++++

>  1 file changed, 4 insertions(+)

> 

> diff --git a/newlib/libc/stdlib/efgcvt.c b/newlib/libc/stdlib/efgcvt.c

> index 9314bf361..c1684f35a 100644

> --- a/newlib/libc/stdlib/efgcvt.c

> +++ b/newlib/libc/stdlib/efgcvt.c

> @@ -102,6 +102,8 @@ Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>,

>  #include <stdlib.h>

>  #include "local.h"

>  

> +#if __XSI_VISIBLE >= 4 && __POSIX_VISIBLE < 200112

> +

>  char *

>  fcvt (double d,

>  	int ndigit,

> @@ -163,3 +165,5 @@ gcvt (double d,

>    }

>    return (_gcvt (_REENT, d, ndigit, buf, 'g', 0) ? tbuf : 0);

>  }

> +

> +#endif // __XSI_VISIBLE >= 4 && __POSIX_VISIBLE < 200112


This patch is incorrect.  The C library must provide all possible
interfaces; guards are only intended for headers, to control what is
declared (and therefore available to userspace code) based on the
chosen standard(s).

-- 
Yaakov Selkowitz
Senior Software Engineer - Platform Enablement
Red Hat, Inc.

Patch

diff --git a/newlib/libc/stdlib/efgcvt.c b/newlib/libc/stdlib/efgcvt.c
index 9314bf361..c1684f35a 100644
--- a/newlib/libc/stdlib/efgcvt.c
+++ b/newlib/libc/stdlib/efgcvt.c
@@ -102,6 +102,8 @@  Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>,
 #include <stdlib.h>
 #include "local.h"
 
+#if __XSI_VISIBLE >= 4 && __POSIX_VISIBLE < 200112
+
 char *
 fcvt (double d,
 	int ndigit,
@@ -163,3 +165,5 @@  gcvt (double d,
   }
   return (_gcvt (_REENT, d, ndigit, buf, 'g', 0) ? tbuf : 0);
 }
+
+#endif // __XSI_VISIBLE >= 4 && __POSIX_VISIBLE < 200112