/**tyLLinux联盟 * container_of - cast a member of a structure out to the containing structuretyLLinux联盟 * @ptr: the pointer to the member.tyLLinux联盟 * @type: the type of the container struct this is embedded in.tyLLinux联盟 * @member: the name of the member within the struct.tyLLinux联盟 *tyLLinux联盟 */tyLLinux联盟 #define container_of(ptr, type, member)({ /tyLLinux联盟 consttypeof(((type *)0)->member )*__mptr =(ptr); /tyLLinux联盟 (type *)((char*)__mptr -offsetof(type,member));})tyLLinux联盟 tyLLinux联盟 tyLLinux联盟 //#define container_of(ptr,type,member)tyLLinux联盟 tyLLinux联盟 //({ /tyLLinux联盟 tyLLinux联盟 // const typeof(((type *)0)->member) *__mptr = (ptr); / //仅仅计算一次tyLLinux联盟 tyLLinux联盟 // (type *)((char *)__mptr - offsetof(type,member)) ; /tyLLinux联盟 tyLLinux联盟 //})tyLLinux联盟 tyLLinux联盟 tyLLinux联盟 tyLLinux联盟 tyLLinux联盟 /**tyLLinux联盟 * list_entry - get the struct for this entrytyLLinux联盟 * @ptr: the &struct list_head pointer.tyLLinux联盟 * @type: the type of the struct this is embedded in.tyLLinux联盟 * @member: the name of the list_struct within the struct.tyLLinux联盟 */tyLLinux联盟 #define list_entry(ptr, type, member) /tyLLinux联盟 container_of(ptr, type, member)tyLLinux联盟 tyLLinux联盟 //#define abs(x) ((x) > 0)?(x):(-(x))tyLLinux联盟 tyLLinux联盟 tyLLinux联盟 /*tyLLinux联盟 * ..and if you can't take the stricttyLLinux联盟 * types, you can specify one yourself.tyLLinux联盟 *tyLLinux联盟 * Or not use min/max at all, of course.tyLLinux联盟 */tyLLinux联盟 #define MIN_T(type,x,y) /tyLLinux联盟 ({ type __x =(x); type __y =(y); __x < __y ? __x: __y;})tyLLinux联盟 #define MAX_T(type,x,y) /tyLLinux联盟 ({ type __x =(x); type __y =(y); __x > __y ? __x: __y;})tyLLinux联盟 tyLLinux联盟 #defineMAX(x,y)((x)>(y)?(x):(y))tyLLinux联盟 #define MAX_CHECK(x,y) /tyLLinux联盟 ({ /tyLLinux联盟 typeof(x) __x =(x); /tyLLinux联盟 typeof(y) __y =(y); /tyLLinux联盟 (void)(&__x ==&__y); /tyLLinux联盟 (__x>__y)?__x:__y ;/tyLLinux联盟 })