This is the mail archive of the libc-alpha@cygnus.com 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]

Re: struct stat


> Date: Mon, 15 Mar 1999 16:27:37 -0500
> From: "David A. Greene" <greened@eecs.umich.edu>
> Organization: Department of Electrical Engineering and Computer Science, The University of Michigan
> 
> Mark Kettenis wrote:
> 
> >    Look, there is a little piece of code in gnu/types.h (the #else clause
> >    for __GNUC__, in fact) that defines dev_t as a struct for non-gcc
> >    compilers.  Why can't this guard be moved into the definition of struct
> >    stat, and for  non-gcc compilers, define st_dev as a long int and follow
> >    it with padding?  Yes, it's ugly, yes, it doesn't support 64 bits (but
> >    nether does Linux), but it's more correct than something that doesn't
> >    even compile.
> > 
> > That would break binary compatibility.  As far as glibc is concerned
> > all 64 bits are important.
> 
> I'm a little fuzzy in this area.  Why would this break binary 
> compatability?  Yes, you'd lose information if all 64 bits are 
> important, but for the time being on Linux/x86, you don't.  Linux 
> (in asm/stat.h) defines st_dev as a short with some padding (actually 
> only a short's worth of padding).  How does this work with glibc?  I'm 
> not being sarcastic here, I'm really curious as to how this works.

It's magic :-).  glibc has a wrapper around the kernel's 'stat'
syscall that unpacks and repacks the structure.

It breaks binary compatibility because before, `struct stat' had the
alignment of a 'long long', and after its alignment is reduced.  This
breaks sparc.

> Ok, I can work within the system.  I just want to make sure I'm not 
> wasting my time.  Assuming I make a sane patch (are there explicit 
> instructions for this?), follow all the coding standards, etc. will it 
> be accepted?  I'd like to get an authoritative answer if possible.

I have put in a small patch.  See if that would work.

> Does POSIX define long long as a standard type?  I'm pretty sure it
> requires dev_t to be an integral type, which it is not without gcc.
> I assume it does not require dev_t to be 64 bits, but please correct
> me if I'm wrong.

Care, here!  It may only require dev_t to be arithmetic, which is
different.

-- 
Geoffrey Keating <geoffk@ozemail.com.au>


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