diff options
author | Stefan <stefan.wunsch@student.kit.edu> | 2015-09-02 13:42:15 +0200 |
---|---|---|
committer | Stefan <stefan.wunsch@student.kit.edu> | 2015-09-02 13:42:15 +0200 |
commit | 955b8db0ea627c7dd59d9caef0cbf9e3c9f9b447 (patch) | |
tree | 6711a1894cfcb9da81521787c24e67ccab1a04bb | |
parent | 30965aab6c6b28fabb1403c635d016fc532caa0d (diff) |
remove deprecated RANDOM_MAX global and adjust test-cases
-rw-r--r-- | gnuradio-runtime/include/gnuradio/random.h | 12 | ||||
-rw-r--r-- | gr-atsc/lib/qa_atsci_fake_single_viterbi.cc | 4 | ||||
-rw-r--r-- | gr-atsc/lib/qa_atsci_fs_correlator.cc | 3 | ||||
-rw-r--r-- | gr-atsc/lib/qa_atsci_single_viterbi.cc | 4 | ||||
-rw-r--r-- | gr-filter/lib/qa_fir_filter_with_buffer.cc | 4 |
5 files changed, 11 insertions, 16 deletions
diff --git a/gnuradio-runtime/include/gnuradio/random.h b/gnuradio-runtime/include/gnuradio/random.h index 3ecdf6a2b7..8b20f7d311 100644 --- a/gnuradio-runtime/include/gnuradio/random.h +++ b/gnuradio-runtime/include/gnuradio/random.h @@ -26,18 +26,6 @@ #include <gnuradio/api.h> #include <gnuradio/gr_complex.h> -// While rand(3) specifies RAND_MAX, random(3) says that the output -// ranges from 0 to 2^31-1 but does not specify a macro to denote -// this. We define RANDOM_MAX for cleanliness. We must omit the -// definition for systems that have made the same choice. (Note that -// random(3) is from 4.2BSD, and not specified by POSIX.) - -#ifndef RANDOM_MAX -static const int RANDOM_MAX = 2147483647; // 2^31-1 -#endif /* RANDOM_MAX */ - -// FIXME: RANDOM_MAX still necessary? Some test-cases (use grep, e.g. in gr-filter or gr-atsc) use this constant, but combine it with the random() function from the std namespace. That should not the way to use this. - #include <stdlib.h> #include <boost/random.hpp> #include <ctime> diff --git a/gr-atsc/lib/qa_atsci_fake_single_viterbi.cc b/gr-atsc/lib/qa_atsci_fake_single_viterbi.cc index e59bc3880b..5edb5acbb7 100644 --- a/gr-atsc/lib/qa_atsci_fake_single_viterbi.cc +++ b/gr-atsc/lib/qa_atsci_fake_single_viterbi.cc @@ -38,6 +38,8 @@ static const int NN = 200; static const int MAXDIBIT = 3; +static gr::random rndm; + void qa_atsci_fake_single_viterbi::encode_block (unsigned char *out, unsigned char *in, unsigned int n) @@ -61,7 +63,7 @@ float qa_atsci_fake_single_viterbi::noise () { #if 1 - return 2.0 * ((float) random () / RANDOM_MAX - 0.5);; + return 2.0 * (rndm.ran1() - 0.5);; #else return 0; #endif diff --git a/gr-atsc/lib/qa_atsci_fs_correlator.cc b/gr-atsc/lib/qa_atsci_fs_correlator.cc index c416c22fbb..b92e63bad8 100644 --- a/gr-atsc/lib/qa_atsci_fs_correlator.cc +++ b/gr-atsc/lib/qa_atsci_fs_correlator.cc @@ -36,11 +36,12 @@ #include <assert.h> #include <gnuradio/random.h> +static gr::random rndm; static float uniform () { - return 2.0 * ((float) random () / RANDOM_MAX - 0.5); // uniformly (-1, 1) + return 2.0 * (rndm.ran1() - 0.5); // uniformly (-1, 1) } diff --git a/gr-atsc/lib/qa_atsci_single_viterbi.cc b/gr-atsc/lib/qa_atsci_single_viterbi.cc index 8291041a55..cd5b0451b6 100644 --- a/gr-atsc/lib/qa_atsci_single_viterbi.cc +++ b/gr-atsc/lib/qa_atsci_single_viterbi.cc @@ -39,6 +39,8 @@ static const int NN = 200; static const int MAXDIBIT = 3; +static gr::random rndm; + void qa_atsci_single_viterbi::encode_block (unsigned char *out, unsigned char *in, unsigned int n) @@ -61,7 +63,7 @@ qa_atsci_single_viterbi::decode_block (unsigned char *out, unsigned char *in, float qa_atsci_single_viterbi::noise () { - return 2.0 * ((float) random () / RANDOM_MAX - 0.5); // uniformly (-1, 1) + return 2.0 * (rndm.ran1() - 0.5); // uniformly (-1, 1) } void diff --git a/gr-filter/lib/qa_fir_filter_with_buffer.cc b/gr-filter/lib/qa_fir_filter_with_buffer.cc index a1dd9f4e48..74f5261588 100644 --- a/gr-filter/lib/qa_fir_filter_with_buffer.cc +++ b/gr-filter/lib/qa_fir_filter_with_buffer.cc @@ -40,10 +40,12 @@ namespace gr { #define MAX_DATA (16383) #define ERR_DELTA (1e-5) + static gr::random rndm; + static float uniform() { - return 2.0 * ((float)(::random()) / RANDOM_MAX - 0.5); // uniformly (-1, 1) + return 2.0 * (rndm.ran1() - 0.5); // uniformly (-1, 1) } static void |