This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH][BZ 18234] struct stat is not posix conform


On Wed, 20 May 2015, Carlos O'Donell wrote:

> On 05/20/2015 11:20 AM, Szabolcs Nagy wrote:
> > the generic definition of struct stat on linux miss the
> > st_atim, st_mtim and st_ctim members when _POSIX_C_SOURCE
> > is defined (affects at least aarch64 and arm).
> > 
> > i did not see regressions on aarch64.
> > 
> > 2015-05-20  Szabolcs Nagy  <szabolcs.nagy@arm.com>
> > 
> > 	[BZ #18234]
> > 	* sysdeps/unix/sysv/linux/generic/bits/stat.h (struct stat): Make
> > 	st_atim, st_ctim, st_mtim visible under __USE_XOPEN2K8.
> 
> I like the idea of the change.
> 
> Firstly it needs a test case.

I.e. adding

#if defined XOPEN2K8 || defined POSIX2008
element {struct stat} {struct timespec} st_atim
element {struct stat} {struct timespec} st_mtim
element {struct stat} {struct timespec} st_ctim
#endif

to conform/data/sys/stat.h-data (the conform/ data hasn't generally been 
fully reviewed against current POSIX, hence such assertions being 
missing).

> Secondly, it changes when these members are made available, and that
> might break applications unless you show that __USE_MISC is a subset
> of __USE_XOPEN2K8, which I don't think it is.
> 
> Therefore you will have to use "__USE_MISC || __USE_XOPEN2K8" preceeded
> by a lengthy comment about the fact that in _DEFAULT_SOURCE you'll get
> these members, but in strict compliance you need to have POSIX Issue 7.

The API should be consistent across architectures.

Most widely-used cases use __USE_XOPEN2K8.  The exceptions are: toplevel 
bits/stat.h (not used in fact) doesn't have the timespec members; 
sysdeps/nacl/bits/stat.h uses __USE_MISC || __USE_XOPEN2K8; as discussed, 
linux/generic uses __USE_MISC; linux/ia64 uses __USE_MISC; 
linux/microblaze uses __USE_MISC.

So, I think a change to use just __USE_XOPEN2K8 is most appropriate.  This 
would fix bugs with the elements not being made available when they should 
be.  The default API level includes __USE_XOPEN2K8.  If __USE_MISC is 
defined, so is __USE_XOPEN2K8: __USE_MISC is only defined when 
_DEFAULT_SOURCE is defined (explicitly or implicitly), and _DEFAULT_SOURCE 
implies __USE_XOPEN2K8.  So __USE_MISC || __USE_XOPEN2K8 is entirely 
redundant and means the same as __USE_XOPEN2K8.

Thus: fix nacl, linux/generic, linux/ia64 and linux/microblaze to use 
__USE_XOPEN2K8 here (all in one patch, and the bug in Bugzilla might 
reasonably be rescoped to cover all those cases).

linux/alpha does its own more complicated thing with a macro __ST_TIME; I 
see no real reason for one architecture to do things differently from all 
the test, but also no reason to change it for this bug since it's already 
using __USE_XOPEN2K8.

-- 
Joseph S. Myers
joseph@codesourcery.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]