From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/6651 Path: news.gmane.org!not-for-mail From: Rich Felker Newsgroups: gmane.linux.lib.musl.general Subject: Re: [PATCH 4/4] fix a minor bug for the definition of WINT_MIN Date: Tue, 2 Dec 2014 16:56:34 -0500 Message-ID: <20141202215634.GJ29621@brightrain.aerifal.cx> References: <1416926909.16006.926.camel@eris.loria.fr> <20141202180633.GE29621@brightrain.aerifal.cx> <1417548198.4936.1108.camel@eris.loria.fr> <20141202194712.GH29621@brightrain.aerifal.cx> <1417556577.4936.1133.camel@eris.loria.fr> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1417557416 32056 80.91.229.3 (2 Dec 2014 21:56:56 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 2 Dec 2014 21:56:56 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-6664-gllmg-musl=m.gmane.org@lists.openwall.com Tue Dec 02 22:56:50 2014 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1XvvRB-0006Yn-GU for gllmg-musl@m.gmane.org; Tue, 02 Dec 2014 22:56:49 +0100 Original-Received: (qmail 7965 invoked by uid 550); 2 Dec 2014 21:56:48 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Original-Received: (qmail 7948 invoked from network); 2 Dec 2014 21:56:47 -0000 Content-Disposition: inline In-Reply-To: <1417556577.4936.1133.camel@eris.loria.fr> User-Agent: Mutt/1.5.21 (2010-09-15) Original-Sender: Rich Felker Xref: news.gmane.org gmane.linux.lib.musl.general:6651 Archived-At: On Tue, Dec 02, 2014 at 10:42:57PM +0100, Jens Gustedt wrote: > Am Dienstag, den 02.12.2014, 14:47 -0500 schrieb Rich Felker: > > On Tue, Dec 02, 2014 at 08:23:18PM +0100, Jens Gustedt wrote: > > > > Indeed, but 0U would be a much nicer way of writing it. > > > > > > But this would be wrong on platforms with 16 bit int, no? > > > > POSIX requires int to be at least 32 bits. > > ah right, and since we heavily rely on linux we don't assume that we > will ever run on a non-POSIX platform > > > > > Also I'm wondering why I have wint_t in the arch-specific > > > > alltypes.h.in files if stdint.h is assuming the type is > > > > unsigned/32-bit, and it actually is for all archs. Perhaps we should > > > > move it into the shared part of alltypes.h.in? > > > > > > don't we have archs with 16 bit int? > > > > No. And we don't have archs with int > 32 bits either because too much > > would break with no practical benefits. (For example, uint32_t would > > be smaller than int and thus would be subject to default promotions, > > UB on overflow, etc. and there would be no way to get either a 16-bit > > type or a 32-bit type without extended integer types.) > > > > > but right, even then we could move it up and define it as uint32_t > > > > That would not work directly, as wint_t is exposed in places that > > don't expose uint32_t. > > So that's probably the reason why it is burried in the arch specific > stuff. So I see two solutions > > - have it as I did, be symmetric, and burry it in the arch specific > files > > - have it in one place, but then bluntly use unsigned, UINT_MAX and 0U > > I have no personal preference for any of that. One simple definition that seems to work and naturally gets the types right: #define WINT_MAX 0xffffffffu #define WINT_MIN (WINT_MAX-WINT_MAX) Note that UINT_MAX isn't available in stdint.h; this was probably the original motivation for using UINT32_MAX. But spelling it out as 0xffffffffu explicitly works just as well. Rich