diff options
author | Andreas Fankhauser hiddenalpha.ch | 2024-04-24 21:33:01 +0200 |
---|---|---|
committer | Andreas Fankhauser hiddenalpha.ch | 2024-04-24 21:33:01 +0200 |
commit | 37af455dff71ab08070e48f6a848e326a52902ca (patch) | |
tree | 6765a00fb4fa924b1985f4f2988f1b21cbeb367a /src/main/c/common/offset_of.h | |
parent | e17b8876cfafae081784d5cf1258ce16c50e283a (diff) | |
download | UnspecifiedGarbage-37af455dff71ab08070e48f6a848e326a52902ca.zip UnspecifiedGarbage-37af455dff71ab08070e48f6a848e326a52902ca.tar.gz |
Add a standalone container_of impl. Fix assert_is template.
Diffstat (limited to 'src/main/c/common/offset_of.h')
-rw-r--r-- | src/main/c/common/offset_of.h | 9 |
1 files changed, 9 insertions, 0 deletions
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 */ |