[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
current coreutils on MacOS X
From: |
Bruno Haible |
Subject: |
current coreutils on MacOS X |
Date: |
Fri, 1 Sep 2006 14:01:57 +0200 |
User-agent: |
KMail/1.9.1 |
Hi,
On MacOS X 10.3.9, coreutils current CVS fails to compile:
stat.c: In function `print_statfs':
stat.c:416: error: incompatible types in initialization
make[2]: *** [stat.o] Error 1
This is because f_fsid on various systems is of different types:
FreeBSD-4.0: typedef struct fsid { int32_t val[2]; } fsid_t;
MacOS X: typedef struct fsid { int32_t val[2]; } fsid_t;
OpenBSD-3.8: typedef struct { int32_t val[2]; } fsid_t;
NetBSD-3.0: typedef struct { int32_t __fsid_val[2]; } fsid_t;
I think it's not worth testing for subfields of name 'val', '__val',
'__fsid_val', because the purpose of these subfields is just to split
8 bytes of data into two integers. So I propose this patch.
With this patch, thanks to your fixes regarding O_NOFOLLOW and isapipe(),
"make check" succeeds!
2006-08-31 Bruno Haible <address@hidden>
* src/stat.c (print_statfs): Use memcpy to copy the fsid into an
uintmax_t.
*** src/stat.c.bak Fri Aug 25 13:48:03 2006
--- src/stat.c Fri Sep 1 02:52:03 2006
***************
*** 404,420 ****
case 'i':
{
! #if HAVE_STRUCT_STATXFS_F_FSID___VAL
! uintmax_t val0 = statfsbuf->f_fsid.__val[0];
! uintmax_t val1 = statfsbuf->f_fsid.__val[1];
! uintmax_t fsid =
! (val1
! + (sizeof statfsbuf->f_fsid.__val[1] < sizeof fsid
! ? val0 << (CHAR_BIT * sizeof statfsbuf->f_fsid.__val[1])
! : 0));
! #else
! uintmax_t fsid = statfsbuf->f_fsid;
! #endif
out_uint_x (pformat, prefix_len, fsid);
}
break;
--- 404,422 ----
case 'i':
{
! uintmax_t fsid;
! /* On many BSD systems, fsd.f_fsid is of type fsid_t which is a
! struct type:
! struct { int32_t val[2]; }
! or struct { int32_t __val[2]; }
! or struct { int32_t __fsid_val[2]; }. */
! memcpy ((char *) &fsid, &statfsbuf->f_fsid,
! sizeof (statfsbuf->f_fsid) < sizeof (fsid)
! ? sizeof (statfsbuf->f_fsid)
! : sizeof (fsid));
! if (sizeof (statfsbuf->f_fsid) < sizeof (fsid))
! memset ((char *) &fsid + sizeof (statfsbuf->f_fsid), 0,
! sizeof (fsid) - sizeof (statfsbuf->f_fsid));
out_uint_x (pformat, prefix_len, fsid);
}
break;
- current coreutils on MacOS X,
Bruno Haible <=