[2613] in Kerberos_V5_Development
Re: sized types, and ridding ourselves of them
daemon@ATHENA.MIT.EDU (Assar Westerlund)
Tue Oct 21 18:02:22 1997
To: Tom Yu <tlyu@MIT.EDU>
Cc: krbdev@MIT.EDU
From: Assar Westerlund <assar@sics.se>
Date: 22 Oct 1997 00:02:45 +0200
In-Reply-To: Tom Yu's message of "Fri, 17 Oct 1997 23:44:52 -0400 (EDT)"
Tom Yu <tlyu@MIT.EDU> writes:
> So what do people think about getting rid of sized types completely?
> In particular, krb5_int32 will always be a long, and krb5_int16 will
> always be an int. Better yet, what about just using long and int
> where we mean types at least 32 and 16 bits wide, accordingly? I
> don't think that's inherently a bad thing. It will likely break some
> binary compatibility, but considering Ken Hornstein's experiences with
> with Crays and other associated confusion, I am strongly considering
> it.
Short answer: no
Long answer follows...
The only types we can count on being there are `at least n bits'. And
of course, the code cannot depend on these having exactly n bits of
precision or occupying exactly n bits in memory. And I think there
are two advantages to calling them `foo_16' and `foo_32' instead of
`int' and `long'. First, that's it's more obvious that we need a type
of at least `n' bits. And second because it gives flexibility later
to change things on strange machines.
In C9X there's this nice header called <inttypes.h> which contains
these types (for canonical values of 17):
int17_t, uint17_t (these may or may not exist)
int_least17_t, uint_least17_t (must exist)
int_fast17_t, uint_fast17_t (must exist)
and then (in the cases where there will be any difference) picking the
*fast* makes the most sense to me.
Of course, having foo_16 == int and foo_32 == long as a fall-back is
the right thing.
The way we have done things in Heimdal is mostly like above except
that we (for historical reasons) call the types `int17_t' and
`u_int17_t'. If these are defined when compiling we use these
definitions, otherwise we generate a small program to calculate the
precision of each integer type and generate a header from that.
/assar