aboutsummaryrefslogtreecommitdiffstats
path: root/host/lib/usrp/common/ad9361_transaction.h
diff options
context:
space:
mode:
authorJosh Blum <josh@joshknows.com>2013-09-06 14:41:35 -0700
committerJosh Blum <josh@joshknows.com>2013-09-06 14:41:35 -0700
commit0184989a5f716d99435409279ce5cd1f78d98544 (patch)
tree4caa18a9e0f2d46216cbed9b7684f1498594d1d9 /host/lib/usrp/common/ad9361_transaction.h
parente8dfc4638222689c875f3c399c1dec667dca082d (diff)
downloaduhd-0184989a5f716d99435409279ce5cd1f78d98544.tar.gz
uhd-0184989a5f716d99435409279ce5cd1f78d98544.tar.bz2
uhd-0184989a5f716d99435409279ce5cd1f78d98544.zip
b200: use a union to perform double pack/unpack
Diffstat (limited to 'host/lib/usrp/common/ad9361_transaction.h')
-rw-r--r--host/lib/usrp/common/ad9361_transaction.h22
1 files changed, 14 insertions, 8 deletions
diff --git a/host/lib/usrp/common/ad9361_transaction.h b/host/lib/usrp/common/ad9361_transaction.h
index 7b41b811f..7cbad5908 100644
--- a/host/lib/usrp/common/ad9361_transaction.h
+++ b/host/lib/usrp/common/ad9361_transaction.h
@@ -41,20 +41,26 @@ extern "C" {
#define AD9361_ACTION_SET_CLOCK_RATE 9
#define AD9361_ACTION_SET_ACTIVE_CHAINS 10
+typedef union
+{
+ double d;
+ uint32_t x[2];
+} ad9361_double_union_t;
+
static inline void ad9361_double_pack(const double input, uint32_t output[2])
{
- const uint32_t *p = (const uint32_t *)&input;
- output[0] = p[0];
- output[1] = p[1];
+ ad9361_double_union_t p = {};
+ p.d = input;
+ output[0] = p.x[0];
+ output[1] = p.x[1];
}
static inline double ad9361_double_unpack(const uint32_t input[2])
{
- double output = 0.0;
- uint32_t *p = (uint32_t *)&output;
- p[0] = input[0];
- p[1] = input[1];
- return output;
+ ad9361_double_union_t p = {};
+ p.x[0] = input[0];
+ p.x[1] = input[1];
+ return p.d;
}
typedef struct