diff options
author | Lucas De Marchi <lucas.demarchi@profusion.mobi> | 2012-05-21 20:22:12 -0300 |
---|---|---|
committer | Lucas De Marchi <lucas.demarchi@profusion.mobi> | 2012-05-21 20:22:12 -0300 |
commit | a6b67f90c3fd4a2d2880649bea7e95df0f35bb08 (patch) | |
tree | 7cb560c2e957843ea3e2baaa08a825112eca1aac | |
parent | d30319e4335bcf76101e28d81c9a7c2ec9187cb7 (diff) | |
download | kmod-a6b67f90c3fd4a2d2880649bea7e95df0f35bb08.tar.gz |
libkmod-util: copy macros for unaligned access from BlueZ
-rw-r--r-- | libkmod/libkmod-util.h | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/libkmod/libkmod-util.h b/libkmod/libkmod-util.h index 163b187..ffe7c43 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 |