From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/6657 Path: news.gmane.org!not-for-mail From: Rich Felker Newsgroups: gmane.linux.lib.musl.general Subject: Further limits/stdint issues Date: Tue, 2 Dec 2014 20:02:04 -0500 Message-ID: <20141203010204.GA5440@brightrain.aerifal.cx> 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 1417568547 6462 80.91.229.3 (3 Dec 2014 01:02:27 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 3 Dec 2014 01:02:27 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-6670-gllmg-musl=m.gmane.org@lists.openwall.com Wed Dec 03 02:02:21 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 1XvyKg-0002Fp-PB for gllmg-musl@m.gmane.org; Wed, 03 Dec 2014 02:02:18 +0100 Original-Received: (qmail 20401 invoked by uid 550); 3 Dec 2014 01:02:17 -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 20390 invoked from network); 3 Dec 2014 01:02:16 -0000 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) Original-Sender: Rich Felker Xref: news.gmane.org gmane.linux.lib.musl.general:6657 Archived-At: Based on Jens' proposed patches, I took another look at things in limits.h and stdint.h and here are some things I noticed that should perhaps be changed: LLONG_MAX is needlessly in bits/limits.h despite widespread assumptions that long long is 64-bit. LONG_BIT and LONG_MAX in bits/limits.h are redundant; either can be derived from the other. In general I try to avoid #ifdefs for feature tests in bits headers, so perhaps we could make bits/limits.h just define __PAGE_SIZE and __LONG_BIT and leave it to the top-level limits.h to expose these as PAGE_SIZE and LONG_BIT according to feature tests and to derive LONG_MAX from __LONG_BIT. UINT32_MAX and UINT64_MAX lack the U suffix. This probably does not matter for UINT64_MAX since the value does not fit in intmax_t, but for UINT32_MAX, it will be treated as a signed value at the preprocessor level without the U suffix. The fast16/fast32 types and limits are still in bits/stdint.h despite not varying between archs. Removing those would make bits/stdint.h tiny/trivial. Aside from PAGE_SIZE, both bits/limits.h and bits/stdint.h would essentially have no information except "long/pointer size" and maybe we could even eventually eliminate them by having a global idea of "wordsize". As noted in the other thread, wint_t should be a shared type, not arch-specific, and WINT_MIN needs to be unsigned. WCHAR_MIN could be defined slightly simpler (just L'\0') in the unsigned case. It may be possible to eliminate the #if UINTPTR_MAX == UINT64_MAX check for defining INT64_C() etc. using an expression that yields the right type naturally (e.g. (c)+0*0x7fffffffffffffff etc.) but I'm not sure if that's an improvement. Rich