From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTP id 1B932383B43A for ; Fri, 20 Aug 2021 08:32:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 1B932383B43A Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1629448326; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references; bh=0+JmKOXnyowtr5PCk04NE6J6ZufkEEpk2DUxucqqw7A=; b=hoLQQVajalPa+ej3EPfC3qcxh13QQRlZosab168ch2ng+akrApMe9HVwnJLDOBm9cjpZUS p5mWQsIpsuYJfng3ci2BTf9B/f3YDTzBwgEKGNjERkDfT2+9urCnGesKPexKCJNfmCRod1 cZcDjEzPLgqWbi3xATPTMT9FuBGH14U= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-162-6bbshaW-NmWinwzNO26Egw-1; Fri, 20 Aug 2021 04:32:05 -0400 X-MC-Unique: 6bbshaW-NmWinwzNO26Egw-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B9AF3802922; Fri, 20 Aug 2021 08:32:04 +0000 (UTC) Received: from calimero.vinschen.de (ovpn-112-10.ams2.redhat.com [10.36.112.10]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8B1901036D20; Fri, 20 Aug 2021 08:32:04 +0000 (UTC) Received: by calimero.vinschen.de (Postfix, from userid 500) id 04D06A80D63; Fri, 20 Aug 2021 10:32:03 +0200 (CEST) Date: Fri, 20 Aug 2021 10:32:02 +0200 From: Corinna Vinschen To: Roger Sayle Cc: 'Newlib' Subject: Re: Should libc/locale/lnumeric.c be in GENERAL_SOURCES (EL/IX level 1)? Message-ID: Reply-To: newlib@sourceware.org Mail-Followup-To: Roger Sayle , 'Newlib' References: <02e001d79516$ee6eb1d0$cb4c1570$@nextmovesoftware.com> MIME-Version: 1.0 In-Reply-To: <02e001d79516$ee6eb1d0$cb4c1570$@nextmovesoftware.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=vinschen@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Disposition: inline X-Spam-Status: No, score=-13.2 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: newlib@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Newlib mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Aug 2021 08:32:17 -0000 On Aug 19 17:26, Roger Sayle wrote: > > > I believe that newlib/libc/locale/Makefile.am should place lnumeric.c > > in GENERAL_SOURCES [EL/IX level 1]. The motivation for doing this is > > that both stdlib/strtod.c and stdlib/gdtoa-gethex.c unconditionally > > call __get_numeric_locale, and they themselves are in GENERAL_SOURCES > > (i.e. EL/IX level 1). Hmm, I wonder if we shouldn't rather fix this in strtod.c and gdtoa-gethex.c. If the target doesn't define __HAVE_LOCALE_INFO__, there's not much of a point to call __get_numeric_locale(loc). Rather, decimal_point could just be set to the dot, i.e. diff --git a/newlib/libc/stdlib/gdtoa-gethex.c b/newlib/libc/stdlib/gdtoa-gethex.c index 1d3da2889ea1..74f30e69013d 100644 --- a/newlib/libc/stdlib/gdtoa-gethex.c +++ b/newlib/libc/stdlib/gdtoa-gethex.c @@ -149,10 +149,16 @@ gethex (struct _reent *ptr, const char **sp, const FPI *fpi, int esign, havedig, irv, k, n, nbits, up, zret; __ULong L, lostbits, *x; Long e, e1; - const unsigned char *decimalpoint = (unsigned char *) +#ifdef __HAVE_LOCALE_INFO__ + const unsigned char *decimalpoint = (const unsigned char *) __get_numeric_locale(loc)->decimal_point; - size_t decp_len = strlen ((const char *) decimalpoint); - unsigned char decp_end = decimalpoint[decp_len - 1]; + const size_t decp_len = strlen ((const char *) decimalpoint); + const unsigned char decp_end = decimalpoint[decp_len - 1]; +#else + const unsigned char *decimalpoint = (const unsigned char *) "."; + const size_t decp_len = 1; + const unsigned char decp_end = (unsigned char) '.'; +#endif havedig = 0; s0 = *(const unsigned char **)sp + 2; diff --git a/newlib/libc/stdlib/strtod.c b/newlib/libc/stdlib/strtod.c index 019416ca7026..ca6d79040224 100644 --- a/newlib/libc/stdlib/strtod.c +++ b/newlib/libc/stdlib/strtod.c @@ -263,7 +263,11 @@ _strtod_l (struct _reent *ptr, const char *__restrict s00, char **__restrict se, #ifdef Honor_FLT_ROUNDS int rounding; #endif +#ifdef __HAVE_LOCALE_INFO__ const char *decimal_point = __get_numeric_locale(loc)->decimal_point; +#else + const char *decimal_point = "."; +#endif int dec_len = strlen (decimal_point); delta = bs = bd = NULL; This would also avoid to pull in a readonly struct which is never used. Thoughts? Corinna