Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84 SMI; site sun.uucp Path: utzoo!watmath!clyde!burl!ulysses!ucbvax!decvax!decwrl!sun!guy From: guy@sun.uucp (Guy Harris) Newsgroups: net.lang.c Subject: Re: Typedefs Message-ID: <2899@sun.uucp> Date: Thu, 17-Oct-85 01:34:53 EDT Article-I.D.: sun.2899 Posted: Thu Oct 17 01:34:53 1985 Date-Received: Sat, 19-Oct-85 05:37:30 EDT References: <2148@brl-tgr.ARPA> <430@brl-sem.ARPA> Organization: Sun Microsystems, Inc. Lines: 35 > (The 4.x BSD C compiler) doesn't ignore register short definitions, it > mearly does not put them in registers because registers can only be > applied to types int and long on VAX. It also puts pointers into registers as well; the rule is "if it's not 32 bits wide, ignore the 'register' declaration." The reason, according to the 4.1BSD manual page for "cc": BUGS The compiler currently ignores advice to put "char", "unsigned char", "short", or "unsigned short" variables into registers. It previously produced poor, and in some cases incorrect, code for such declarations. I remember running code through the System III VAX PCC and the 4.1BSD VAX PCC (which is the S3 VAX PCC with long variable name support added, register variables < 32 bits wide subtracted, and some other minor changes). If I remember correctly, the S3 compiler did, indeed, produces some less-than-wonderful code for some constructs involving "register short" variables. The S5 VAX PCC will put types shorter than 32 bits into registers; it has been claimed that it does not produce the same poor code. I've provoked it into producing code which widens things into registers and narrows them again (or *vice versa*; it's been a while). This may have been necessary to preserve the semantics of C; I don't remember the exact circumstances. > Or whould you have sizeof (int) return different numbers depending > on whether it's in a register or not? Huh? The compiler keeps track of the type of all variables, so the code that handles "sizeof" doesn't look at whether it's in a register or not. Besides, an "int" on a VAX takes 32 bits whether it's in a register or not. Guy Harris