[PATCH 1/2] fix conflicting types (wint_t)

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

[PATCH 1/2] fix conflicting types (wint_t)

uchan0+newlib
From: uchan-nos <[hidden email]>

---
 newlib/libc/include/wchar.h  |  6 +++++-
 newlib/libc/string/wcwidth.c | 10 ++++++++--
 2 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/newlib/libc/include/wchar.h b/newlib/libc/include/wchar.h
index c04a6510e..a68cf5be6 100644
--- a/newlib/libc/include/wchar.h
+++ b/newlib/libc/include/wchar.h
@@ -179,8 +179,12 @@ extern size_t wcsxfrm_l (wchar_t *__restrict, const wchar_t *__restrict, size_t,
 #endif
 
 #if __XSI_VISIBLE
+# ifdef __CYGWIN__
+int wcwidth (const wint_t);
+# else
 int wcwidth (const wchar_t);
-#endif
+# endif
+#endif // __XSI_VISIBLE
 wchar_t *wmemchr (const wchar_t *, wchar_t, size_t);
 int wmemcmp (const wchar_t *, const wchar_t *, size_t);
 wchar_t *wmemcpy (wchar_t *__restrict, const wchar_t *__restrict,
diff --git a/newlib/libc/string/wcwidth.c b/newlib/libc/string/wcwidth.c
index 62e76edc3..a4b520bbe 100644
--- a/newlib/libc/string/wcwidth.c
+++ b/newlib/libc/string/wcwidth.c
@@ -225,10 +225,16 @@ __wcwidth (const wint_t ucs)
 #endif /* _MB_CAPABLE */
 }
 
+#ifdef __CYGWIN__
+#define WCHAR_TYPE wint_t
+#else
+#define WCHAR_TYPE wchar_t
+#endif
+
 int
-wcwidth (const wint_t wc)
+wcwidth (const WCHAR_TYPE wc)
 {
-  wint_t wi = wc;
+  WCHAR_TYPE wi = wc;
 
 #ifdef _MB_CAPABLE
   wi = _jp2uc (wi);
--
2.17.1

Reply | Threaded
Open this post in threaded view
|

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

uchan0+newlib
From: uchan-nos <[hidden email]>

---
 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
--
2.17.1

Reply | Threaded
Open this post in threaded view
|

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

Yaakov Selkowitz-2
On Tue, 2019-07-23 at 08:14 +0900, [hidden email] wrote:

> From: uchan-nos <[hidden email]>
>
> ---
>  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.