Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Sat, 16 Jan 2016 14:09:29 +0100
From: Jens Gustedt <jens.gustedt@...ia.fr>
To: musl@...ts.openwall.com
Subject: Re: the size of the int type

Am Samstag, den 16.01.2016, 14:09 +0300 schrieb croco@...nwall.com:
> On Fri, Jan 15, 2016 at 09:11:25PM +0000, Josiah Worcester wrote:
> 
> > You would do better to match the convention used on modern-day Unix
> > systems, where int is 32-bit, long is the machine word size, and long long
> > is 64-bit. If you do this everything should pretty much function as it
> > expects, with regard to the standard C types' sizes.
> 
> Let me second this.  Please note that in case you implement int as 64-bit,
> then there will be either no 32-bit or no 16-bit integer type (at all), as
> there's only the short which is in between char ant int; hence, well, there
> will be a kind of problem with some typedefs from <stdint.h>: either
> int16_t/uint16_t or int32_t/uint32_t will actually have a size different
> from what the name suggests, so you'll run into a trouble with
> reading/analysing data in binary formats.

You certainly shouldn't do it like that. If you can't support
[u]intXX_t for some XX, you shouldn't define these types. These are
optional types in the C standard, but if they are defined they must
have the exact width, and the intXX_t must have two's complement
representation.

Mandatory are only the [u]int_leastXX_t types for XX = 8, 16, 32 and
64. But as the name indicates, these don't have to have the exact
width.

In any case you should just stick to the standard ABI of your
platform. Everything else would be opening a can of worms.

Jens


-- 
:: INRIA Nancy Grand Est ::: Camus ::::::: ICube/ICPS :::
:: ::::::::::::::: office Strasbourg : +33 368854536   ::
:: :::::::::::::::::::::: gsm France : +33 651400183   ::
:: ::::::::::::::: gsm international : +49 15737185122 ::
:: http://icube-icps.unistra.fr/index.php/Jens_Gustedt ::




Download attachment "signature.asc" of type "application/pgp-signature" (182 bytes)

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.