From 37af455dff71ab08070e48f6a848e326a52902ca Mon Sep 17 00:00:00 2001 From: Andreas Fankhauser hiddenalpha.ch Date: Wed, 24 Apr 2024 21:33:01 +0200 Subject: Add a standalone container_of impl. Fix assert_is template. --- src/main/c/common/offset_of.h | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 src/main/c/common/offset_of.h (limited to 'src/main/c/common/offset_of.h') diff --git a/src/main/c/common/offset_of.h b/src/main/c/common/offset_of.h new file mode 100644 index 0000000..7d9179d --- /dev/null +++ b/src/main/c/common/offset_of.h @@ -0,0 +1,9 @@ +#ifndef INCGUARD_yisgKqALPG4lfEqb +#define INCGUARD_yisgKqALPG4lfEqb + + +#define container_of(P, T, M) \ + ((T*)( ((size_t)P) - ((size_t)((char*)&((T*)0)->M - (char*)0) ))) + + +#endif /* INCGUARD_yisgKqALPG4lfEqb */ -- cgit v1.1