All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] configure: Define NCURSES_WIDECHAR if we're using curses
@ 2017-06-02 14:35 Peter Maydell
  2017-06-02 21:58 ` Laszlo Ersek
                   ` (3 more replies)
  0 siblings, 4 replies; 10+ messages in thread
From: Peter Maydell @ 2017-06-02 14:35 UTC (permalink / raw)
  To: qemu-devel
  Cc: patches, Chad Joan, Paolo Bonzini, Laszlo Ersek, Rainer Müller

We want the wide character functions from the ncurses header.
Unfortunately it doesn't provide them by default, but only
if either:
 * NCURSES_WIDECHAR is defined (for ncurses 20111030 and up)
 * _XOPEN_SOURCE/_XOPEN_SOURCE_EXTENDED are suitably defined

So far we have been implicitly relying on the latter, because
for GNU libc when we define _GNU_SOURCE this causes libc
to define the _XOPEN_SOURCE macros for us. Unfortunately
this doesn't work on all libcs, because some (like OSX and
musl libc) do not define _XOPEN_SOURCE when _GNU_SOURCE
is defined.

We can't fix this by defining _XOPEN_SOURCE ourselves, because
that also means "and don't provide any functions that aren't in
that standard", and not all libcs provide any way to override
that to also get the non-standard functions. In particular
FreeBSD has no such mechanism, and OSX's _DARWIN_C_SOURCE
doesn't reenable everything (for instance getpagesize()
is still not prototyped if _DARWIN_C_SOURCE and _XOPEN_SOURCE
are both defined).

