From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mailout10.t-online.de (mailout10.t-online.de [194.25.134.21]) by sourceware.org (Postfix) with ESMTPS id 9BB473858C29 for ; Wed, 24 Jan 2024 09:42:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9BB473858C29 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=t-online.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=t-online.de ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 9BB473858C29 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=194.25.134.21 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1706089340; cv=none; b=HaXu4Wy62Jp2cHfLOZTIBvLQTfhmyC75jhWoDMI5joP6SUr3CYPwnChcQ4c/j4L5q4S2LBh6eszkmdQOx5bA/iI8SFuNy7UYPEZ3rqp2goM4EZkpNK/pwj6WkGnyBQDojLA8wBmryVx7adoKrScBZsfkukcEqXiDt+m7BZ0G4h4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1706089340; c=relaxed/simple; bh=G36YTes5e5pk1qZ68NL81gHaygG2xX/DU+hse/vBQI8=; h=Subject:To:From:Message-ID:Date:MIME-Version; b=xuWZ7MnlK4lLjV6ssIiwlvtV6xDGVQnEGsVFGMe2FtkGWLEOt7YlN/3m99jjE/qKOTd50K62q2xm+0dHYnRUmnPKnVH7jDWvP1Qsh6Q1X5xV9Cz7gWOqXh3B/eAxruMY/42Yh7krQ4gGEry035TA3YWa2v3XMAPmcPsrVDbWsQo= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from fwd82.aul.t-online.de (fwd82.aul.t-online.de [10.223.144.108]) by mailout10.t-online.de (Postfix) with SMTP id 079789C5A for ; Wed, 24 Jan 2024 10:42:16 +0100 (CET) Received: from [192.168.2.104] ([79.230.174.55]) by fwd82.t-online.de with (TLSv1.3:TLS_AES_256_GCM_SHA384 encrypted) esmtp id 1rSZlt-0Ndviy0; Wed, 24 Jan 2024 10:42:13 +0100 Subject: Re: Hide non-standard itoa/utoa() in stdlib.h or drop these functions? To: newlib@sourceware.org References: <83962310-aec8-a718-bafb-6e10703693b8@t-online.de> From: Christian Franke Message-ID: <90bedd49-bed9-0c6d-fd89-a94241b0dd4f@t-online.de> Date: Wed, 24 Jan 2024 10:42:11 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 SeaMonkey/2.53.16 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-TOI-EXPURGATEID: 150726::1706089333-F67FB954-04A23D03/0/0 CLEAN NORMAL X-TOI-MSGID: c8952871-0cc7-43a3-9e07-1ca9911ab4e6 X-Spam-Status: No, score=-10.4 required=5.0 tests=BAYES_00,BODY_8BITS,FREEMAIL_FROM,GIT_PATCH_0,KAM_DMARC_STATUS,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: 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. >>> >>> See the original posts on the Cygwin list for more details: >>> https://sourceware.org/pipermail/cygwin/2024-January/255216.html >>> https://sourceware.org/pipermail/cygwin/2024-January/255217.html >>> >>> Corinna proposed to either drop these functions entirely or hide the >>> prototypes on Cygwin only. I attached a patch for the second >>> alternative. > >>>  From 5f1c43796c6a125f04c1f2436fc1048783ce3b7a Mon Sep 17 00:00:00 2001 >>> From: Christian Franke >>> Date: Mon, 22 Jan 2024 19:11:20 +0100 >>> Subject: [PATCH] Hide itoa, utoa, __itoa and __utoa in stdlib.h on >>> Cygwin only >>> >>> These functions are non-standard and not exported by Cygwin. >>> >>> Signed-off-by: Christian Franke >>> --- >>>   newlib/libc/include/stdlib.h | 4 +++- >>>   1 file changed, 3 insertions(+), 1 deletion(-) >>> >>> diff --git a/newlib/libc/include/stdlib.h >>> b/newlib/libc/include/stdlib.h >>> index 15b349440..fd89f5ba7 100644 >>> --- a/newlib/libc/include/stdlib.h >>> +++ b/newlib/libc/include/stdlib.h >>> @@ -221,11 +221,13 @@ char *    ecvtbuf (double, int, int*, int*, >>> char *); >>>   char *    fcvtbuf (double, int, int*, int*, char *); >>>   char *    ecvtf (float,int,int *,int *); >>>   #endif >>> +#ifndef __CYGWIN__ >>>   char *    __itoa (int, char *, int); >>>   char *    __utoa (unsigned, char *, int); >>> -#if __MISC_VISIBLE >>> +# if __MISC_VISIBLE >>>   char *    itoa (int, char *, int); >>>   char *    utoa (unsigned, char *, int); >>> +# endif >>>   #endif >>>   #if __POSIX_VISIBLE >>>   int    rand_r (unsigned *__seed); >>> -- >>> 2.43.0 > >> In fact, while this patch fixes the namespace pollution for Cygwin, I >> wonder if we shouldn't remove itoa/utoa entirely.  The underscored >> functions __itoa/__utoa accomplish exactly the same thing. >> >> 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 > 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. > > Downstream systems should note the change in their lists of supported > functions, and in their release notes. 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. -- Regards, Christian