[PATCH 64bit] ssize_t

Eric Blake eblake@redhat.com
Wed Feb 20 16:36:00 GMT 2013


On 02/20/2013 09:30 AM, Schwarz, Konrad wrote:

>>>> GCC requires exact symmetry of types between ssize_t and size_t.
>>>> I.e. checking for sizes of types is not sufficient for [s]size_t.

> 
> Pardon me, but would an approach similar to the following work?
> 
> # include <limits.h>
> 
> typedef int
> # if USHRT_MAX == __SIZE_MAX__
> 	short
> # elif UINT_MAX == __SIZE_MAX__

No, because when size_t and long are 4 bytes, UINT_MAX == LONG_MAX, but
that's a case where we want ssize_t to be long, not int.

The problem at hand is that gcc doesn't seem to give us any good way to
tell whether size_t is based on 'int' or on 'long'.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 621 bytes
Desc: OpenPGP digital signature
URL: <http://sourceware.org/pipermail/newlib/attachments/20130220/4bb5a96c/attachment.sig>


More information about the Newlib mailing list