Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 26 Nov 1995 16:32:02 -0700 (MST)
From:      Terry Lambert <terry@lambert.org>
To:        jehamby@lightside.com (Jake Hamby)
Cc:        terry@lambert.org, grog@lemis.de, hackers@FreeBSD.org
Subject:   Re: How long is long?
Message-ID:  <199511262332.QAA17633@phaeton.artisoft.com>
In-Reply-To: <Pine.BSF.3.91.951126144020.207A-100000@localhost> from "Jake Hamby" at Nov 26, 95 02:47:50 pm

next in thread | previous in thread | raw e-mail | index | archive | help
> > If there is a type that is treated as atomic (ie: it may be used as
> > the underlying type for off_t according to ANSI and POSIX), then the
> > type promotion has to promote to the largest one allowable.  The
> > target promoted type is, in fact, the stack alignment size.  This
> > only makes sense, since the stack alignment size and single cycle
> > bus fetch and register sizes dictate the efficiency of the fetch
> > process.  This is why Aztec on the Mac and Amiga 68k was correct
> > in setting sizeof(int) == 2 and Lattice (SAS) C was wrong in
> > setting sizeof(int) == 4.  An "int" is supposed to be the "natural"
> > type for the machine and take a single bus cycle to load.
> 
> I'd have to disagree with this particular statement.  On the 680x0 series,
> it is correct to have sizeof(int) == 4, because these machines are fully
> 32-bit internally.  Of course the 68000 and 68010 have a 16-bit data bus,
> but the 68020 and above have a 32-bit data bus.  By saying that "int"
> should be the "natural" type for the machine, you are implying that, for
> example, "int" should be 16-bits on an 80386SX running FreeBSD (because it
> has a 16-bit bus) and 32-bits on 386DX and above!!  Not that many people
> actually run FreeBSD on a 386SX :-) but you get the idea..
> 
> P.S.  There is a compiler flag in SAS C on Amiga to set the default "int" 
> size to 16 bits, if you so desire.  How does that affect your philosophy?

There's a flag on Aztec to set it to 32.  But it wasn't the default.

Aztec code ran faster because it took a single bus cycle to fetch an
Aztec int, but two to fetch a Lattice (SAS) int.

Faster is better.  <-- AXIOM

It boils down to if you think the registers dictate sizeof(int) or the
bus width dictates it.

Personally I think it should be dictated by min(sizeof(REG),sizeof(BUS))
so that it is *always* a single cycle fetch.  Hardware engineers (who
are the fiends who cause such problems for programmers in the first
place) would probably disagree.

The 32 bit int became a defacto standard on the Amiga because of the
code base and the pushing from Commodore itself.


BTW: I agree with your examples, although I wouldn't have said '"int"
should be 16-bits on an 80386SX', I would have said 'Intel should never
have produces a 386SX, the PC manufactures should have had to update
their 286 board designs instead of adapting them'.

The natural consequence of this is that "int" is 32 bits and 80386SX
purchasers suffer for their bad taste.

Of course, that doesn't mean that I don't believe that FreeBSD shouldn't
be compilable/runnable with 16 bit ints.  It should.

Peter rightly points out that portable code that requires sized types
should use typedef'ed sizes.

I disagree with taking that all the way to a "short short" to fix the
16/32 bit orphaning in a 64 bit long, 64 bit int environment.


					Terry Lambert
					terry@lambert.org
---
Any opinions in this posting are my own and not those of my present
or previous employers.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199511262332.QAA17633>