diff options
author | Marcel Holtmann <marcel@holtmann.org> | 2004-04-03 08:25:58 +0000 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2004-04-03 08:25:58 +0000 |
commit | ee63ac598e56142ba513729d6b69df04d233d186 (patch) | |
tree | 621db2847aa9e2ea9b1fbd7624d5da3df9904766 /include/bluetooth.h | |
parent | db3ac6f0370159237530248efa79557c2cd98499 (diff) |
Add support for unaligned access
Diffstat (limited to 'include/bluetooth.h')
-rw-r--r-- | include/bluetooth.h | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/include/bluetooth.h b/include/bluetooth.h index 8690f456..3dc4b245 100644 --- a/include/bluetooth.h +++ b/include/bluetooth.h @@ -86,6 +86,19 @@ enum { #error "Unknown byte order" #endif +/* Bluetooth unaligned access */ +#if defined(__i386__) +#define bt_get_unaligned(ptr) (*(ptr)) +#define bt_put_unaligned(val, ptr) ((void)( *(ptr) = (val) )) +#else +#define bt_get_unaligned(ptr) \ + ({ __typeof__(*(ptr)) __tmp; memcpy(&__tmp, (ptr), sizeof(*(ptr))); __tmp; }) +#define bt_put_unaligned(val, ptr) \ + ({ __typeof__(*(ptr)) __tmp = (val); \ + memcpy((ptr), &__tmp, sizeof(*(ptr))); \ + (void)0; }) +#endif + /* BD Address */ typedef struct { uint8_t b[6]; |