Re: [RFC 7/7] ext3 blocks: convert ext3_fsblk_t to sector_t

Dave Kleikamp <[email protected]>
Newsgroups gmane.comp.file-systems.ext2.devel
Message-ID <[email protected]>
On Fri, 2006-05-19 at 12:55 -0600, Andreas Dilger wrote:

> No, even though the sizes of long and long long are the same on a 64-bit
> arch you get compile warnings because this isn't a safe assumption on all
> systems.  It is even worse on e.g. x86_64 and SPARC because the types in
> userspace aren't the same as in the kernel.  I've had to deal with this for
> a long time with Lustre, and we have defined LPU64, LPX64, LPD64 that are
> used in all the printks in our code:
> 
> #if (defined(__x86_64__) && defined(__KERNEL__))
> /* x86_64 defines __u64 as "long" in userspace, but "long long" in the kernel */
> # define LPU64 "%Lu"
> # define LPD64 "%Ld"
> # define LPX64 "%#Lx"
> #elif (BITS_PER_LONG == 32 || __WORDSIZE == 32)
> # define LPU64 "%Lu"
> # define LPD64 "%Ld"
> # define LPX64 "%#Lx"
> #elif (BITS_PER_LONG == 64 || __WORDSIZE == 64)
> # define LPU64 "%lu"
> # define LPD64 "%ld"
> # define LPX64 "%#lx"
> #endif

%Lu, %Ld, and &Lx are not technically correct, even though the compiler
& printk code allow them.  According to printf(3), "L" refers to a long
double, and "ll" refers to a long long int.

> That said, I think I'd still prefer to have Dave's original SECTOR_FMT patch
> since it is completely unambiguous that the format matches the type.  If it
> so happens that we get LPU64 into the kernel (which I doubt, since I had
> suggested this a long time ago, but maybe things change) then we can
> redefine SECTOR_FMT in terms of LPU64.

I'd rather see a more generic solution.  If defining SECTOR_FMT is the
right thing to do, isn't it likely that the same will be done for a lot
of other types?  On the other hand, it's less intrusive and more
straightforward than anything else we've come up with.

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



-------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.