From a6b67f90c3fd4a2d2880649bea7e95df0f35bb08 Mon Sep 17 00:00:00 2001 From: Lucas De Marchi Date: Mon, 21 May 2012 20:22:12 -0300 Subject: [PATCH] libkmod-util: copy macros for unaligned access from BlueZ --- libkmod/libkmod-util.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/libkmod/libkmod-util.h b/libkmod/libkmod-util.h index 163b1873..ffe7c43e 100644 --- a/libkmod/libkmod-util.h +++ b/libkmod/libkmod-util.h @@ -25,4 +25,20 @@ char *modname_normalize(const char *modname, char buf[PATH_MAX], size_t *len) __ char *path_to_modname(const char *path, char buf[PATH_MAX], size_t *len) __attribute__((nonnull(2))); unsigned long long stat_mstamp(const struct stat *st); +#define get_unaligned(ptr) \ +({ \ + struct __attribute__((packed)) { \ + typeof(*(ptr)) __v; \ + } *__p = (typeof(__p)) (ptr); \ + __p->__v; \ +}) + +#define bt_put_unaligned(val, ptr) \ +do { \ + struct __attribute__((packed)) { \ + typeof(*(ptr)) __v; \ + } *__p = (typeof(__p)) (ptr); \ + __p->__v = (val); \ +} while(0) + #endif -- 2.47.2