Subject: IMPORTANT: stat(2) fix for NetBSD/alpha 1.3
To: None <port-alpha@NetBSD.ORG>
From: Jason Thorpe <thorpej@nas.nasa.gov>
List: port-alpha
Date: 01/04/1998 18:14:57
Hi folks...
To follow up on Curt's post the other day, here is a fix for the stat(2)
ABI bug on the Alpha. This is going into the first 1.3 patch set, and
will be slightly different in post-1.3 NetBSD-current (I am going to remove
the "timespec" structures; they never should have been there in the first
place.)
It was suggested that in current I remove the padding as well, and just
rev the stat(2) ABI one more time. But, I decided NOT to do that because
if time_t is changed to 64-bits (2038 bug! :-), then that will change the
stat(2) ABI again. So, I have just added the comment directing whoever
changes stat(2) again to remove the padding.
Jason R. Thorpe thorpej@nas.nasa.gov
NASA Ames Research Center Home: +1 408 866 1912
NAS: M/S 258-6 Work: +1 650 604 0935
Moffett Field, CA 94035 Pager: +1 415 428 6939
Index: stat.h
===================================================================
RCS file: /cvsroot/src/sys/sys/stat.h,v
retrieving revision 1.30
diff -c -r1.30 stat.h
*** stat.h 1997/11/23 20:40:42 1.30
--- stat.h 1998/01/05 02:14:36
***************
*** 85,90 ****
--- 85,104 ----
int64_t st_qspare[2];
};
+ /*
+ * On systems with 8 byte longs and 4 byte time_ts, padding the time_ts
+ * is required in order to have a consistent ABI. This is because the
+ * stat structure used to contain timespecs, which had different
+ * alignment constraints than a time_t and a long alone. The padding
+ * should be removed the next time the stat structure ABI is changed.
+ * (This will happen whever we change to 8 byte time_t.)
+ */
+ #if defined(__alpha__) /* XXX XXX XXX */
+ #define __STATPAD(x) int x;
+ #else
+ #define __STATPAD(x) /* nothing */
+ #endif
+
struct stat {
dev_t st_dev; /* inode's device */
ino_t st_ino; /* inode's number */
***************
*** 98,108 ****
--- 112,126 ----
struct timespec st_mtimespec;/* time of last data modification */
struct timespec st_ctimespec;/* time of last file status change */
#else
+ __STATPAD(__pad0)
time_t st_atime; /* time of last access */
+ __STATPAD(__pad1)
long st_atimensec; /* nsec of last access */
time_t st_mtime; /* time of last data modification */
+ __STATPAD(__pad2)
long st_mtimensec; /* nsec of last data modification */
time_t st_ctime; /* time of last file status change */
+ __STATPAD(__pad3)
long st_ctimensec; /* nsec of last file status change */
#endif
off_t st_size; /* file size, in bytes */
***************
*** 112,117 ****
--- 130,137 ----
u_int32_t st_gen; /* file generation number */
int64_t st_qspare[2];
};
+
+ #undef __STATPAD
#ifndef _POSIX_SOURCE
#define st_atime st_atimespec.tv_sec