[riot-notifications] [RIOT-OS/RIOT] sys: add unaligned.h (header for alignment safe value-from-pointer functions) (#10797)

Kaspar Schleiser notifications at github.com
Mon Jan 21 14:10:38 CET 2019


kaspar030 commented on this pull request.



> +
+/** @brief Unaligned access helper struct (uint16_t version) */
+typedef struct {
+    uint16_t val;       /**< value */
+} __attribute__((packed)) uint16_una_t;
+
+/**
+ * @brief    Get uint16_t from possibly unaligned pointer
+ *
+ * @param[in]   ptr pointer to read from
+ *
+ * @returns value read from @p ptr
+ */
+static inline uint16_t get_unaligned_u16(const uint16_t *ptr)
+{
+    const uint16_una_t *tmp = (const uint16_una_t *)ptr;

Is it? How?

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/RIOT-OS/RIOT/pull/10797#discussion_r249444002
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20190121/a5c1e1f1/attachment.html>


More information about the notifications mailing list