From: larry@eco.twg.com (Lawrence B. Henry III)
Subject: Re: C include files can change member_alignment
Reply-To: larry@eco.twg.com
Organization: The Wollongong Group (East Coast Operations)
Date: Mon, 21 Dec 92 18:31:22 GMT


In article <1992Dec21.162222.10206@ann-arbor.applicon.slb.com>, chamber@mailhost.aa.cad.slb.com (Craig Chamberlain) writes:
|>Newsgroups: vmsnet.alpha
|>Path: eco.twg.com!uunet!usc!zaphod.mps.ohio-state.edu!cs.utexas.edu!geraldo.cc.utexas.edu!slcs.slb.com!aa.cad.slb.com!chamber
|>From: chamber@mailhost.aa.cad.slb.com (Craig Chamberlain)
|>Subject: C include files can change member_alignment
|>Message-ID: <1992Dec21.162222.10206@ann-arbor.applicon.slb.com>
|>Sender: usenet@ann-arbor.applicon.slb.com (Usenet Administrator)
|>Organization: Schlumberger CAD/CAM at Ann Arbor, MI
|>Date: Mon, 21 Dec 1992 16:22:22 GMT
|>Lines: 48
|>
|>I discovered at least one C include file, stat.h, which changes the C
|>compiler's alignment mode to nomember_alignment.  The default is
|>member_alignment, which generates better code.  If you have two source
|>files which include the same struct declaration, but one source file
|>also includes <stat.h>, the structures may not be compatible in terms
|>of memory layout between the two files.  In stat.h it looks like there
|>is some attempt to save the member_alignment, but it doesn't get
|>restored.
|>
|>$ type inc_stat.c
|>#include <stat.h>
|>$ cc/preprocess_only inc_stat.c
|>$ type inc_stat.i
|># 1 "DISK1:[PASCAL.TEST]INC_STAT.C;1"
|># 1 "SYS$COMMON:[SYSLIB]DECC$RTLDEF.TLB;1"
|>#pragma nostandard
|>#pragma member_alignment __save
|>#pragma nomember_alignment
|>typedef unsigned off_t;
|>typedef unsigned short ino_t;
|>typedef char *dev_t;
|>struct stat
|>{
|> dev_t st_dev;
|> ino_t st_ino[3];
|> unsigned short st_mode;
|> int st_nlink;
|> unsigned st_uid;
|> unsigned short st_gid;
|> dev_t st_rdev;
|> off_t st_size;
|> unsigned st_atime;
|> unsigned st_mtime;
|> unsigned st_ctime;
|> char st_fab_rfm;
|> char st_fab_rat;
|> char st_fab_fsz;
|> unsigned st_fab_mrs;
|>};
|>typedef struct stat stat_t;
|>int stat(char *__file_spec, stat_t *__buffer);
|>int fstat(int __file_desc, stat_t *__buffer);
|>unsigned short umask(unsigned short __old_mask);
|>#pragma standard
|>-- 
|>(My opinions do not necessarily represent those of my employer.)
|>Craig Chamberlain, Software Engineer, Applicon Schlumberger
|>Ann Arbor, Michigan  chamber@ann-arbor.applicon.slb.com  (313) 995-6310
|>

Craig,
	Check out what causes this at the bottom of this file.. got a 
missing "_" in front of the _ALPHA.. should be __ALPHA.. I would suspect that
this is fixed by now inside of DEC... My suspicion is that mid-stream during
the header file development somebody said "hey.. these single underscore names
are violating the user's name space.." so they change them all to "__".. or at
least most of them :-)

-Larry.

---stat.h---- (extracted from DEC's Text library)
$ lib/extract=(stat) sys$Library:decc$rtldef.tlb/out=tt
#ifndef __STAT_LOADED
#define __STAT_LOADED   1
#pragma nostandard      /* This file uses non-ANSI-Standard features */

#ifdef __ALPHA
#pragma member_alignment __save
#pragma nomember_alignment
#endif

/* stuff omitted */

#ifdef _ALPHA
#pragma member_alignment __restore
#endif

#pragma standard
#endif                                  /* __STAT_LOADED */