summaryrefslogtreecommitdiff
path: root/gnuradio-core/src
diff options
context:
space:
mode:
Diffstat (limited to 'gnuradio-core/src')
-rw-r--r--gnuradio-core/src/lib/reed-solomon/CMakeLists.txt17
-rw-r--r--gnuradio-core/src/lib/reed-solomon/decode_rs.c8
-rw-r--r--gnuradio-core/src/lib/reed-solomon/exercise.c9
3 files changed, 28 insertions, 6 deletions
diff --git a/gnuradio-core/src/lib/reed-solomon/CMakeLists.txt b/gnuradio-core/src/lib/reed-solomon/CMakeLists.txt
index 4a495f9f9..5640b12a2 100644
--- a/gnuradio-core/src/lib/reed-solomon/CMakeLists.txt
+++ b/gnuradio-core/src/lib/reed-solomon/CMakeLists.txt
@@ -20,10 +20,18 @@
########################################################################
# This file included, use CMake directory variables
########################################################################
-IF(NOT MSVC) #FIXME can't build reed-solomon in MSVC.
-#The rs sources use a lot of non-standard code
-#like the array allocation and some c99 functions.
-#In short, will not fix unless someone asks nicely.
+#MSVC workaround: we cant have dynamically sized arrays.
+#So ifdef a max array bounds that is larger than NN and NROOTS
+#Its a bit of a hack, but if you look at the code, its so full of ifdefs,
+#and lacks optimization where it should be pre-allocating these arrays.
+IF(MSVC)
+ SET_SOURCE_FILES_PROPERTIES(
+ ${CMAKE_CURRENT_SOURCE_DIR}/exercise.c
+ ${CMAKE_CURRENT_SOURCE_DIR}/decode_rs.c
+ PROPERTIES COMPILE_DEFINITIONS "MAX_ARRAY=256;"
+ )
+ENDIF(MSVC)
+
SET(gr_core_rs_sources
${CMAKE_CURRENT_SOURCE_DIR}/encode_rs.c
${CMAKE_CURRENT_SOURCE_DIR}/decode_rs.c
@@ -52,4 +60,3 @@ ADD_EXECUTABLE(gr_core_rstest
)
ADD_TEST(gr-core-reed-solomon-test gr_core_rstest)
ENDIF(ENABLE_TESTING)
-ENDIF(NOT MSVC)
diff --git a/gnuradio-core/src/lib/reed-solomon/decode_rs.c b/gnuradio-core/src/lib/reed-solomon/decode_rs.c
index ca409782f..ba60b89ee 100644
--- a/gnuradio-core/src/lib/reed-solomon/decode_rs.c
+++ b/gnuradio-core/src/lib/reed-solomon/decode_rs.c
@@ -31,11 +31,19 @@ DTYPE *data, int *eras_pos, int no_eras){
#endif
int deg_lambda, el, deg_omega;
int i, j, r,k;
+#ifdef MAX_ARRAY
+ DTYPE u,q,tmp,num1,num2,den,discr_r;
+ DTYPE lambda[MAX_ARRAY], s[MAX_ARRAY]; /* Err+Eras Locator poly
+ * and syndrome poly */
+ DTYPE b[MAX_ARRAY], t[MAX_ARRAY], omega[MAX_ARRAY];
+ DTYPE root[MAX_ARRAY], reg[MAX_ARRAY], loc[MAX_ARRAY];
+#else
DTYPE u,q,tmp,num1,num2,den,discr_r;
DTYPE lambda[NROOTS+1], s[NROOTS]; /* Err+Eras Locator poly
* and syndrome poly */
DTYPE b[NROOTS+1], t[NROOTS+1], omega[NROOTS+1];
DTYPE root[NROOTS], reg[NROOTS+1], loc[NROOTS];
+#endif
int syn_error, count;
/* form the syndromes; i.e., evaluate data(x) at roots of g(x) */
diff --git a/gnuradio-core/src/lib/reed-solomon/exercise.c b/gnuradio-core/src/lib/reed-solomon/exercise.c
index 1e04f618d..987fe1aeb 100644
--- a/gnuradio-core/src/lib/reed-solomon/exercise.c
+++ b/gnuradio-core/src/lib/reed-solomon/exercise.c
@@ -13,7 +13,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <strings.h>
#ifdef FIXED
#include "fixed.h"
@@ -47,11 +46,19 @@ int trials){
#if !defined(CCSDS) && !defined(FIXED)
struct rs *rs = (struct rs *)p;
#endif
+#if MAX_ARRAY
+ DTYPE block[MAX_ARRAY],tblock[MAX_ARRAY];
+ int i;
+ int errors;
+ int errlocs[MAX_ARRAY];
+ int derrlocs[MAX_ARRAY];
+#else
DTYPE block[NN],tblock[NN];
int i;
int errors;
int errlocs[NN];
int derrlocs[NROOTS];
+#endif
int derrors;
int errval,errloc;
int erasures;