Re: [RFC] [PATCH 1/1] nanosecond timestamps

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Feb 25, 2007  02:36 -0800, Andrew Morton wrote:
> > On Fri, 02 Feb 2007 20:09:40 +0530 Kalpak Shah <kalpak@xxxxxxxxxxxxx> wrote:
> > +#define EXT3_INODE_GET_XTIME(xtime, extra_xtime, inode, raw_inode)
> > \
> > +do {
> > \
> > +	(inode)->xtime.tv_sec = le32_to_cpu((raw_inode)->xtime);
> > \
> > +									      \
> > +	if (offsetof(typeof(*raw_inode), extra_xtime) -
> > \
> > +	    offsetof(typeof(*raw_inode), i_extra_isize) +
> > \
> > +   	    sizeof((raw_inode)->extra_xtime) <=
> > \
> > +	    le16_to_cpu((raw_inode)->i_extra_isize)) {
> > \
> > +		if (sizeof((inode)->xtime.tv_sec) > 4)                        \
> > +			(inode)->xtime.tv_sec |=                              \
> > +			(__u64)(le32_to_cpu((raw_inode)->extra_xtime) &       \
> > +				EXT3_EPOCH_MASK) << 32;                       \
> > +			(inode)->xtime.tv_nsec =                              \
> > +				(le32_to_cpu((raw_inode)->extra_xtime) &      \
> > +				EXT3_NSEC_MASK) >> 2;                         \
> > +	}
> > \
> > +} while (0)
> 
> ow, my eyes.  Can we find a way to do this in C rather than in cpp?

The macro is working on the field names of the inode in most places
(e.g. i_mtime, i_ctime, etc) rather than the values.  You _could_ do it
in C, but it would mean moving all of the "offsetof()" into the caller
(basically putting the whole macro in-line at the caller) or doing math
on the pointer addresses at runtime instead of compile time.

It boils down to a check whether the particular nanosecond field is
inside the reserved space in the inode or not, so it ends up a comparison
against a constant.  For ctime:

	if (4 <= le32_to_cpu((raw_inode)->i_extra_isize) {

And the second "if" decides whether to save bits > 32 in the seconds
field for 64-bit architectures, so it is also evaluated at compile time.

Better to have this in a macro than in the code itself.

Cheers, Andreas
--
Andreas Dilger
Principal Software Engineer
Cluster File Systems, Inc.

-
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Reiser Filesystem Development]     [Ceph FS]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux FS]     [Yosemite National Park]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Device Mapper]     [Linux Media]

  Powered by Linux