This is the mail archive of the newlib@sourceware.org mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH 64bit] ssize_t


On Feb 21 08:17, Schwarz, Konrad wrote:
> > -----Original Message-----
> > From: Eric Blake [mailto:eblake@redhat.com]
> > 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.
> 
> On what platforms does
> 
> 	# include <stddef.h>
> 	typedef ptrdiff_t ssize_t;
> 
> fail?

This is a very good question.  I just applied Yaakov's patch based
on Joseph's idea, but this suggestion comes in second only barely.
There is a chance, however, that on a system with pointer size ==
int size == long size ptrdiff_t is defined as in and size_t defined
as unsigned long or vice versa.  So you would still have the same
potential type difference.

OTOH, maybe we should use this as sane default in the non-GCC case?


Corinna

-- 
Corinna Vinschen
Cygwin Maintainer
Red Hat


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]