From e7cc8eafa03d975a6c6603cb5f143c68d1fcdd2b Mon Sep 17 00:00:00 2001 From: Andreas Fankhauser hiddenalpha.ch Date: Sat, 5 Oct 2024 12:36:41 +0200 Subject: Cleanup container_of.h for even easier CopyPasta --- src/main/c/common/container_of.h | 4 ++++ src/main/c/common/offset_of.h | 9 --------- 2 files changed, 4 insertions(+), 9 deletions(-) create mode 100644 src/main/c/common/container_of.h delete mode 100644 src/main/c/common/offset_of.h diff --git a/src/main/c/common/container_of.h b/src/main/c/common/container_of.h new file mode 100644 index 0000000..c484697 --- /dev/null +++ b/src/main/c/common/container_of.h @@ -0,0 +1,4 @@ +#ifndef container_of +# define container_of(P, T, M) \ + ((T*)( ((size_t)P) - ((size_t)((char*)&((T*)0)->M - (char*)0) ))) +#endif diff --git a/src/main/c/common/offset_of.h b/src/main/c/common/offset_of.h deleted file mode 100644 index 7d9179d..0000000 --- a/src/main/c/common/offset_of.h +++ /dev/null @@ -1,9 +0,0 @@ -#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