Article View: vmsnet.alpha
Article #1C include files can change member_alignment
From: Craig Chamberlain
Date: Mon, 21 Dec 1992 16:22
Date: Mon, 21 Dec 1992 16:22
48 lines
2043 bytes
2043 bytes
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
Technical Details
Message-ID:
<1992Dec21.162222.10206@ann-arbor.applicon.slb.com>Path:
arc1-ca.pugleaf.net!sparky!uunet!usc!zaphod.mps.ohio-state.edu!cs.utexas.edu!geraldo.cc.utexas.edu!slcs.slb.com!aa.cad.slb.com!chamberShow Full Headers
Complete Article Headers
Newsgroups: vmsnet.alpha Path: arc1-ca.pugleaf.net!sparky!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