So we have to define NCURSES_WIDECHAR. (This will only work
if your ncurses is at least 20111030, as older versions
don't honour this macro.)

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
Testing from the people with musl libc and OSX-with-ncurses
appreciated, as I don't have any systems which have the bug
which this patch is attempting to fix...

 configure | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/configure b/configure
index 0586ec9..6aca5d1 100755
--- a/configure
+++ b/configure
@@ -3053,6 +3053,8 @@ int main(void) {
 EOF
   IFS=:
   for curses_inc in $curses_inc_list; do
+    # Make sure we get the wide character prototypes
+    curses_inc="-DNCURSES_WIDECHAR $curses_inc"
     IFS=:
     for curses_lib in $curses_lib_list; do
       unset IFS
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [Qemu-devel] [PATCH] configure: Define NCURSES_WIDECHAR if we're using curses
  2017-06-02 14:35 [Qemu-devel] [PATCH] configure: Define NCURSES_WIDECHAR if we're using curses Peter Maydell
@ 2017-06-02 21:58 ` Laszlo Ersek
  2017-06-03  9:43   ` Kamil Rytarowski
  2017-06-03 10:13 ` Rainer Müller
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 10+ messages in thread
From: Laszlo Ersek @ 2017-06-02 21:58 UTC (permalink / raw)
  To: Peter Maydell, qemu-devel
  Cc: patches, Chad Joan, Paolo Bonzini, Rainer Müller

On 06/02/17 16:35, Peter Maydell wrote:
> We want the wide character functions from the ncurses header.
> Unfortunately it doesn't provide them by default, but only
> if either:
>  * NCURSES_WIDECHAR is defined (for ncurses 20111030 and up)
>  * _XOPEN_SOURCE/_XOPEN_SOURCE_EXTENDED are suitably defined
> 
> So far we have been implicitly relying on the latter, because
> for GNU libc when we define _GNU_SOURCE this causes libc
> to define the _XOPEN_SOURCE macros for us. Unfortunately
> this doesn't work on all libcs, because some (like OSX and
> musl libc) do not define _XOPEN_SOURCE when _GNU_SOURCE
> is defined.
> 
> We can't fix this by defining _XOPEN_SOURCE ourselves, because
> that also means "and don't provide any functions that aren't in
> that standard", and not all libcs provide any way to override
> that to also get the non-standard functions. In particular
> FreeBSD has no such mechanism, and OSX's _DARWIN_C_SOURCE
> doesn't reenable everything (for instance getpagesize()
> is still not prototyped if _DARWIN_C_SOURCE and _XOPEN_SOURCE
> are both defined).
> 
> So we have to define NCURSES_WIDECHAR. (This will only work
> if your ncurses is at least 20111030, as older versions
> don't honour this macro.)
> 
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
> Testing from the people with musl libc and OSX-with-ncurses
> appreciated, as I don't have any systems which have the bug
> which this patch is attempting to fix...
> 
>  configure | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/configure b/configure
> index 0586ec9..6aca5d1 100755
> --- a/configure
> +++ b/configure
> @@ -3053,6 +3053,8 @@ int main(void) {
>  EOF
>    IFS=:
>    for curses_inc in $curses_inc_list; do
> +    # Make sure we get the wide character prototypes
> +    curses_inc="-DNCURSES_WIDECHAR $curses_inc"
>      IFS=:
>      for curses_lib in $curses_lib_list; do
>        unset IFS
> 

Given that we're already consciously using non-portable functions, this
solution looks the least messy to me.

Acked-by: Laszlo Ersek <lersek@redhat.com>

Thanks
Laszlo

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Qemu-devel] [PATCH] configure: Define NCURSES_WIDECHAR if we're using curses
  2017-06-02 21:58 ` Laszlo Ersek
@ 2017-06-03  9:43   ` Kamil Rytarowski
  2017-06-03 16:08     ` Laszlo Ersek
  0 siblings, 1 reply; 10+ messages in thread
From: Kamil Rytarowski @ 2017-06-03  9:43 UTC (permalink / raw)
  To: Laszlo Ersek, Peter Maydell, qemu-devel
  Cc: Paolo Bonzini, Chad Joan, Rainer Müller, patches

[-- Attachment #1: Type: text/plain, Size: 2422 bytes --]

On 02.06.2017 23:58, Laszlo Ersek wrote:
> On 06/02/17 16:35, Peter Maydell wrote:
>> We want the wide character functions from the ncurses header.
>> Unfortunately it doesn't provide them by default, but only
>> if either:
>>  * NCURSES_WIDECHAR is defined (for ncurses 20111030 and up)
>>  * _XOPEN_SOURCE/_XOPEN_SOURCE_EXTENDED are suitably defined
>>
>> So far we have been implicitly relying on the latter, because
>> for GNU libc when we define _GNU_SOURCE this causes libc
>> to define the _XOPEN_SOURCE macros for us. Unfortunately
>> this doesn't work on all libcs, because some (like OSX and
>> musl libc) do not define _XOPEN_SOURCE when _GNU_SOURCE
>> is defined.
>>
>> We can't fix this by defining _XOPEN_SOURCE ourselves, because
>> that also means "and don't provide any functions that aren't in
>> that standard", and not all libcs provide any way to override
>> that to also get the non-standard functions. In particular
>> FreeBSD has no such mechanism, and OSX's _DARWIN_C_SOURCE
>> doesn't reenable everything (for instance getpagesize()
>> is still not prototyped if _DARWIN_C_SOURCE and _XOPEN_SOURCE
>> are both defined).
>>
>> So we have to define NCURSES_WIDECHAR. (This will only work
>> if your ncurses is at least 20111030, as older versions
>> don't honour this macro.)
>>
>> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
>> ---
>> Testing from the people with musl libc and OSX-with-ncurses
>> appreciated, as I don't have any systems which have the bug
>> which this patch is attempting to fix...
>>
>>  configure | 2 ++
>>  1 file changed, 2 insertions(+)
>>
>> diff --git a/configure b/configure
>> index 0586ec9..6aca5d1 100755
>> --- a/configure
>> +++ b/configure
>> @@ -3053,6 +3053,8 @@ int main(void) {
>>  EOF
>>    IFS=:
>>    for curses_inc in $curses_inc_list; do
>> +    # Make sure we get the wide character prototypes
>> +    curses_inc="-DNCURSES_WIDECHAR $curses_inc"
>>      IFS=:
>>      for curses_lib in $curses_lib_list; do
>>        unset IFS
>>
> 
> Given that we're already consciously using non-portable functions, this
> solution looks the least messy to me.
> 

These functions are enough portable to work on NetBSD curses(3).

pkgsrc had an equivalent patch to define NCURSES_WIDECHAR=1 to fix build
on Darwin.

> Acked-by: Laszlo Ersek <lersek@redhat.com>
> 
> Thanks
> Laszlo
> 



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Qemu-devel] [PATCH] configure: Define NCURSES_WIDECHAR if we're using curses
  2017-06-02 14:35 [Qemu-devel] [PATCH] configure: Define NCURSES_WIDECHAR if we're using curses Peter Maydell
  2017-06-02 21:58 ` Laszlo Ersek
@ 2017-06-03 10:13 ` Rainer Müller
  2017-06-03 10:17   ` Kamil Rytarowski
  2017-06-26 13:31 ` Peter Maydell
  2021-06-06 18:13 ` Stefan Weil
  3 siblings, 1 reply; 10+ messages in thread
From: Rainer Müller @ 2017-06-03 10:13 UTC (permalink / raw)
  To: Peter Maydell, qemu-devel; +Cc: patches, Chad Joan, Paolo Bonzini, Laszlo Ersek

On 2017-06-02 16:35, Peter Maydell wrote:
> diff --git a/configure b/configure
> index 0586ec9..6aca5d1 100755
> --- a/configure
> +++ b/configure
> @@ -3053,6 +3053,8 @@ int main(void) {
>  EOF
>    IFS=:
>    for curses_inc in $curses_inc_list; do
> +    # Make sure we get the wide character prototypes
> +    curses_inc="-DNCURSES_WIDECHAR $curses_inc"
>      IFS=:
>      for curses_lib in $curses_lib_list; do
>        unset IFS
> 

Thank you for getting back to this. I can confirm that this patch fixes
--enable-curses for me on Mac OS X.

Although this already works as is, I would use -DNCURSES_WIDECHAR=1 as
ncurses.h uses #if and not #ifdef to check for this.

Rainer

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Qemu-devel] [PATCH] configure: Define NCURSES_WIDECHAR if we're using curses
  2017-06-03 10:13 ` Rainer Müller
@ 2017-06-03 10:17   ` Kamil Rytarowski
  0 siblings, 0 replies; 10+ messages in thread
From: Kamil Rytarowski @ 2017-06-03 10:17 UTC (permalink / raw)
  To: Rainer Müller, Peter Maydell, qemu-devel
  Cc: Paolo Bonzini, Chad Joan, Laszlo Ersek, patches

[-- Attachment #1: Type: text/plain, Size: 833 bytes --]

On 03.06.2017 12:13, Rainer Müller wrote:
> On 2017-06-02 16:35, Peter Maydell wrote:
>> diff --git a/configure b/configure
>> index 0586ec9..6aca5d1 100755
>> --- a/configure
>> +++ b/configure
>> @@ -3053,6 +3053,8 @@ int main(void) {
>>  EOF
>>    IFS=:
>>    for curses_inc in $curses_inc_list; do
>> +    # Make sure we get the wide character prototypes
>> +    curses_inc="-DNCURSES_WIDECHAR $curses_inc"
>>      IFS=:
>>      for curses_lib in $curses_lib_list; do
>>        unset IFS
>>
> 
> Thank you for getting back to this. I can confirm that this patch fixes
> --enable-curses for me on Mac OS X.
> 
> Although this already works as is, I would use -DNCURSES_WIDECHAR=1 as
> ncurses.h uses #if and not #ifdef to check for this.
> 

-DNCURSES_WIDECHAR evaluates to 1 for #if

> Rainer
> 



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Qemu-devel] [PATCH] configure: Define NCURSES_WIDECHAR if we're using curses
  2017-06-03  9:43   ` Kamil Rytarowski
@ 2017-06-03 16:08     ` Laszlo Ersek
  0 siblings, 0 replies; 10+ messages in thread
From: Laszlo Ersek @ 2017-06-03 16:08 UTC (permalink / raw)
  To: Kamil Rytarowski, Peter Maydell, qemu-devel
  Cc: Paolo Bonzini, Chad Joan, Rainer Müller, patches

On 06/03/17 11:43, Kamil Rytarowski wrote:
> On 02.06.2017 23:58, Laszlo Ersek wrote:
>> On 06/02/17 16:35, Peter Maydell wrote:
>>> We want the wide character functions from the ncurses header.
>>> Unfortunately it doesn't provide them by default, but only
>>> if either:
>>>  * NCURSES_WIDECHAR is defined (for ncurses 20111030 and up)
>>>  * _XOPEN_SOURCE/_XOPEN_SOURCE_EXTENDED are suitably defined
>>>
>>> So far we have been implicitly relying on the latter, because
>>> for GNU libc when we define _GNU_SOURCE this causes libc
>>> to define the _XOPEN_SOURCE macros for us. Unfortunately
>>> this doesn't work on all libcs, because some (like OSX and
>>> musl libc) do not define _XOPEN_SOURCE when _GNU_SOURCE
>>> is defined.
>>>
>>> We can't fix this by defining _XOPEN_SOURCE ourselves, because
>>> that also means "and don't provide any functions that aren't in
>>> that standard", and not all libcs provide any way to override
>>> that to also get the non-standard functions. In particular
>>> FreeBSD has no such mechanism, and OSX's _DARWIN_C_SOURCE
>>> doesn't reenable everything (for instance getpagesize()
>>> is still not prototyped if _DARWIN_C_SOURCE and _XOPEN_SOURCE
>>> are both defined).
>>>
>>> So we have to define NCURSES_WIDECHAR. (This will only work
>>> if your ncurses is at least 20111030, as older versions
>>> don't honour this macro.)
>>>
>>> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
>>> ---
>>> Testing from the people with musl libc and OSX-with-ncurses
>>> appreciated, as I don't have any systems which have the bug
>>> which this patch is attempting to fix...
>>>
>>>  configure | 2 ++
>>>  1 file changed, 2 insertions(+)
>>>
>>> diff --git a/configure b/configure
>>> index 0586ec9..6aca5d1 100755
>>> --- a/configure
>>> +++ b/configure
>>> @@ -3053,6 +3053,8 @@ int main(void) {
>>>  EOF
>>>    IFS=:
>>>    for curses_inc in $curses_inc_list; do
>>> +    # Make sure we get the wide character prototypes
>>> +    curses_inc="-DNCURSES_WIDECHAR $curses_inc"
>>>      IFS=:
>>>      for curses_lib in $curses_lib_list; do
>>>        unset IFS
>>>
>>
>> Given that we're already consciously using non-portable functions,
>> this solution looks the least messy to me.
>>
>
> These functions are enough portable to work on NetBSD curses(3).

Sorry, that's not what I meant by "non-portable functions".

Peter wrote,

>>> We can't fix this by defining _XOPEN_SOURCE ourselves, because
>>> that also means "and don't provide any functions that aren't in
>>> that standard", and not all libcs provide any way to override
>>> that to also get the non-standard functions.

So basically, if we only used standard (SUSv2, SUSv3 or SUSv4, i.e.
_XOPEN_SOURCE=500, =600 or =700) functions, then the wide char curses
functions could also be declared just through _XOPEN_SOURCE:

  http://pubs.opengroup.org/onlinepubs/007908799/xcurses/implement.html

(

Note that X/Open Curses, Issue 4 Version 2, does provide the wide char
stuff; see for example the add_wch() function at
<http://pubs.opengroup.org/onlinepubs/007908799/xcurses/add_wch.html>,
and my "/usr/include/curses.h" has:

  #ifndef NCURSES_WIDECHAR
  #if defined(_XOPEN_SOURCE_EXTENDED) || (defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE - 0 >= 500))
  #define NCURSES_WIDECHAR 1
  #else
  #define NCURSES_WIDECHAR 0
  #endif
  #endif /* NCURSES_WIDECHAR */
  ...
  #if NCURSES_WIDECHAR
  ...
  extern NCURSES_EXPORT(int) add_wch (const cchar_t *);                   /* generated:WIDEC */

)

Since we can't use _XOPEN_SOURCE (because of our reliance on non-std
functions), we have to go with "whatever works" (basically abandoning
any benefit that the SUS / POSIX standardization brings), and then
NCURSES_WIDECHAR looks simple enough.

Thanks
Laszlo

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Qemu-devel] [PATCH] configure: Define NCURSES_WIDECHAR if we're using curses
  2017-06-02 14:35 [Qemu-devel] [PATCH] configure: Define NCURSES_WIDECHAR if we're using curses Peter Maydell
  2017-06-02 21:58 ` Laszlo Ersek
  2017-06-03 10:13 ` Rainer Müller
@ 2017-06-26 13:31 ` Peter Maydell
  2021-06-06 18:13 ` Stefan Weil
  3 siblings, 0 replies; 10+ messages in thread
From: Peter Maydell @ 2017-06-26 13:31 UTC (permalink / raw)
  To: QEMU Developers
  Cc: Paolo Bonzini, Chad Joan, Laszlo Ersek, Rainer Müller, patches

On 2 June 2017 at 15:35, Peter Maydell <peter.maydell@linaro.org> wrote:
> We want the wide character functions from the ncurses header.
> Unfortunately it doesn't provide them by default, but only
> if either:
>  * NCURSES_WIDECHAR is defined (for ncurses 20111030 and up)
>  * _XOPEN_SOURCE/_XOPEN_SOURCE_EXTENDED are suitably defined
>
> So far we have been implicitly relying on the latter, because
> for GNU libc when we define _GNU_SOURCE this causes libc
> to define the _XOPEN_SOURCE macros for us. Unfortunately
> this doesn't work on all libcs, because some (like OSX and
> musl libc) do not define _XOPEN_SOURCE when _GNU_SOURCE
> is defined.
>
> We can't fix this by defining _XOPEN_SOURCE ourselves, because
> that also means "and don't provide any functions that aren't in
> that standard", and not all libcs provide any way to override
> that to also get the non-standard functions. In particular
> FreeBSD has no such mechanism, and OSX's _DARWIN_C_SOURCE
> doesn't reenable everything (for instance getpagesize()
> is still not prototyped if _DARWIN_C_SOURCE and _XOPEN_SOURCE
> are both defined).
>
> So we have to define NCURSES_WIDECHAR. (This will only work
> if your ncurses is at least 20111030, as older versions
> don't honour this macro.)
>
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>

Applied, thanks.

-- PMM

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Qemu-devel] [PATCH] configure: Define NCURSES_WIDECHAR if we're using curses
  2017-06-02 14:35 [Qemu-devel] [PATCH] configure: Define NCURSES_WIDECHAR if we're using curses Peter Maydell
                   ` (2 preceding siblings ...)
  2017-06-26 13:31 ` Peter Maydell
@ 2021-06-06 18:13 ` Stefan Weil
  2021-06-07 12:57   ` Laszlo Ersek
  3 siblings, 1 reply; 10+ messages in thread
From: Stefan Weil @ 2021-06-06 18:13 UTC (permalink / raw)
  To: Peter Maydell, qemu-devel
  Cc: Paolo Bonzini, patches, Laszlo Ersek, Rainer Müller, Chad Joan

Am 02.06.17 um 16:35 schrieb Peter Maydell:

> We want the wide character functions from the ncurses header.
> Unfortunately it doesn't provide them by default, but only
> if either:
>   * NCURSES_WIDECHAR is defined (for ncurses 20111030 and up)
>   * _XOPEN_SOURCE/_XOPEN_SOURCE_EXTENDED are suitably defined
>
> So far we have been implicitly relying on the latter, because
> for GNU libc when we define _GNU_SOURCE this causes libc
> to define the _XOPEN_SOURCE macros for us. Unfortunately
> this doesn't work on all libcs, because some (like OSX and
> musl libc) do not define _XOPEN_SOURCE when _GNU_SOURCE
> is defined.
>
> We can't fix this by defining _XOPEN_SOURCE ourselves, because
> that also means "and don't provide any functions that aren't in
> that standard", and not all libcs provide any way to override
> that to also get the non-standard functions. In particular
> FreeBSD has no such mechanism, and OSX's _DARWIN_C_SOURCE
> doesn't reenable everything (for instance getpagesize()
> is still not prototyped if _DARWIN_C_SOURCE and _XOPEN_SOURCE
> are both defined).
>
> So we have to define NCURSES_WIDECHAR. (This will only work
> if your ncurses is at least 20111030, as older versions
> don't honour this macro.)


I answer to this very old e-mail because I noticed today that defining 
NCURSES_WIDECHAR does not work with the latest MacOS on M1:

Apple still delivers a curses.h which indicates NCURSES_VERSION "5.7" 
(20081102). It does not know NCURSES_WIDECHAR, but support for curses 
can be enabled with _XOPEN_SOURCE_EXTENDED=1.

I used this patch for git master:

diff --git a/meson.build b/meson.build
index 626cf932c1..513332a76d 100644
--- a/meson.build
+++ b/meson.build
@@ -606,7 +606,7 @@ if have_system and not get_option('curses').disabled()
      endif
    endforeach
    msg = get_option('curses').enabled() ? 'curses library not found' : ''
-  curses_compile_args = ['-DNCURSES_WIDECHAR']
+  curses_compile_args = ['-DNCURSES_WIDECHAR', 
'-D_XOPEN_SOURCE_EXTENDED=1']
    if curses.found()
      if cc.links(curses_test, args: curses_compile_args, dependencies: 
[curses])
        curses = declare_dependency(compile_args: curses_compile_args, 
dependencies: [curses])


Then curses is detected and works when configure is given the right 
PKG_CONFIG_PATH:

PKG_CONFIG_PATH=/opt/homebrew/Library/Homebrew/os/mac/pkgconfig/11 
./configure

Regards

Stefan




^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [Qemu-devel] [PATCH] configure: Define NCURSES_WIDECHAR if we're using curses
  2021-06-06 18:13 ` Stefan Weil
@ 2021-06-07 12:57   ` Laszlo Ersek
  2021-06-07 13:05     ` Daniel P. Berrangé
  0 siblings, 1 reply; 10+ messages in thread
From: Laszlo Ersek @ 2021-06-07 12:57 UTC (permalink / raw)
  To: Stefan Weil, Peter Maydell, qemu-devel
  Cc: Paolo Bonzini, patches, Rainer Müller, Chad Joan

On 06/06/21 20:13, Stefan Weil wrote:
> Am 02.06.17 um 16:35 schrieb Peter Maydell:
> 
>> We want the wide character functions from the ncurses header.
>> Unfortunately it doesn't provide them by default, but only
>> if either:
>>   * NCURSES_WIDECHAR is defined (for ncurses 20111030 and up)
>>   * _XOPEN_SOURCE/_XOPEN_SOURCE_EXTENDED are suitably defined
>>
>> So far we have been implicitly relying on the latter, because
>> for GNU libc when we define _GNU_SOURCE this causes libc
>> to define the _XOPEN_SOURCE macros for us. Unfortunately
>> this doesn't work on all libcs, because some (like OSX and
>> musl libc) do not define _XOPEN_SOURCE when _GNU_SOURCE
>> is defined.
>>
>> We can't fix this by defining _XOPEN_SOURCE ourselves, because
>> that also means "and don't provide any functions that aren't in
>> that standard", and not all libcs provide any way to override
>> that to also get the non-standard functions. In particular
>> FreeBSD has no such mechanism, and OSX's _DARWIN_C_SOURCE
>> doesn't reenable everything (for instance getpagesize()
>> is still not prototyped if _DARWIN_C_SOURCE and _XOPEN_SOURCE
>> are both defined).
>>
>> So we have to define NCURSES_WIDECHAR. (This will only work
>> if your ncurses is at least 20111030, as older versions
>> don't honour this macro.)
> 
> 
> I answer to this very old e-mail because I noticed today that defining
> NCURSES_WIDECHAR does not work with the latest MacOS on M1:
> 
> Apple still delivers a curses.h which indicates NCURSES_VERSION "5.7"
> (20081102). It does not know NCURSES_WIDECHAR, but support for curses
> can be enabled with _XOPEN_SOURCE_EXTENDED=1.
> 
> I used this patch for git master:
> 
> diff --git a/meson.build b/meson.build
> index 626cf932c1..513332a76d 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -606,7 +606,7 @@ if have_system and not get_option('curses').disabled()
>      endif
>    endforeach
>    msg = get_option('curses').enabled() ? 'curses library not found' : ''
> -  curses_compile_args = ['-DNCURSES_WIDECHAR']
> +  curses_compile_args = ['-DNCURSES_WIDECHAR',
> '-D_XOPEN_SOURCE_EXTENDED=1']
>    if curses.found()
>      if cc.links(curses_test, args: curses_compile_args, dependencies:
> [curses])
>        curses = declare_dependency(compile_args: curses_compile_args,
> dependencies: [curses])
> 
> 
> Then curses is detected and works when configure is given the right
> PKG_CONFIG_PATH:
> 
> PKG_CONFIG_PATH=/opt/homebrew/Library/Homebrew/os/mac/pkgconfig/11
> ./configure

_XOPEN_SOURCE_EXTENDED is only supposed to make a difference in SUSv2.
If MacOS needs it, whatever, but I don't view it as a good idea for any
other host OS.

Just my two cents, since I've been CC'd.

Laszlo



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Qemu-devel] [PATCH] configure: Define NCURSES_WIDECHAR if we're using curses
  2021-06-07 12:57   ` Laszlo Ersek
@ 2021-06-07 13:05     ` Daniel P. Berrangé
  0 siblings, 0 replies; 10+ messages in thread
