added container_of macro

This commit is contained in:
Fabrice Bellard
2023-12-22 11:03:44 +01:00
parent 1692f2a7a3
commit c3599515c8
3 changed files with 5 additions and 3 deletions

View File

@@ -49,6 +49,9 @@
#define countof(x) (sizeof(x) / sizeof((x)[0]))
#endif
/* return the pointer of type 'type *' containing 'ptr' as field 'member' */
#define container_of(ptr, type, member) ((type *)((uint8_t *)(ptr) - offsetof(type, member)))
typedef int BOOL;
#ifndef FALSE