public inbox for newlib@sourceware.org
 help / color / mirror / Atom feed
From: Christian Franke <Christian.Franke@t-online.de>
To: newlib@sourceware.org
Subject: Re: Hide non-standard itoa/utoa() in stdlib.h or drop these functions?
Date: Sun, 28 Jan 2024 13:52:05 +0100	[thread overview]
Message-ID: <0cbff769-04c0-210b-e832-9886fb252da6@t-online.de> (raw)
In-Reply-To: <ZbDxmNcj0hF5l-CH@calimero.vinschen.de>

Corinna Vinschen wrote:
> On Jan 24 10:42, Christian Franke wrote:
>> brian.inglis@systematicsw.ab.ca wrote:
>>> On 2024-01-23 02:03, Corinna Vinschen wrote:
>>>> On Jan 22 19:46, Christian Franke wrote:
>>>>> The functions itoa() and utoa() are non-standard, not exported
>>>>> by Cygwin and
>>>>> also unavailable on FreeBSD and Linux (glibc and musl libc).
>>>>> Busybox for
>>>>> example could not be build OOTB using newlib's stdlib.h because
>>>>> there are
>>>>> conflicts with local functions with same names but different
>>>>> signatures.
>>>>> [...]
>>>> Does anybody actually *need* itoa/utoa as long as we have __itoa/__utoa?
>>> Unix 1st ed Manual defined itoa as did K&R on p60 (/p64 2ed); at least
>>> IBM and QNX and "some compilers" provide itoa and others:
>>>
>>>      https://cplusplus.com/reference/cstdlib/itoa/
>>>
>>> other libraries also provide {,u}{,l}ltoa.
>> This page suggests that at least the K&R version was different (no radix
>> parameter):
>> https://en.wikibooks.org/wiki/C_Programming/stdlib.h/itoa
> Also, the fact that it has been mentioned in K&R was apparently no
> incentive to standarize it later on.  That's why its existence on
> various systems is a bit erratic.
>
>>> Newlib provided the function and man pages, which should be updated to
>>> reflect the changed situation, as they will have been used, and users
>>> will want to know what happened and what to do e.g. use prefixed
>>> functions, #define, sprintf(3), etc.
> Mind, I never said to remove the underscored functins.  So the
> functionality still exists, it's just called __foo instead of foo.
>
>>> Downstream systems should note the change in their lists of supported
>>> functions, and in their release notes.
> We don't have any influence on downstream, but if downstream wants the
> API, it's easy to provide it by aliasing foo to __foo in a downstream
> header.
>
>> Newlib should IMO at least provide an easy way to hide the [iu]toa()
>> prototypes without hiding other BSD or GNU extensions. The prototypes should
>> not be visible if for example _GNU_SOURCE is defined and no other _*_SOURCE.
>> This is currently not possible. Such a change would possibly require only
>> minor documentation updates.
> The problem is that _GNU_SOURCE got synonymous for "everything and the
> kitchen sink", and there's no blessed way around that other than
> defining another source standard instead.

My interpretation was "everything and the kitchen sink - except 
everything never provided by glibc or Linux" :-)


> Do we really want to create our own kind of "this is
> non-standard"-standard?
>
> That would be something like __NEWLIB_VISIBLE / _NEWLIB_SOURCE.
>
> But, then again, for just two seldom used APIs?

The API is seldom used, possibly not or no longer well known and 
definitely unavailable in widely used other C libs. This increases the 
risk of a conflict with local functions with the same name. Busybox is a 
real world example.

If it will be decided to keep this API as is, please consider to accept 
my patch from the start of this thread. It IMO obviously makes sense 
because Cygwin does not provide this API. This could at least simplify 
my patch for the busybox Cygwin package and may increase the probability 
that it will be accepted by busybox upstream.


  parent reply	other threads:[~2024-01-28 12:52 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-22 18:46 Christian Franke
2024-01-23  9:03 ` Corinna Vinschen
     [not found]   ` <BN2P110MB154497B2775D2D45D55C91009A74A@BN2P110MB1544.NAMP110.PROD.OUTLOOK.COM>
2024-01-23 16:05     ` Fw: " C Howland
2024-01-23 21:41   ` brian.inglis
2024-01-24  9:42     ` Christian Franke
2024-01-24 11:16       ` Corinna Vinschen
2024-01-24 18:08         ` brian.inglis
2024-01-28 12:52         ` Christian Franke [this message]
2024-01-29 12:56           ` Corinna Vinschen
2024-01-29 14:17             ` Christian Franke
2024-01-29 15:31               ` Corinna Vinschen
2024-01-31 19:08 ` Corinna Vinschen

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=0cbff769-04c0-210b-e832-9886fb252da6@t-online.de \
    --to=christian.franke@t-online.de \
    --cc=newlib@sourceware.org \
    /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).