mailing list of musl libc
 help / color / mirror / code / Atom feed
* Further limits/stdint issues
@ 2014-12-03  1:02 Rich Felker
  2014-12-03  4:10 ` Glenn Weinberg
  2014-12-03 10:38 ` Jens Gustedt
  0 siblings, 2 replies; 7+ messages in thread
From: Rich Felker @ 2014-12-03  1:02 UTC (permalink / raw)
  To: musl

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


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2014-12-03 21:08 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-12-03  1:02 Further limits/stdint issues Rich Felker
2014-12-03  4:10 ` Glenn Weinberg
2014-12-03  5:03   ` Rich Felker
2014-12-03 16:34     ` Glenn Weinberg
2014-12-03 17:01       ` Rich Felker
2014-12-03 21:08         ` Glenn Weinberg
2014-12-03 10:38 ` Jens Gustedt

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).