This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
Re: shs.cc won't build on Solaris 2.5/sparc
- From: Alexandre Oliva <aoliva at redhat dot com>
- To: Adam Megacz <patches at lists dot megacz dot com>
- Cc: java-patches at gcc dot gnu dot org
- Date: 25 Feb 2002 00:18:41 -0300
- Subject: Re: shs.cc won't build on Solaris 2.5/sparc
- Organization: GCC Team, Red Hat
- References: <ork7t3c7wn.fsf@free.redhat.lsd.ic.unicamp.br><86y9hi1ntu.fsf@megacz.com>
On Feb 24, 2002, Adam Megacz <patches@lists.megacz.com> wrote:
> Can somebody enlighten me on this? Most of my experience is in
> Java/Perl/ML/Haskell... I was under the impression that if you're
> programming in C, and you want an integer that's 32 bits wide,
> uint32_t is the 'official' way to do it.
It's the C99 Standard way to do it, yes. But not all systems are
C99-compliant yet.
> If this is not correct, what is the universal way to get a 32-bit
> wide int?
Unfortunately there's no such thing yet. In fact, there's no
guarantee that any system will have a type that is a 32-bit wide int.
The best fully portable bet is probably:
struct uint32_s { unsigned long val : 32; };
but it's a pain to use that. Unless we made this a class with all
arithmetic operators to make its use transparent. I don't see how to
implement Java semantics otherwise on machines that don't have 32-bit
wide ints or longs. Fortunately, those are very rare these days.
More to the point: uint32_t is not available on all platforms. A
quick hack could define uint32_t as follows:
#if ! HAVE_UINT32_T /* must check for it with autoconf */
# if INT_MAX == 0x7fffffff && INT_MIN == 0x80000000
typedef unsigned int uint32_t;
# elif LONG_MAX = 0x7fffffff && LONG_MAX == 0x80000000
typedef unsigned long uint32_t;
# else
# error "no 32-bit wide int type found"
# endif
#endif
--
Alexandre Oliva Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
Red Hat GCC Developer aoliva@{cygnus.com, redhat.com}
CS PhD student at IC-Unicamp oliva@{lsd.ic.unicamp.br, gnu.org}
Free Software Evangelist Professional serial bug killer