Article View: comp.arch
Article #12572Re: 64-bit chips, 32-bit compatibility?
From: Joe Buck
Date: Thu, 21 Sep 1995 23:13
Date: Thu, 21 Sep 1995 23:13
55 lines
2631 bytes
2631 bytes
For some reason people always post things like this to comp.arch. This is a C question, not a computer architecture question. The types possessed by the underlying computer architecture need not correspond to the types a given C compiler will support (particularly for "char" on processors with no byte addressing). Followups to comp.lang.c. vanevery@rbdc.rbdc.com (Brandon Van every) writes: >I'm writing some 3d graphics libraries that I want to be portable >across all of the mainstream 32-bit and 64-bit architectures. To this >end, I've used GNU Autoconf to define the following data types with >known bit lengths: char8, int16, int32, int64. A good solution, most of the time. Sometimes you can get bitten because a given compiler/processor combo doesn't support a given size (e.g. int64). >What I'm wondering, is how many mainstream CPU's out there are >"strictly 64-bit," and have no 32-bit emulation of any kind. You'd need to be more specific. No 32-bit pointer types? Or what? Also, this is a compiler question, not an architecture question. Several processors have no byte-manipulation instructions but have C compilers that have an 8-bit char type. >In the "mainstream" 64-bit universe, what are the typical bit sizes of >the various integer types? For example, nearly every 32-bit C/C++ >compiler in the universe does the following, nowadays: > >char 8 bits There are a few mainframes with chars of a different size still around, but in practice you don't need to care (except for DSP's which you may not care about either). >short 16 bits Almost always true. >int 32 bits Whoops. In 16-bit code for x86 processors, and for some 68k compilers for embedded processors, int is 16 bits. >long 32 bits For 64-bit processors, long is often 64 bits (it is on the Alpha). Some DSP processors make char = 32 bits and sizeof(int) 1 meaning int is also 32 bits (and so is short). Several compilers (including gcc, MIPS and others) add "long long" which is usually 64 bits. -- -- Joe Buck <jbuck@synopsys.com> (not speaking for Synopsys, Inc) Anagrams for "information superhighway": Enormous hairy pig with fan A rough whimper of insanity
Technical Details
Message-ID:
<43srit$94b@hermes.synopsys.com>Path:
arc1-ca.pugleaf.net!news.synopsys.com!jbuckReferences:
<43p1g8$s24@rbdc.rbdc.com>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!news.synopsys.com!jbuck From: jbuck@synopsys.com (Joe Buck) Newsgroups: comp.arch,comp.lang.c Subject: Re: 64-bit chips, 32-bit compatibility? Followup-To: comp.lang.c Date: 21 Sep 1995 23:13:33 GMT Organization: Synopsys Inc., Mountain View, CA 94043-4033 Message-ID: <43srit$94b@hermes.synopsys.com> References: <43p1g8$s24@rbdc.rbdc.com> NNTP-Posting-Host: deerslayer.synopsys.com