[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] [gnuradio] 04/04: MSVC-specific fixes for compatibilit
From: |
git |
Subject: |
[Commit-gnuradio] [gnuradio] 04/04: MSVC-specific fixes for compatibility |
Date: |
Mon, 30 May 2016 21:23:21 +0000 (UTC) |
This is an automated email from the git hooks/post-receive script.
jcorgan pushed a commit to branch maint
in repository gnuradio.
commit 23460e36094ad85c559a538918c3b40e76b2fa37
Author: gnieboer <address@hidden>
Date: Sun May 22 10:38:19 2016 +0300
MSVC-specific fixes for compatibility
* Changed dtv_viterbi_decoder to use __GR_ATTR_ALIGNED macro for
cross-compiler compatibility
* Replace usleep() with boost equivalent for cross-compiler
compatibility
* Includes windows-specific headers for portaudio
* Added macro to handle use of VLAs on non-C99 compilers (MSVC) using
alloca to declare variable length arrays
* Remove setting SO_LINGER option for the UDP source. SO_LINGER is
not an applicable option for a UDP socket. Windows will throw an
exception if set. Linux allows it to be set but does not use it.
* VS 2013+ supports round()
---
gnuradio-runtime/include/gnuradio/attributes.h | 11 ++++++++++
gr-audio/lib/portaudio/portaudio_sink.cc | 3 +++
gr-audio/lib/portaudio/portaudio_source.cc | 3 +++
gr-blocks/lib/udp_source_impl.cc | 3 ---
.../lib/dvbt/dvbt_bit_inner_deinterleaver_impl.cc | 5 +++--
gr-dtv/lib/dvbt/dvbt_bit_inner_interleaver_impl.cc | 3 ++-
gr-dtv/lib/dvbt/dvbt_ofdm_sym_acquisition_impl.cc | 4 ++--
gr-dtv/lib/dvbt/dvbt_reed_solomon.cc | 14 ++++++-------
gr-dtv/lib/dvbt/dvbt_viterbi_decoder_impl.cc | 24 +++++++++++-----------
gr-vocoder/lib/codec2/fdmdv.c | 2 +-
gr-zeromq/lib/pull_msg_source_impl.cc | 4 +++-
gr-zeromq/lib/req_msg_source_impl.cc | 4 +++-
gr-zeromq/lib/sub_msg_source_impl.cc | 4 +++-
13 files changed, 53 insertions(+), 31 deletions(-)
diff --git a/gnuradio-runtime/include/gnuradio/attributes.h
b/gnuradio-runtime/include/gnuradio/attributes.h
index 3d2e764..0102c11 100644
--- a/gnuradio-runtime/include/gnuradio/attributes.h
+++ b/gnuradio-runtime/include/gnuradio/attributes.h
@@ -78,4 +78,15 @@
# pragma warning(disable: 4290) // C++ exception specification ignored except
to indicate a function is not __declspec(nothrow)
#endif
+////////////////////////////////////////////////////////////////////////
+// implement cross-compiler VLA macros
+////////////////////////////////////////////////////////////////////////
+#ifdef C99
+# define __GR_VLA(TYPE, buf, size) TYPE buf[size]
+# define __GR_VLA2D(TYPE, buf, size, size2) TYPE buf[size][size2]
+#else
+# define __GR_VLA(TYPE, buf, size) TYPE * buf = (TYPE *) alloca(sizeof(TYPE)
* (size))
+# define __GR_VLA2D(TYPE, buf, size, size2) TYPE ** buf = (TYPE **)
alloca(sizeof(TYPE) * (size) * (size2))
+#endif
+
#endif /* INCLUDED_GNURADIO_ATTRIBUTES_H */
diff --git a/gr-audio/lib/portaudio/portaudio_sink.cc
b/gr-audio/lib/portaudio/portaudio_sink.cc
index 4a0a969..2397b65 100644
--- a/gr-audio/lib/portaudio/portaudio_sink.cc
+++ b/gr-audio/lib/portaudio/portaudio_sink.cc
@@ -34,6 +34,9 @@
#include <unistd.h>
#include <stdexcept>
#include <string.h>
+#ifdef _MSC_VER
+#include <io.h>
+#endif
namespace gr {
namespace audio {
diff --git a/gr-audio/lib/portaudio/portaudio_source.cc
b/gr-audio/lib/portaudio/portaudio_source.cc
index efbe2b6..1e1bbfa 100644
--- a/gr-audio/lib/portaudio/portaudio_source.cc
+++ b/gr-audio/lib/portaudio/portaudio_source.cc
@@ -34,6 +34,9 @@
#include <unistd.h>
#include <stdexcept>
#include <string.h>
+#ifdef _MSC_VER
+#include <io.h>
+#endif
namespace gr {
namespace audio {
diff --git a/gr-blocks/lib/udp_source_impl.cc b/gr-blocks/lib/udp_source_impl.cc
index e09ed43..c3705d8 100644
--- a/gr-blocks/lib/udp_source_impl.cc
+++ b/gr-blocks/lib/udp_source_impl.cc
@@ -93,9 +93,6 @@ namespace gr {
d_socket = new boost::asio::ip::udp::socket(d_io_service);
d_socket->open(d_endpoint.protocol());
- boost::asio::socket_base::linger loption(true, 0);
- d_socket->set_option(loption);
-
boost::asio::socket_base::reuse_address roption(true);
d_socket->set_option(roption);
diff --git a/gr-dtv/lib/dvbt/dvbt_bit_inner_deinterleaver_impl.cc
b/gr-dtv/lib/dvbt/dvbt_bit_inner_deinterleaver_impl.cc
index bf7613a..9e45c81 100644
--- a/gr-dtv/lib/dvbt/dvbt_bit_inner_deinterleaver_impl.cc
+++ b/gr-dtv/lib/dvbt/dvbt_bit_inner_deinterleaver_impl.cc
@@ -135,8 +135,9 @@ namespace gr {
// First index of d_b is Bit interleaver number
// Second index of d_b is the position inside Bit interleaver
- unsigned char d_b[d_v][d_bsize];
-
+ // Linux: unsigned char d_b[d_v][d_bsize];
+ __GR_VLA2D(unsigned char, d_b, d_v, d_bsize);
+
for (int bcount = 0; bcount < bmax; bcount++) {
for (int w = 0; w < d_bsize; w++) {
int c = in[(bcount * d_bsize) + w];
diff --git a/gr-dtv/lib/dvbt/dvbt_bit_inner_interleaver_impl.cc
b/gr-dtv/lib/dvbt/dvbt_bit_inner_interleaver_impl.cc
index 0ab3003..d2bfb3d 100644
--- a/gr-dtv/lib/dvbt/dvbt_bit_inner_interleaver_impl.cc
+++ b/gr-dtv/lib/dvbt/dvbt_bit_inner_interleaver_impl.cc
@@ -136,7 +136,8 @@ namespace gr {
// First index of d_b is Bit interleaver number
// Second index of d_b is the position inside the Bit interleaver
- unsigned char d_b[d_v][d_bsize];
+ // Linux: unsigned char d_b[d_v][d_bsize];
+ __GR_VLA2D(unsigned char, d_b, d_v, d_bsize);
for (int bcount = 0; bcount < bmax; bcount++) {
for (int i = 0; i < d_bsize; i++) {
diff --git a/gr-dtv/lib/dvbt/dvbt_ofdm_sym_acquisition_impl.cc
b/gr-dtv/lib/dvbt/dvbt_ofdm_sym_acquisition_impl.cc
index 84b20f9..6617c2c 100644
--- a/gr-dtv/lib/dvbt/dvbt_ofdm_sym_acquisition_impl.cc
+++ b/gr-dtv/lib/dvbt/dvbt_ofdm_sym_acquisition_impl.cc
@@ -109,8 +109,8 @@ namespace gr {
int low, size;
// Array to store peak positions
- int peak_pos[d_fft_length];
- float d_phi[d_fft_length];
+ __GR_VLA(int, peak_pos, d_fft_length);
+ __GR_VLA(float, d_phi, d_fft_length);
// Calculate norm
low = lookup_stop - (d_cp_length + d_fft_length - 1);
diff --git a/gr-dtv/lib/dvbt/dvbt_reed_solomon.cc
b/gr-dtv/lib/dvbt/dvbt_reed_solomon.cc
index 6277350..7d67a0a 100644
--- a/gr-dtv/lib/dvbt/dvbt_reed_solomon.cc
+++ b/gr-dtv/lib/dvbt/dvbt_reed_solomon.cc
@@ -245,13 +245,13 @@ namespace gr {
int
dvbt_reed_solomon::rs_decode(unsigned char *data, unsigned char *eras,
const int no_eras)
{
- unsigned char sigma[2 * d_t + 1];
- unsigned char b[2 * d_t + 1];
- unsigned char T[2 * d_t + 1];
- unsigned char reg[2 * d_t + 1];
- unsigned char root[2 * d_t + 1];
- unsigned char loc[2 * d_t + 1];
- unsigned char omega[2 * d_t];
+ __GR_VLA(unsigned char, sigma, 2 * d_t + 1);
+ __GR_VLA(unsigned char, b, 2 * d_t + 1);
+ __GR_VLA(unsigned char, T, 2 * d_t + 1);
+ __GR_VLA(unsigned char, reg, 2 * d_t + 1);
+ __GR_VLA(unsigned char, root, 2 * d_t + 1);
+ __GR_VLA(unsigned char, loc, 2 * d_t + 1);
+ __GR_VLA(unsigned char, omega, 2 * d_t);
// Compute erasure locator polynomial
memset(sigma, 0, 2 * d_t + 1);
diff --git a/gr-dtv/lib/dvbt/dvbt_viterbi_decoder_impl.cc
b/gr-dtv/lib/dvbt/dvbt_viterbi_decoder_impl.cc
index 8e22d8d..05554c5 100644
--- a/gr-dtv/lib/dvbt/dvbt_viterbi_decoder_impl.cc
+++ b/gr-dtv/lib/dvbt/dvbt_viterbi_decoder_impl.cc
@@ -71,25 +71,25 @@ namespace gr {
};
#ifdef DTV_SSE2
- __m128i dvbt_viterbi_decoder_impl::d_metric0[4] __attribute__
((aligned(16)));
- __m128i dvbt_viterbi_decoder_impl::d_metric1[4] __attribute__
((aligned(16)));
- __m128i dvbt_viterbi_decoder_impl::d_path0[4] __attribute__
((aligned(16)));
- __m128i dvbt_viterbi_decoder_impl::d_path1[4] __attribute__
((aligned(16)));
+ __GR_ATTR_ALIGNED(16) __m128i dvbt_viterbi_decoder_impl::d_metric0[4];
+ __GR_ATTR_ALIGNED(16) __m128i dvbt_viterbi_decoder_impl::d_metric1[4];
+ __GR_ATTR_ALIGNED(16) __m128i dvbt_viterbi_decoder_impl::d_path0[4];
+ __GR_ATTR_ALIGNED(16) __m128i dvbt_viterbi_decoder_impl::d_path1[4];
#else
- unsigned char dvbt_viterbi_decoder_impl::d_metric0_generic[64]
__attribute__ ((aligned(16)));
- unsigned char dvbt_viterbi_decoder_impl::d_metric1_generic[64]
__attribute__ ((aligned(16)));
- unsigned char dvbt_viterbi_decoder_impl::d_path0_generic[64] __attribute__
((aligned(16)));
- unsigned char dvbt_viterbi_decoder_impl::d_path1_generic[64] __attribute__
((aligned(16)));
+ __GR_ATTR_ALIGNED(16) unsigned char
dvbt_viterbi_decoder_impl::d_metric0_generic[64];
+ __GR_ATTR_ALIGNED(16) unsigned char
dvbt_viterbi_decoder_impl::d_metric1_generic[64];
+ __GR_ATTR_ALIGNED(16) unsigned char
dvbt_viterbi_decoder_impl::d_path0_generic[64];
+ __GR_ATTR_ALIGNED(16) unsigned char
dvbt_viterbi_decoder_impl::d_path1_generic[64];
#endif
#ifdef DTV_SSE2
- branchtab27 dvbt_viterbi_decoder_impl::Branchtab27_sse2[2] __attribute__
((aligned(16)));
+ __GR_ATTR_ALIGNED(16) branchtab27
dvbt_viterbi_decoder_impl::Branchtab27_sse2[2];
#else
- branchtab27 dvbt_viterbi_decoder_impl::Branchtab27_generic[2]
__attribute__ ((aligned(16)));
+ __GR_ATTR_ALIGNED(16) branchtab27
dvbt_viterbi_decoder_impl::Branchtab27_generic[2];
#endif
- unsigned char dvbt_viterbi_decoder_impl::mmresult[64]
__attribute__((aligned(16)));
- unsigned char dvbt_viterbi_decoder_impl::ppresult[TRACEBACK_MAX][64]
__attribute__((aligned(16)));
+ __GR_ATTR_ALIGNED(16) unsigned char
dvbt_viterbi_decoder_impl::mmresult[64];
+ __GR_ATTR_ALIGNED(16) unsigned char
dvbt_viterbi_decoder_impl::ppresult[TRACEBACK_MAX][64];
#ifdef DTV_SSE2
void
diff --git a/gr-vocoder/lib/codec2/fdmdv.c b/gr-vocoder/lib/codec2/fdmdv.c
index 8855f76..51d6bef 100644
--- a/gr-vocoder/lib/codec2/fdmdv.c
+++ b/gr-vocoder/lib/codec2/fdmdv.c
@@ -25,7 +25,7 @@
along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
-#ifdef _MSC_VER
+#if defined(_MSC_VER) && (_MSC_VER < 1800) // round() not available before VS
2013
#define round(number) number < 0.0 ? ceil(number - 0.5) : floor(number + 0.5)
#endif
diff --git a/gr-zeromq/lib/pull_msg_source_impl.cc
b/gr-zeromq/lib/pull_msg_source_impl.cc
index ca496ef..9d00cdf 100644
--- a/gr-zeromq/lib/pull_msg_source_impl.cc
+++ b/gr-zeromq/lib/pull_msg_source_impl.cc
@@ -25,6 +25,8 @@
#endif
#include <gnuradio/io_signature.h>
+#include <boost/thread/thread.hpp>
+#include <boost/date_time/posix_time/posix_time.hpp>
#include "pull_msg_source_impl.h"
#include "tag_headers.h"
@@ -102,7 +104,7 @@ namespace gr {
message_port_pub(pmt::mp("out"), m);
} else {
- usleep(100);
+ boost::this_thread::sleep(boost::posix_time::microseconds(100));
}
}
}
diff --git a/gr-zeromq/lib/req_msg_source_impl.cc
b/gr-zeromq/lib/req_msg_source_impl.cc
index b30ef26..e231a31 100644
--- a/gr-zeromq/lib/req_msg_source_impl.cc
+++ b/gr-zeromq/lib/req_msg_source_impl.cc
@@ -25,6 +25,8 @@
#endif
#include <gnuradio/io_signature.h>
+#include <boost/thread/thread.hpp>
+#include <boost/date_time/posix_time/posix_time.hpp>
#include "req_msg_source_impl.h"
#include "tag_headers.h"
@@ -114,7 +116,7 @@ namespace gr {
message_port_pub(pmt::mp("out"), m);
} else {
- usleep(100);
+ boost::this_thread::sleep(boost::posix_time::microseconds(100));
}
}
}
diff --git a/gr-zeromq/lib/sub_msg_source_impl.cc
b/gr-zeromq/lib/sub_msg_source_impl.cc
index b016405..0a11ea7 100644
--- a/gr-zeromq/lib/sub_msg_source_impl.cc
+++ b/gr-zeromq/lib/sub_msg_source_impl.cc
@@ -25,6 +25,8 @@
#endif
#include <gnuradio/io_signature.h>
+#include <boost/thread/thread.hpp>
+#include <boost/date_time/posix_time/posix_time.hpp>
#include "sub_msg_source_impl.h"
#include "tag_headers.h"
@@ -101,7 +103,7 @@ namespace gr {
message_port_pub(pmt::mp("out"), m);
} else {
- usleep(100);
+ boost::this_thread::sleep(boost::posix_time::microseconds(100));
}
}
}