commit-gnuradio
[Top][All Lists]
Advanced

[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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]