From 222aa9f40d9dc2f22954eff3952564cdfb388060 Mon Sep 17 00:00:00 2001 From: f4exb Date: Tue, 13 Nov 2018 10:51:57 +0100 Subject: [PATCH] Windows: MSVC2017: adapt decimators.h to handle packing with MSVC --- plugins/samplesource/airspy/airspy.pro | 2 + sdrbase/dsp/decimators.h | 114 ++++++++++++++++++++++++- 2 files changed, 115 insertions(+), 1 deletion(-) diff --git a/plugins/samplesource/airspy/airspy.pro b/plugins/samplesource/airspy/airspy.pro index 5ba6d7050..600b51672 100644 --- a/plugins/samplesource/airspy/airspy.pro +++ b/plugins/samplesource/airspy/airspy.pro @@ -13,6 +13,8 @@ TARGET = inputairspy CONFIG(MINGW32):LIBAIRSPYSRC = "C:\softs\libairspy" CONFIG(MINGW64):LIBAIRSPYSRC = "C:\softs\libairspy" +CONFIG(MSVC):LIBAIRSPYSRC = "C:\softs\libairspy" + INCLUDEPATH += $$PWD INCLUDEPATH += ../../../exports INCLUDEPATH += ../../../sdrbase diff --git a/sdrbase/dsp/decimators.h b/sdrbase/dsp/decimators.h index ee54b56e9..3979d92f8 100644 --- a/sdrbase/dsp/decimators.h +++ b/sdrbase/dsp/decimators.h @@ -184,6 +184,42 @@ struct decimation_shifts<24, 8> static const uint post64 = 0; }; +#ifdef _MSC_VER +#pragma pack(push,1) +template +struct TripleByteLE +{ + uint8_t b0; + uint8_t b1; + uint8_t b2; + + typedef union { +#pragma pack(push,1) + struct { + int32_t i; + }; +#pragma pack(pop) +#pragma pack(push, 1) + struct { + uint8_t i0; + uint8_t i1; + uint8_t i2; + uint8_t i3; + }; +#pragma pack(pop) + } isample; + + operator T() const { + isample s; + s.i0 = 0; + s.i1 = b0; + s.i2 = b1; + s.i3 = b2; + return s.i; + } +}; +#pragma pack(pop) +#else template struct TripleByteLE { @@ -212,7 +248,44 @@ struct TripleByteLE return s.i; } } __attribute__((__packed__)); +#endif +#ifdef _MSC_VER +#pragma pack(push, 1) +template<> +struct TripleByteLE +{ + uint8_t b0; + uint8_t b1; + uint8_t b2; + + typedef union { +#pragma pack(push, 1) + struct { + qint32 i; + }; +#pragma pack(pop) +#pragma pack(push, 1) + struct { + uint8_t i0; + uint8_t i1; + uint8_t i2; + uint8_t i3; + }; +#pragma pack(pop) + } isample; + + operator qint32() const { + isample s; + s.i0 = 0; + s.i1 = b0; + s.i2 = b1; + s.i3 = b2; + return s.i >> 8; + } +}; +#pragma pack(pop) +#else template<> struct TripleByteLE { @@ -241,7 +314,46 @@ struct TripleByteLE return s.i >> 8; } } __attribute__((__packed__)); +#endif +#ifdef _MSC_VER +#pragma pack(push, 1) +template<> +struct TripleByteLE +{ + uint8_t b0; + uint8_t b1; + uint8_t b2; + + typedef union { +#pragma pack(push, 1) + struct { + qint64 i; + }; +#pragma pack(pop) +#pragma pack(push, 1) + struct { + uint32_t ia; + uint8_t i0; + uint8_t i1; + uint8_t i2; + uint8_t i3; + }; +#pragma pack(pop) + } isample; + + operator qint64() const { + isample s; + s.ia = 0; + s.i0 = 0; + s.i1 = b0; + s.i2 = b1; + s.i3 = b2; + return s.i >> 40; + } +}; +#pragma pack(pop) +#else template<> struct TripleByteLE { @@ -272,7 +384,7 @@ struct TripleByteLE return s.i >> 40; } } __attribute__((__packed__)); - +#endif /** Decimators with integer input and integer output */ template