From: Daniel P. Berrangé @ 2021-06-07 13:05 UTC (permalink / raw)
  To: Laszlo Ersek
  Cc: Peter Maydell, patches, Stefan Weil, Chad Joan, qemu-devel,
	Rainer Müller, Paolo Bonzini

On Mon, Jun 07, 2021 at 02:57:41PM +0200, Laszlo Ersek wrote:
> On 06/06/21 20:13, Stefan Weil wrote:
> > Am 02.06.17 um 16:35 schrieb Peter Maydell:
> > 
> >> We want the wide character functions from the ncurses header.
> >> Unfortunately it doesn't provide them by default, but only
> >> if either:
> >>   * NCURSES_WIDECHAR is defined (for ncurses 20111030 and up)
> >>   * _XOPEN_SOURCE/_XOPEN_SOURCE_EXTENDED are suitably defined
> >>
> >> So far we have been implicitly relying on the latter, because
> >> for GNU libc when we define _GNU_SOURCE this causes libc
> >> to define the _XOPEN_SOURCE macros for us. Unfortunately
> >> this doesn't work on all libcs, because some (like OSX and
> >> musl libc) do not define _XOPEN_SOURCE when _GNU_SOURCE
> >> is defined.
> >>
> >> We can't fix this by defining _XOPEN_SOURCE ourselves, because
> >> that also means "and don't provide any functions that aren't in
> >> that standard", and not all libcs provide any way to override
> >> that to also get the non-standard functions. In particular
> >> FreeBSD has no such mechanism, and OSX's _DARWIN_C_SOURCE
> >> doesn't reenable everything (for instance getpagesize()
> >> is still not prototyped if _DARWIN_C_SOURCE and _XOPEN_SOURCE
> >> are both defined).
> >>
> >> So we have to define NCURSES_WIDECHAR. (This will only work
> >> if your ncurses is at least 20111030, as older versions
> >> don't honour this macro.)
> > 
> > 
> > I answer to this very old e-mail because I noticed today that defining
> > NCURSES_WIDECHAR does not work with the latest MacOS on M1:
> > 
> > Apple still delivers a curses.h which indicates NCURSES_VERSION "5.7"
> > (20081102). It does not know NCURSES_WIDECHAR, but support for curses
> > can be enabled with _XOPEN_SOURCE_EXTENDED=1.
> > 
> > I used this patch for git master:
> > 
> > diff --git a/meson.build b/meson.build
> > index 626cf932c1..513332a76d 100644
> > --- a/meson.build
> > +++ b/meson.build
> > @@ -606,7 +606,7 @@ if have_system and not get_option('curses').disabled()
> >      endif
> >    endforeach
> >    msg = get_option('curses').enabled() ? 'curses library not found' : ''
> > -  curses_compile_args = ['-DNCURSES_WIDECHAR']
> > +  curses_compile_args = ['-DNCURSES_WIDECHAR',
> > '-D_XOPEN_SOURCE_EXTENDED=1']
> >    if curses.found()
> >      if cc.links(curses_test, args: curses_compile_args, dependencies:
> > [curses])
> >        curses = declare_dependency(compile_args: curses_compile_args,
> > dependencies: [curses])
> > 
> > 
> > Then curses is detected and works when configure is given the right
> > PKG_CONFIG_PATH:
> > 
> > PKG_CONFIG_PATH=/opt/homebrew/Library/Homebrew/os/mac/pkgconfig/11
> > ./configure
> 
> _XOPEN_SOURCE_EXTENDED is only supposed to make a difference in SUSv2.
> If MacOS needs it, whatever, but I don't view it as a good idea for any
> other host OS.

Easy to do with

  if host_machine.system() == 'darwin'
    curses_compile_args = [ '-D_XOPEN_SOURCE_EXTENDED=1']
  else
    curses_compile_args = ['-DNCURSES_WIDECHAR']
  endif

Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|



^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2021-06-07 13:08 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-02 14:35 [Qemu-devel] [PATCH] configure: Define NCURSES_WIDECHAR if we're using curses Peter Maydell
2017-06-02 21:58 ` Laszlo Ersek
2017-06-03  9:43   ` Kamil Rytarowski
2017-06-03 16:08     ` Laszlo Ersek
2017-06-03 10:13 ` Rainer Müller
2017-06-03 10:17   ` Kamil Rytarowski
2017-06-26 13:31 ` Peter Maydell
2021-06-06 18:13 ` Stefan Weil
2021-06-07 12:57   ` Laszlo Ersek
2021-06-07 13:05     ` Daniel P. Berrangé

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.