Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date: Tue, 2 Dec 2014 20:02:04 -0500
From: Rich Felker <dalias@...c.org>
To: musl@...ts.openwall.com
Subject: Further limits/stdint issues

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

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.