andrzej-kaczmarek closed pull request #1508: kernel/os: Add helper CONTAINER_OF macro URL: https://github.com/apache/mynewt-core/pull/1508
This is a PR merged from a forked repository. As GitHub hides the original diff on merge, it is displayed below for the sake of provenance: As this is a foreign pull request (from a fork), the diff is supplied below (as it won't show otherwise due to GitHub magic): diff --git a/kernel/os/include/os/util.h b/kernel/os/include/os/util.h index d84d0a3bc7..b04c57ff07 100644 --- a/kernel/os/include/os/util.h +++ b/kernel/os/include/os/util.h @@ -26,4 +26,8 @@ #define POINTER_TO_INT(p) ((int) ((intptr_t) (p))) #define INT_TO_POINTER(u) ((void *) ((intptr_t) (u))) +/* Helper to retrieve pointer to "parent" object in structure */ +#define CONTAINER_OF(ptr, type, field) \ + ((type *)(((char *)(ptr)) - offsetof(type, field))) + #endif ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services