[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20070226214215.GE10715@schatzie.adilger.int>
Date: Mon, 26 Feb 2007 14:42:15 -0700
From: Andreas Dilger <adilger@...sterfs.com>
To: Andrew Morton <akpm@...ux-foundation.org>
Cc: Kalpak Shah <kalpak@...sterfs.com>, linux-ext4@...r.kernel.org,
tytso@....edu, sct@...hat.com
Subject: Re: [RFC] [PATCH 1/1] nanosecond timestamps
On Feb 25, 2007 02:36 -0800, Andrew Morton wrote:
> > On Fri, 02 Feb 2007 20:09:40 +0530 Kalpak Shah <kalpak@...sterfs.com> 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@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists