From owner-freebsd-numerics@freebsd.org Mon Jan 14 13:43:14 2019 Return-Path: Delivered-To: freebsd-numerics@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A4A6114A092E for ; Mon, 14 Jan 2019 13:43:14 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from mail106.syd.optusnet.com.au (mail106.syd.optusnet.com.au [211.29.132.42]) by mx1.freebsd.org (Postfix) with ESMTP id 6D7D6891F5; Mon, 14 Jan 2019 13:43:12 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from [192.168.0.102] (c110-21-101-228.carlnfd1.nsw.optusnet.com.au [110.21.101.228]) by mail106.syd.optusnet.com.au (Postfix) with ESMTPS id 630723CF3C8; Tue, 15 Jan 2019 00:43:08 +1100 (AEDT) Date: Tue, 15 Jan 2019 00:43:07 +1100 (EST) From: Bruce Evans X-X-Sender: bde@besplex.bde.org To: Steve Kargl cc: Pedro Giffuni , freebsd-numerics@freebsd.org Subject: Re: Undefined Behavior in lib/msun/src/e_pow.c (was Re: New math library from ARM) In-Reply-To: <20190101183226.GA11443@troutmask.apl.washington.edu> Message-ID: <20190114235426.I1062@besplex.bde.org> References: <797a7755-db93-1b9c-f3b9-8850d948e098@FreeBSD.org> <20181231151904.GB823@troutmask.apl.washington.edu> <20181231152230.GC823@troutmask.apl.washington.edu> <06c8b6a2-ed26-f255-3947-c79b593a9dea@FreeBSD.org> <20190101045425.GA5767@troutmask.apl.washington.edu> <20190101055225.GA5982@troutmask.apl.washington.edu> <9cdce84b-2cff-d752-67a9-4c9ef391cc2c@FreeBSD.org> <20190101183226.GA11443@troutmask.apl.washington.edu> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Optus-CM-Score: 0 X-Optus-CM-Analysis: v=2.2 cv=FNpr/6gs c=1 sm=1 tr=0 a=PalzARQSbocsUSjMRkwAPg==:117 a=PalzARQSbocsUSjMRkwAPg==:17 a=kj9zAlcOel0A:10 a=oRHHkTnlz5SPpp-4SwMA:9 a=CjuIK1q_8ugA:10 X-Rspamd-Queue-Id: 6D7D6891F5 X-Spamd-Bar: ------ Authentication-Results: mx1.freebsd.org; spf=pass (mx1.freebsd.org: domain of brde@optusnet.com.au designates 211.29.132.42 as permitted sender) smtp.mailfrom=brde@optusnet.com.au X-Spamd-Result: default: False [-6.51 / 15.00]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; RCVD_IN_DNSWL_LOW(-0.10)[42.132.29.211.list.dnswl.org : 127.0.5.1]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; R_SPF_ALLOW(-0.20)[+ip4:211.29.132.0/23]; FREEMAIL_FROM(0.00)[optusnet.com.au]; MIME_GOOD(-0.10)[text/plain]; DMARC_NA(0.00)[optusnet.com.au]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; TO_DN_SOME(0.00)[]; TO_MATCH_ENVRCPT_SOME(0.00)[]; MX_GOOD(-0.01)[cached: extmail.optusnet.com.au]; NEURAL_HAM_SHORT(-0.83)[-0.825,0]; IP_SCORE(-3.37)[ip: (-9.41), ipnet: 211.28.0.0/14(-4.13), asn: 4804(-3.28), country: AU(-0.04)]; RCVD_NO_TLS_LAST(0.10)[]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(0.00)[]; FREEMAIL_ENVFROM(0.00)[optusnet.com.au]; ASN(0.00)[asn:4804, ipnet:211.28.0.0/14, country:AU]; MIME_TRACE(0.00)[0:+]; RCVD_COUNT_TWO(0.00)[2] X-BeenThere: freebsd-numerics@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Discussions of high quality implementation of libm functions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 14 Jan 2019 13:43:15 -0000 On Tue, 1 Jan 2019, Steve Kargl wrote: > On Tue, Jan 01, 2019 at 10:01:45AM -0500, Pedro Giffuni wrote: >> >>>> This would be easy >>>> to see if all declarations are grouped together. In additional, >>>> don't you need to include stdint.h to get uint32_t? >>> >>> Well, my patch did compile, but I will match the existing style if >>> the change is accepted/desired. > > Yeah, I found that out myself. I cannot find where stdint.h is > being pulled into the build. It seems that one of the included > headers may have some namespace pollution. Both u_int32_t and uint32_t are standard [Free]BSD pollution in . The library can reasonably depend on this. stdint.h should rarely be included when compiling msun. It is currently included directly in about 6 source files but never as pollution. Some of the standard pollution in is implemented by including . This is now excessive and results in declaring all standard integer types (which is permitted to declare) and some macros (WCHAR_MAX, WCHAR_MIN, and sometimes RSIZE_MAX which depends on SIZE_MAX which is not defined via pollution) which is not permitted to declare. The extras for the standard integer types are not even under __BSD_VISIBLE. The 6 includes of seem to be just style bugs for using uint64_t. Even FreeBSD-4 declares both u_int64_t and uint64_t. Also, most includes of including all the ones in msun are excessive. Standard integer types are declared in . includes and adds mistakes like PRI* support and non-mistakes like prototypes for strto[u]imax(). msun now uses (signed) int32_t a lot, and this depends on more than the old u_foo_t pollution in , so msun has required FreeBSD features for a long time and is less portable than fdlibm. Including and changing all the u_foo_t's to ufoo_t's would be a lot of churn and would break portability to C90. should be included in at most math.private.h and math_private.h should provide consistent spellings more like ufoo_t than u_foo_t Bruce