From owner-freebsd-hackers Sun Nov 26 04:56:47 1995 Return-Path: owner-hackers Received: (from root@localhost) by freefall.freebsd.org (8.6.12/8.6.6) id EAA05858 for hackers-outgoing; Sun, 26 Nov 1995 04:56:47 -0800 Received: from cls.net (freeside.cls.de [192.129.50.1]) by freefall.freebsd.org (8.6.12/8.6.6) with SMTP id EAA05853 for ; Sun, 26 Nov 1995 04:56:42 -0800 Received: by mail.cls.net (Smail3.1.29.1) from allegro.lemis.de (192.109.197.134) with smtp id ; Sun, 26 Nov 95 12:56 GMT From: grog@lemis.de (Greg Lehey) Organisation: LEMIS, Schellnhausen 2, 36325 Feldatal, Germany Phone: +49-6637-919123 Fax: +49-6637-919122 Reply-To: grog@lemis.de (Greg Lehey) Received: (grog@localhost) by allegro.lemis.de (8.6.9/8.6.9) id NAA13345; Sun, 26 Nov 1995 13:52:15 +0100 Message-Id: <199511261252.NAA13345@allegro.lemis.de> Subject: Re: How long is long? To: terry@lambert.org (Terry Lambert) Date: Sun, 26 Nov 1995 13:52:15 +0100 (MET) Cc: hackers@freebsd.org (FreeBSD Hackers) In-Reply-To: <199511241905.MAA10078@phaeton.artisoft.com> from "Terry Lambert" at Nov 24, 95 12:05:45 pm X-Mailer: ELM [version 2.4 PL23] MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit Content-Length: 2758 Sender: owner-hackers@freebsd.org Precedence: bulk Terry Lambert writes: > > > Terry Lambert wrote: > > >That's a bug in the standard in not having mechanisms for obtaining > > >sized types. For a 64 bit int (requiring a 64 bit long), short is > > ^^-- 128 > ^^^-- 64 > The size of long shall be greater than or equal to the sizeof int. Your > 128 says "greater than" and ignores "equal to". > > > >either 16 or 32 bits (undefined) and we lose access to either 32 or > > >16 bit types (respectively). > > > > What architecture requires a 64 bit (int)? > > Any architecture where 64 bits is the bus transfer size and the registers > are 64 bits or larger. It's defined as the "natural type" for the machine. > > But I was assuming a 64 bit int, and it was the int requiring the 64 > bit long, not anything requiring a 64 bit int. > > My complaint is about the long >= int requirement on longs. > > > IMHO, DEC did exactly the right thing making int 32 bits and long 64 bits, > > given the history of the language, but IMHO the original BSD port to the > > VAX should have done the same thing, rather than keeping it 32 bits for > > easier porting of PDP-11 code. > > > > Long doesn't and shouldn't mean "32 bits". > > Maybe not. But *something* should mean "32 bits". > > The problem is that with a 64 bit int (which, despite your opinion of > DEC and grandfathering old software, is correct for the Alpha): > > int == 64 :== long == 64 > short == 32 || short == 16 > char == 8 > > You lose access to either 32 bit or 16 bit sized types. > > Period. You're looking at this from the wrong perspective. Even if you say: > ANSI doesn't allow "long long" or "quad". That means that ANSI is wrong. If a language doesn't allow you to access to the primitive data types of your machine, then it's broken. In the case of C, the answer is obvious enough. ANSI doesn't allow long long, but that doesn't mean you can't use it. And how about short short? I tend to agree with Peter that it's a good idea to keep data sizes roughly the same. It may have been a mistake to increase an int from 16 to 32 bits when moving to the Vax, but that's history. Modern computers have int lengths which are a power of 2, and that power lies between 3 and 7 in all cases. Is it really that difficult to find 5 different descriptions? For example: short short 8 bits short 16 int 32 long 64 long long 128 I don't think that this should be carved in stone; I'd prefer int8, int16 etc. for things which really *must* be that length (like data shared with other architectures), but it would make life a lot easier if people would adhere to the lengths anyway. Greg