[prev in list] [next in list] [prev in thread] [next in thread] 

List:       fuse-devel
Subject:    Re: [fuse-devel] [PATCH] Use a C1x static assertion to test that off_t is 64 bits.
From:       "Richard W.M. Jones" <rjones () redhat ! com>
Date:       2012-03-20 11:38:55
Message-ID: 20120320113855.GH27709 () amd ! home ! annexia ! org
[Download RAW message or body]

On Tue, Mar 20, 2012 at 12:09:35PM +0100, Lennert Buytenhek wrote:
> On Tue, Mar 20, 2012 at 10:53:37AM +0000, Richard W.M. Jones wrote:
> 
> > with this:
> > 
> > However off_t must still be 64 bits, so how to enforce that?  C1X will
> > define static assertions[1], and these can be used to check the size
> > of off_t.
> > 
> > Not all compilers support static assertions yet, although several do.
> > Therefore I have surrounded the static assertion with a conservative
> > check that the compiler is GCC >= 4.6.  In the long run, this test can
> > be removed and you can just use 'static_assert'.
> 
> Since it'll take many years for everyone to switch over to at least
> gcc 4.6, how about filling in something with the same effect for the
> #else arm as well?  E.g.:
> 
> 
> > diff --git a/include/fuse_common.h b/include/fuse_common.h
> > index a4d980d..72989bb 100644
> > --- a/include/fuse_common.h
> > +++ b/include/fuse_common.h
> > @@ -29,9 +29,13 @@
> > #define FUSE_VERSION FUSE_MAKE_VERSION(FUSE_MAJOR_VERSION, FUSE_MINOR_VERSION)
> > 
> > /* This interface uses 64 bit off_t */
> > +#if defined(__GNUC__) && (__GNUC__ > 4 || __GNUC__ == 4 && __GNUC_MINOR__ >= 6)
> > +_Static_assert (sizeof (off_t) == 8, "off_t is not 8 bytes, ensure large file \
> > support (LFS) is enabled"); +#else
> 
> 	typedef char __off_t_must_be_64_bits_for_fuse_to_work[(signed)sizeof(off_t) - 8];

Yes, or in fact my first version used the trick in Padraig's page
which is similar:

http://www.pixelbeat.org/programming/gcc/static_assert.html

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
virt-p2v converts physical machines to virtual machines.  Boot with a
live CD or over the network (PXE) and turn machines into Xen guests.
http://et.redhat.com/~rjones/virt-p2v

------------------------------------------------------------------------------
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here 
http://p.sf.net/sfu/sfd2d-msazure
_______________________________________________
fuse-devel mailing list
fuse-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/fuse-devel


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic