summaryrefslogtreecommitdiff
path: root/android/hal-utils.h
diff options
context:
space:
mode:
authorSzymon Janc <szymon.janc@tieto.com>2014-09-26 15:42:16 +0200
committerSzymon Janc <szymon.janc@gmail.com>2014-09-29 17:26:55 +0200
commitda50c27b5d3d930f2ece35e417f30e2ead5acd17 (patch)
tree49655485c7c4bd6e4becfb0f755dcebde28bf947 /android/hal-utils.h
parent21d3e1230379dbe50f90427aa4e4c0304fbcf8ba (diff)
downloadbluez-da50c27b5d3d930f2ece35e417f30e2ead5acd17.tar.gz
android/hal: Add simple helpers for unaligned memory access
In HALs we usually don't operate on unaligned memory. Only exception are PCM stereo<->mono mixing scenarios in sco and audio HALs.
Diffstat (limited to 'android/hal-utils.h')
-rw-r--r--android/hal-utils.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/android/hal-utils.h b/android/hal-utils.h
index a2ae0f48b..ee0320c92 100644
--- a/android/hal-utils.h
+++ b/android/hal-utils.h
@@ -15,6 +15,8 @@
*
*/
+#include <endian.h>
+
#include <hardware/bluetooth.h>
#define PLATFORM_VER(a,b,c) ((a << 16) | ( b << 8) | (c))
@@ -132,3 +134,21 @@ DECINTMAP(bt_bond_state_t);
DECINTMAP(bt_ssp_variant_t);
DECINTMAP(bt_property_type_t);
DECINTMAP(bt_cb_thread_evt);
+
+static inline uint16_t get_le16(const void *src)
+{
+ const struct __attribute__((packed)) {
+ uint16_t le16;
+ } *p = src;
+
+ return le16toh(p->le16);
+}
+
+static inline void put_le16(uint16_t val, void *dst)
+{
+ struct __attribute__((packed)) {
+ uint16_t le16;
+ } *p = dst;
+
+ p->le16 = htole16(val);
+}