Monday, October 11, 2010

Alignemet and structures.

I was reading some random code on the net and had come across this code snippet at following link.

#define NETDEV_ALIGN 32
#define NETDEV_ALIGN_CONST (NETDEV_ALIGN - 1)


static inline void *netdev_priv(struct net_device *dev)
{ return (char *)dev + ((sizeof(struct net_device)+
NETDEV_ALIGN_CONST)
& ~NETDEV_ALIGN_CONST);
}

The above code is somehow calculating some alignment requirement I was a bit confused on how it is being done.

Always friendly wikipedia answered my queries here

No comments:

Post a Comment