1 #ifndef KVM__LINUX_KERNEL_H_ 2 #define KVM__LINUX_KERNEL_H_ 3 4 #define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d)) 5 6 #define ALIGN(x,a) __ALIGN_MASK(x,(typeof(x))(a)-1) 7 #define __ALIGN_MASK(x,mask) (((x)+(mask))&~(mask)) 8 9 #ifndef offsetof 10 #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) 11 #endif 12 13 #ifndef container_of 14 /** 15 * container_of - cast a member of a structure out to the containing structure 16 * @ptr: the pointer to the member. 17 * @type: the type of the container struct this is embedded in. 18 * @member: the name of the member within the struct. 19 * 20 */ 21 #define container_of(ptr, type, member) ({ \ 22 const typeof(((type *)0)->member) * __mptr = (ptr); \ 23 (type *)((char *)__mptr - offsetof(type, member)); }) 24 #endif 25 26 #endif 27