[riot-notifications] [RIOT-OS/RIOT] sys: Add helpers for pointer tagging (#15440)
notifications at github.com
Fri Nov 13 19:21:18 CET 2020
@chrysn commented on this pull request.
> + * @details This will ensure a minimum alignment of 4 bytes
+#define PTRTAG __attribute__((aligned(4)))
+ * @brief Create a tagged pointer
+ * @param ptr Pointer to tag
+ * @param tag Tag to add
+ * @return Tagged pointer encoding both @p ptr and @p tag
+ * @pre @p ptr points to data marked with @ref PTRTAG
+ * @pre @p tag contains a two bit value (its numeric value 0, 1, 2, or 3)
+ * Expect assertions blowing up when the preconditions are not met.
+static inline __attribute__((always_inline)) void * ptrtag(void *ptr, uint8_t tag)
Why `always_inline`? On machines where shift-and-or is cheap, the compiler will do this already due to the inline, and if it's not, isn't it good if the compiler honors the `-Os` if it gets one?
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the notifications