From: Lucas De Marchi Date: Mon, 21 May 2012 23:22:12 +0000 (-0300) Subject: libkmod-util: copy macros for unaligned access from BlueZ X-Git-Tag: v9~39 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a6b67f90c3fd4a2d2880649bea7e95df0f35bb08;p=thirdparty%2Fkmod.git libkmod-util: copy macros for unaligned access from BlueZ --- 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