Subject: Re: 64 bit inode changes
To: None <tech-kern@netbsd.org>
From: Christos Zoulas <christos@astron.com>
List: tech-kern
Date: 08/16/2005 21:19:41
In article <OKEHKFHNMFINIBDNPMFGKEPLDAAA.gww@traakan.com>,
Gordon Waidhofer <gww@traakan.com> wrote:
>
>> | 
>> | Why the parameter 'dp' to DIRENT_NAMEOFF? Why wouldn't
>> | it just boil down to a constant? ((struct dirent *)0)
>> 
>> Because I can use this macro with struct dirent, struct dirent12, 
>> and struct direct. Otherwise I would need 3 macros.
>
>#define _DIRENT_RECLEN(dp, namlen) \     
>    ((_DIRENT_NAMEOFF(dp) + (namlen) + 1 + 0xf) & ~0xf)
>
>Does this 0xF alignment hold for all variants of dirent?

Unfortunately not. Our on-disk struct direct and struct dirent12 use 0x3.
I thought about parameterizing this one, but did not. instead i do:

#define _DIRENT12_RECLEN(dp, namlen) \     
    ((_DIRENT_NAMEOFF(dp) + (namlen) + 1 + 0x3) & ~0x3)

I thought about defining the # in another macro or using some ugliness like:

#define _DIRENT_ALIGN(dp)
	(/*CONSTCOND*/sizeof(dp->d_namlen) == sizeof(uint8_t) ? 0x3 : 0xf)

#define _DIRENT_RECLEN(dp, namlen) \     
    ((_DIRENT_NAMEOFF(dp) + (namlen) + 1 + _DIRENT_ALIGN(dp)) & \
    ~_DIRENT_ALIGN(dp))

but I decided to use a separate macro..

christos