public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
From: Christian Franke <Christian.Franke@t-online.de>
To: cygwin@cygwin.com
Subject: Re: Add ability to hide non-standard itoa/utoa() in stdlib.h ?
Date: Mon, 22 Jan 2024 19:48:23 +0100	[thread overview]
Message-ID: <812d5c41-3ece-c49a-bcfd-52b39192b21c@t-online.de> (raw)
In-Reply-To: <Za6UC3WP3Ns7MzVD@calimero.vinschen.de>

Corinna Vinschen via Cygwin wrote:
> On Jan 22 16:47, Christian Franke via Cygwin wrote:
>> Busybox does not build OOTB on Cygwin due to the addition of itoa/utoa() to
>> newlib in 2014:
>> https://cygwin.com/git/?p=newlib-cygwin.git;a=commit;h=32c96dd
>>
>> This is because Busybox use local functions with same name but different
>> signature. This does not affect build on FreeBSD, Linux (glibc, musl libc),
>> ... because these functions simply do not exits there. For the busybox
>> Cygwin package, I use an ugly local hack to fix this.
>>
>> itoa() is mentioned as a non-standard extension here:
>> https://en.wikibooks.org/wiki/C_Programming/stdlib.h/itoa
>> https://cplusplus.com/reference/cstdlib/itoa/
>>
>> MSVC provides itoa() as a "POSIX version" of _itoa():
>> https://learn.microsoft.com/cpp/c-runtime-library/reference/itoa-itow
>>
>> But SUS-1997... POSIX-2018 do not mention these functions:
>> https://pubs.opengroup.org/onlinepubs/7908799/
>> https://pubs.opengroup.org/onlinepubs/9699919799/
>>
>> Newlib guards the prototypes with __MISC_VISIBLE in stdlib.h and
>> sys/features.h says:
>>
>>   * __MISC_VISIBLE
>>   *      Extensions found in both BSD and SVr4 (shorthand for
>>   *      (__BSD_VISIBLE || __SVID_VISIBLE)), or newlib-specific
>>   *      extensions; enabled by default.
>>
>> __MISC_VISIBLE is set if and only if _DEFAULT_SOURCE is set, so the comment
>> below should also include "... or newlib-specific extensions":
>>
>>   * _DEFAULT_SOURCE (or none of the above)
>>   *     POSIX-1.2008 with BSD and SVr4 extensions
>>
>>
>> The above is not suitable to disable only the non-standard functions for
>> such use cases. Using -D_GNU_SOURCE should IMO not enable functions
>> unavailable on Linux. This is not the case because _GNU_SOURCE implies
>> _DEFAULT_SOURCE.
>>
>> No patch provided for now, as I'm not yet sure how to handle this. Possibly:
>>
>> - Use __MISC_VISIBLE only for (__BSD_VISIBLE || __SVID_VISIBLE) - under the
>> assumption that this is applicable for most cases.
>> - Introduce __NONSTD_VISIBLE for non-standard functions like itoa().
>> - Introduce _NONSTD_SOURCE to set __NONSTD_VISIBLE independent from other
>> _*_SOURCE defines.
> Counter proposal:
>
> First of all, Cygwin does NOT export itoa/utoa!  Only the prototypes
> exist from the Cygwin POV.

Thanks, I missed that.


> As Cygwin is usually the only newlib project with backward compat
> issues, we have two simple choices:
>
> - Drop itoa/utoa entirely, or
> - just guard them with
>
>      #if __MISC_VISIBLE && !defined (__CYGWIN__)
>
> You can make a proposal like that on the newlib list and then we can
> discuss it there, ok?

Done.


      reply	other threads:[~2024-01-22 18:48 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-22 15:47 Christian Franke
2024-01-22 16:12 ` Corinna Vinschen
2024-01-22 18:48   ` Christian Franke [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=812d5c41-3ece-c49a-bcfd-52b39192b21c@t-online.de \
    --to=christian.franke@t-online.de \
    --cc=cygwin@cygwin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).