[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] [gnuradio] 05/13: remove deprecated RANDOM_MAX global
From: |
git |
Subject: |
[Commit-gnuradio] [gnuradio] 05/13: remove deprecated RANDOM_MAX global and adjust test-cases |
Date: |
Sun, 6 Sep 2015 01:19:38 +0000 (UTC) |
This is an automated email from the git hooks/post-receive script.
jcorgan pushed a commit to branch master
in repository gnuradio.
commit 955b8db0ea627c7dd59d9caef0cbf9e3c9f9b447
Author: Stefan <address@hidden>
Date: Wed Sep 2 13:42:15 2015 +0200
remove deprecated RANDOM_MAX global and adjust test-cases
---
gnuradio-runtime/include/gnuradio/random.h | 12 ------------
gr-atsc/lib/qa_atsci_fake_single_viterbi.cc | 4 +++-
gr-atsc/lib/qa_atsci_fs_correlator.cc | 3 ++-
gr-atsc/lib/qa_atsci_single_viterbi.cc | 4 +++-
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 3ecdf6a..8b20f7d 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 e59bc38..5edb5ac 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 c416c22..b92e63b 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 8291041..cd5b045 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 a1dd9f4..74f5261 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
- [Commit-gnuradio] [gnuradio] branch master updated (80d5255 -> 45c0fee), git, 2015/09/05
- [Commit-gnuradio] [gnuradio] 06/13: remove fixed fixme, git, 2015/09/05
- [Commit-gnuradio] [gnuradio] 01/13: include random.h in swig; add qa_random testcase, git, 2015/09/05
- [Commit-gnuradio] [gnuradio] 11/13: Merge branch 'maint', git, 2015/09/05
- [Commit-gnuradio] [gnuradio] 04/13: add test-case for reseed feature, git, 2015/09/05
- [Commit-gnuradio] [gnuradio] 08/13: add current year to licence header, git, 2015/09/05
- [Commit-gnuradio] [gnuradio] 12/13: Merge remote-tracking branch 'stwunsch/newRandom', git, 2015/09/05
- [Commit-gnuradio] [gnuradio] 13/13: Merge remote-tracking branch 'drmpeg/gr-dtv-dvbt-rx', git, 2015/09/05
- [Commit-gnuradio] [gnuradio] 03/13: add boost.random as random number generator, git, 2015/09/05
- [Commit-gnuradio] [gnuradio] 02/13: fix wrong laplacian random numbers and add testcase, git, 2015/09/05
- [Commit-gnuradio] [gnuradio] 05/13: remove deprecated RANDOM_MAX global and adjust test-cases,
git <=
- [Commit-gnuradio] [gnuradio] 10/13: Add DVB-T receiver updated files., git, 2015/09/05
- [Commit-gnuradio] [gnuradio] 07/13: redo qa_random without print statements and scipy; add stand-alone evaluation script in gnuradio-runtime/apps, git, 2015/09/05
- [Commit-gnuradio] [gnuradio] 09/13: Add DVB-T receiver., git, 2015/09/05