This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
target/5855: stat.h mods for malign-double x386 compatibility
- From: salevin at lgc dot com
- To: gcc-gnats at gcc dot gnu dot org
- Date: 6 Mar 2002 20:31:28 -0000
- Subject: target/5855: stat.h mods for malign-double x386 compatibility
- Reply-to: salevin at lgc dot com
>Number: 5855
>Category: target
>Synopsis: stat.h mods for malign-double x386 compatibility
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: unassigned
>State: open
>Class: change-request
>Submitter-Id: net
>Arrival-Date: Wed Mar 06 12:36:01 PST 2002
>Closed-Date:
>Last-Modified:
>Originator: Stewart A. Levin
>Release: gcc 3.0.1
>Organization:
>Environment:
Pentium II, RedHat 7.1, gcc built with thread support
>Description:
I'm attached a patch for /usr/include/bits/stat.h that
preserves structure offsets on x386 platforms independent
of the malign-double compiler option.
>How-To-Repeat:
#!/bin/csh -f
set OPTIONS = "-DLINUX -march=pentium -mieee-fp -D__NO_STRING_INLINES -D__USE_EXTERN_INLINES -D_POSIX_C_SOURCE=199309 -D_BSD_SOURCE -D_REENTRANT -D_XOPEN_SOURCE=500 -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=32"
set DEFINES = "-DLINUX -DLGC_DEFINED -DOW50"
set LDFLAGS = "-L/usr/local/lib -L/usr/X11R6/lib"
set CLIBS = "-lpthread -lg2c"
gcc $OPTIONS $DEFINES teststat.c $LDFLAGS $CLIBS && ./a.out
gcc -I. $OPTIONS $DEFINES teststat.c $LDFLAGS $CLIBS && ./a.out
#gcc -malign-double $OPTIONS $DEFINES teststat.c $LDFLAGS $CLIBS && ./a.out
gcc -I. -malign-double $OPTIONS $DEFINES teststat.c $LDFLAGS $CLIBS && ./a.out
set OPTIONS="$OPTIONS -D_FILE_OFFSET_BITS=64"
gcc $OPTIONS $DEFINES teststat.c $LDFLAGS $CLIBS && ./a.out
gcc -I. $OPTIONS $DEFINES teststat.c $LDFLAGS $CLIBS && ./a.out
#gcc -malign-double $OPTIONS $DEFINES teststat.c $LDFLAGS $CLIBS && ./a.out
gcc -I. -malign-double $OPTIONS $DEFINES teststat.c $LDFLAGS $CLIBS && ./a.out
>Fix:
*** /usr/include/bits/stat.h Fri Aug 10 05:11:03 2001
--- bits/stat.h Sat Feb 9 09:17:43 2002
***************
*** 20,25 ****
--- 20,39 ----
# error "Never include <bits/stat.h> directly; use <sys/stat.h> instead."
#endif
+ #ifdef __GNUC__
+ #ifndef _STAT_PAD_ATTR
+ #if defined(__i386__)
+ #define _STAT_PAD_ATTR __attribute__ ((__aligned__ (4),__packed__))
+ #else
+ #define _STAT_PAD_ATTR
+ #endif
+ #endif
+ #else /* __GNUC__ */
+ #ifndef _STAT_PAD_ATTR
+ #define _STAT_PAD_ATTR
+ #endif
+ #endif/* __GNUC__ */
+
/* Versions of the `struct stat' data structure. */
#define _STAT_VER_LINUX_OLD 1
#define _STAT_VER_KERNEL 1
***************
*** 51,57 ****
#ifndef __USE_FILE_OFFSET64
__off_t st_size; /* Size of file, in bytes. */
#else
! __off64_t st_size; /* Size of file, in bytes. */
#endif
__blksize_t st_blksize; /* Optimal block size for I/O. */
--- 65,71 ----
#ifndef __USE_FILE_OFFSET64
__off_t st_size; /* Size of file, in bytes. */
#else
! __off64_t st_size _STAT_PAD_ATTR; /* Size of file, in bytes. */
#endif
__blksize_t st_blksize; /* Optimal block size for I/O. */
***************
*** 87,93 ****
__gid_t st_gid; /* Group ID of the file's group.*/
__dev_t st_rdev; /* Device number, if device. */
unsigned int __pad2;
! __off64_t st_size; /* Size of file, in bytes. */
__blksize_t st_blksize; /* Optimal block size for I/O. */
__blkcnt64_t st_blocks; /* Number 512-byte blocks allocated. */
--- 101,107 ----
__gid_t st_gid; /* Group ID of the file's group.*/
__dev_t st_rdev; /* Device number, if device. */
unsigned int __pad2;
! __off64_t st_size _STAT_PAD_ATTR; /* Size of file, in bytes. */
__blksize_t st_blksize; /* Optimal block size for I/O. */
__blkcnt64_t st_blocks; /* Number 512-byte blocks allocated. */
***************
*** 132,134 ****
--- 146,150 ----
#define __S_IREAD 0400 /* Read by owner. */
#define __S_IWRITE 0200 /* Write by owner. */
#define __S_IEXEC 0100 /* Execute by owner. */
+
+ #undef _STAT_PAD_ATTR
>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: application/x-unknown-content-type-cfile; name="teststat.c"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="teststat.c"
I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxzeXMvdHlwZXMuaD4KI2luY2x1ZGUgPHN5cy9z
dGF0Lmg+CmludCBtYWluKGludCBhcmdjLCBjaGFyICoqYXJndikKewogY2hhciBjMTsKIHN0cnVj
dCBzdGF0IGExOwogc2hvcnQgczE7CiBzdHJ1Y3Qgc3RhdDY0IGEyOwoKIGZwcmludGYoc3Rkb3V0
LCJzaXplb2Yoc3RhdCk9JWx1IHNpemVvZihzdGF0NjQpPSVsdSBvZmYoc3RhdC5zdF9pbm8pPSVs
dSBvZmYoc3RhdC5fX3N0X2lubyk9JWx1IG9mZihzdGF0NjQuc3RfaW5vKT0lbHUgb2ZmKHN0YXQ2
NC5fX3N0X2lubyk9JWx1XG4iLAogICBzaXplb2Yoc3RydWN0IHN0YXQpLCBzaXplb2Yoc3RydWN0
IHN0YXQ2NCksIAogICgoY2hhciAqKSAmKGExLnN0X2lubykpIC0gKChjaGFyICopICYoYTEuc3Rf
ZGV2KSksCiAgKChjaGFyICopICYoYTEuX19zdF9pbm8pKSAtICgoY2hhciAqKSAmKGExLnN0X2Rl
dikpLAogICgoY2hhciAqKSAmKGEyLnN0X2lubykpIC0gKChjaGFyICopICYoYTIuc3RfZGV2KSks
CiAgKChjaGFyICopICYoYTIuX19zdF9pbm8pKSAtICgoY2hhciAqKSAmKGEyLnN0X2RldikpCiAg
KTsKCiAgcmV0dXJuIDA7Cn0K