X-Git-Url: https://scm.lunaixsky.com/lunaix-os.git/blobdiff_plain/28c176b668c841a3b7fb093faccf0efa39257603..4cf445cb569be5f1f078ea27fd5d1b172402f44f:/lunaix-os/includes/lunaix/types.h diff --git a/lunaix-os/includes/lunaix/types.h b/lunaix-os/includes/lunaix/types.h index 52faac3..6ce5fcf 100644 --- a/lunaix-os/includes/lunaix/types.h +++ b/lunaix-os/includes/lunaix/types.h @@ -2,6 +2,7 @@ #define __LUNAIX_TYPES_H #include +#include #include #include @@ -43,9 +44,15 @@ typedef int bool; #define container_of(ptr, type, member) \ ({ \ const typeof(((type*)0)->member)* __mptr = (ptr); \ - (ptr) ? (type*)((char*)__mptr - offsetof(type, member)) : 0; \ + ((ptr_t)ptr != 0UL) ? (type*)((char*)__mptr - offsetof(type, member)) : 0; \ }) +#define offset(data, off) \ + ((typeof(data))(__ptr(data) + (off))) + +#define offset_t(data, type, off) \ + ((type*)(__ptr(data) + (off))) + #define __ptr(val) ((ptr_t)(val)) typedef va_list* sc_va_list;