From: bdwheele@indiana.edu ()
Subject: Re: 32 and 64 bit questions
Date: 1999/11/09 [thread overview]
Message-ID: <809pkb$hvj$1@jetsam.uits.indiana.edu> (raw)
In-Reply-To: 3824F582.855F31FA@rchland.vnet.ibm.com
In article <3824F582.855F31FA@rchland.vnet.ibm.com>,
Larry Loen <lwloen@rchland.vnet.ibm.com> writes:
> Robert Harley wrote:
>
>> Larry W Loen <lwloen@rchland.vnet.ibm.com> writes:
>> > I was once told that the C construct "long" was
>> > supposed to be 64 bits for Alpha, but reading
>> > about the DEC C and DEC C++ compiler manuals on-line
>> > more or less contradicts it.
>>
>> Longs are 64 bits on Linux and Tru64 Unix, but 32 bits on VMS and
>> WinNT. I suspect they're 64 on BSD but I'm not certain.
>>
>> Rob.
>
> Thanks for the reply. It's helpful, but not
> enough for this poor fellow who has no
> machine available to settle it.
>
> There is a kind of incestual relationship between
> and operating system and a compiler.
Well, sort of...since they're both children of the same parents...
>
> At the end of the day, however, the operating system
> really does not determine what "sizeof(int)" or
> "sizeof(long)" is. The compiler does.
That is true, but it is more complex than that. There's nothing to
say that a long on a 64-bit machine _can't_ be 32 bits. When an
OS is being created, it is defined in terms of the compiler that's
building it. If a long is defined as 32 bits by the compiler, then
a long will be 32 bits to the OS, and similarly for a 64 bit long.
>
> An OS may write its documentation "as if" it controlled
> these things. That means an OS interface may be
> written with sizeof(int) and sizeof(long) _presumed_
> to be certain values, but the compiler, in the end,
> controls what is actually done. To be sure, the
> compiler has some good incentive to mimic the
> OS' rules, but it may or may not actually do so.
The OS uses the compiler's rules, since the compiler exists first...usually
as a cross compiler. Since they're defined by the same people, we can
assume that the compiler is designed to handled the data types/sizes that
the OS designers want for defining their OS...
>
> Thus, the OS document can say
> that a given input value on a given interface
> is a "long" and mean "64 bit signed integer." But
> the compiler only need supply _some_ way
> of generating a 64 bit integer. It may define long
> as 32 and use either long long or something like
> __int64 for 64 bit binary numbers. I've seen it done.
>
> And, while the OS may happen to provide a compiler
> along with it that expresses its presumptions about what
> "sizeof(long)" should be, there are usually alternative compilers
> as well that may or may not have different rules. For
> instance, if most of my application was independent of
> the OS, and was first written for NT, I might use an
> Alpha-targeting Microsoft C/C++ or maybe a variant
> of GNU C created with MS conventions for all but the
> modules in my application that deal directly with the OS.
These compilers mimic the 32/64 bit rules of the original compiler, in order
to use the headers and libraries supplied by the OS (which, were generated
by the original compiler)
>
> Thus, my interest is really not just the OS rules, but
> how the compilers _implement_ them and what flags
> they turn on to indicate which rules are active.
>
> I'm very interested in what DEC C and C++ define
> and how they define them (e.g. what/when __32BITS
> is active and what OS flags and so on go with such
> a setting). I'm also a bit interested in MS C++ and
> GNU, but the DEC/COMPAQ are my first
> interest.
>
> So far as I can tell, the DEC C and C++ (and their
> COMPAQ-branded upgrades) seem to have different
> rules. At best, the on-line documentation is inconsistent
> and unclear on long.
>
> Still, I think I get some good answers from your
> note. I think I should expect the following:
>
> int long void*
> Microsoft C/C++ 4 4 8 ****
> DEC C/C++ 4 8 8 **
> GNU 4 8 8 ** ***
>
> ** Unless running in __32BITS mode. Assumed
> same for 64 bit VMS and Tru64.
> *** I'm assuming that if Alpha Linux has a
> 64 bit long, it has a 64 bit void*
> ***** Since MS C++ only supported NT conventions
>
> but the DEC/COMPAQ documentation doesn't
> unambiguously support the above table nor provide
> a consistent way for telling what is what between
> its C and C++. Or, so I read it.
void* is going to be funny under NT. NT is really using only 32 bits
for addressing, regardless of platform, so it is safe (in theory) to
store a void* in an int on NT, but a bad idea to do it on anything else.
Brian Wheeler
bdwheele@indiana.edu
next prev parent reply other threads:[~1999-11-09 5:00 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
1999-11-04 5:00 32 and 64 bit questions Larry W Loen
1999-11-05 5:00 ` Robert Harley
1999-11-06 5:00 ` Larry Loen
1999-11-09 5:00 ` bdwheele [this message]
1999-11-09 5:00 ` Jeff Donsbach
1999-11-11 5:00 ` Larry Loen
1999-11-15 5:00 ` 32 and 64 bit questions (some results) Larry W Loen
read-only archive
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox