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: [RFA:] stdint.h: Add INTPTR_MIN, INTPTR_MAX, UINTPTR_MAX


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

According to Howland Craig D (Craig) on 4/8/2009 6:03 PM:
> 
> The problem is as the comment in the else says, "SHOULD be valid ...
> with ... 32 bit void *".  The statement is true, but the problem is that
> not all platforms fall into that category--there is no guarantee that
> a pointer fits in a long.  (On the other hand, are there any real
> systems for which it presently does not?  This might only be a
> theoretical problem rather than a real one at this time.)

Yes.  64-bit Windows, and thus mingw64, has 64-bit void*, but 32-bit long.
  When a 64-bit cygwin appears, I'm not sure whether it will try to copy
Windows, or whether it will go with the nicer 64-bit long.  A real
portability nightmare, but we're stuck with it.

> The recommended practice (in C99) is for ptrdiff_t is to be no larger
> than long unless it has to be.  The same should probably apply to
> intptr_t, which is one thing against #3.

It is valid to have 64-bit intptr_t but 32-bit ptrdiff_t, particularly if
you are supporting a 64-bit void* but guarantee that an individual array
will never exceed 32 bits of offset, in which case the smaller ptrdiff_t
makes sense.  I don't know what 64-bit Windows does here, though.

- --
Don't work too hard, make some time for fun as well!

Eric Blake             ebb9@byu.net
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkndQq0ACgkQ84KuGfSFAYB0KQCeK09x912JsqM7sP9bIpHVJUe8
S3kAnA8DbcSRA+8V2Lte6195Rb1FxAtI
=mcOA
-----END PGP SIGNATURE-----


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