64-bit bugs in new ovdb

Heath Kehoe heath.kehoe at intermec.com
Thu Oct 5 18:54:32 UTC 2000


> struct datakey {
>     group_id_t groupnum;
>     ARTNUM artnum;
> };
> 
> On the alpha, ARTNUM is unsigned long (64 bits) and group_id_t is
> defined by ovdb as u_int32_t.  By the common rules of padding C
> structs, the compiler adds an extra 32 bit word of padding after
> groupnum to 64-bit align artnum.  Since BerkeleyDB apparently treats
> the datakey as a chunk of memory sizeof(datakey), that padding *must*
> be zeroed (or at least set to a consistent value).  The enclosed patch
> adds the appropriate memsets, and appears to fix the obvious problem:
> 

Hi, thanks for your report.  I hadn't considered the padding issue.
Are alphas big-endian?  There's another potential problem, in that
htonl() and ntohl() macros are used on ARTNUM datatypes.  Are those
macros safe to use on 64-bit ints?

If not, I'll have to change the artnum's so that they are u_int32_t.
If there are two 32-bit ints, there won't be padding between them,
right? (on a 64-bit system, I mean).


-heath




More information about the inn-workers mailing list