diff options
Diffstat (limited to 'gnuradio-core')
-rw-r--r-- | gnuradio-core/src/lib/filter/gri_fft_filter_ccc_generic.cc | 2 | ||||
-rw-r--r-- | gnuradio-core/src/lib/filter/gri_fft_filter_fff_generic.cc | 2 | ||||
-rw-r--r-- | gnuradio-core/src/lib/general/gr_decode_ccsds_27_fb.cc | 2 | ||||
-rw-r--r-- | gnuradio-core/src/lib/general/gr_firdes.cc | 2 | ||||
-rw-r--r-- | gnuradio-core/src/lib/general/gr_ofdm_frame_sink.cc | 2 | ||||
-rw-r--r-- | gnuradio-core/src/lib/general/gr_ofdm_mapper_bcv.cc | 2 | ||||
-rw-r--r-- | gnuradio-core/src/lib/general/gri_fft.cc | 35 | ||||
-rw-r--r-- | gnuradio-core/src/lib/general/qa_gr_fxpt_vco.cc | 4 | ||||
-rw-r--r-- | gnuradio-core/src/lib/missing/Makefile.am | 4 | ||||
-rw-r--r-- | gnuradio-core/src/lib/runtime/gr_preferences.cc | 39 | ||||
-rw-r--r-- | gnuradio-core/src/lib/runtime/gr_unittests.h | 40 | ||||
-rw-r--r-- | gnuradio-core/src/tests/benchmark_vco.cc | 2 | ||||
-rw-r--r-- | gnuradio-core/src/tests/test_all.cc | 7 | ||||
-rw-r--r-- | gnuradio-core/src/tests/test_atsc.cc | 7 | ||||
-rw-r--r-- | gnuradio-core/src/tests/test_filter.cc | 7 | ||||
-rw-r--r-- | gnuradio-core/src/tests/test_general.cc | 7 | ||||
-rw-r--r-- | gnuradio-core/src/tests/test_runtime.cc | 7 |
17 files changed, 64 insertions, 107 deletions
diff --git a/gnuradio-core/src/lib/filter/gri_fft_filter_ccc_generic.cc b/gnuradio-core/src/lib/filter/gri_fft_filter_ccc_generic.cc index 1bf4a6f4b..891905dd0 100644 --- a/gnuradio-core/src/lib/filter/gri_fft_filter_ccc_generic.cc +++ b/gnuradio-core/src/lib/filter/gri_fft_filter_ccc_generic.cc @@ -99,7 +99,7 @@ gri_fft_filter_ccc_generic::compute_sizes(int ntaps) { int old_fftsize = d_fftsize; d_ntaps = ntaps; - d_fftsize = (int) (2 * pow(2.0, ceil(log(ntaps) / log(2)))); + d_fftsize = (int) (2 * pow(2.0, ceil(log(double(ntaps)) / log(2.0)))); d_nsamples = d_fftsize - d_ntaps + 1; if (0) diff --git a/gnuradio-core/src/lib/filter/gri_fft_filter_fff_generic.cc b/gnuradio-core/src/lib/filter/gri_fft_filter_fff_generic.cc index 74058fa93..b3fbe1d1a 100644 --- a/gnuradio-core/src/lib/filter/gri_fft_filter_fff_generic.cc +++ b/gnuradio-core/src/lib/filter/gri_fft_filter_fff_generic.cc @@ -86,7 +86,7 @@ gri_fft_filter_fff_generic::compute_sizes(int ntaps) { int old_fftsize = d_fftsize; d_ntaps = ntaps; - d_fftsize = (int) (2 * pow(2.0, ceil(log(ntaps) / log(2)))); + d_fftsize = (int) (2 * pow(2.0, ceil(log(double(ntaps)) / log(2.0)))); d_nsamples = d_fftsize - d_ntaps + 1; if (0) diff --git a/gnuradio-core/src/lib/general/gr_decode_ccsds_27_fb.cc b/gnuradio-core/src/lib/general/gr_decode_ccsds_27_fb.cc index d5425bfc8..c5e1320a3 100644 --- a/gnuradio-core/src/lib/general/gr_decode_ccsds_27_fb.cc +++ b/gnuradio-core/src/lib/general/gr_decode_ccsds_27_fb.cc @@ -39,7 +39,7 @@ gr_decode_ccsds_27_fb::gr_decode_ccsds_27_fb() { float RATE = 0.5; float ebn0 = 12.0; - float esn0 = RATE*pow(10.0, ebn0/10); + float esn0 = RATE*pow(10.0, ebn0/10.0); gen_met(d_mettab, 100, esn0, 0.0, 256); viterbi_chunks_init(d_state0); diff --git a/gnuradio-core/src/lib/general/gr_firdes.cc b/gnuradio-core/src/lib/general/gr_firdes.cc index 8efeb3438..5d192d67e 100644 --- a/gnuradio-core/src/lib/general/gr_firdes.cc +++ b/gnuradio-core/src/lib/general/gr_firdes.cc @@ -574,7 +574,7 @@ gr_firdes::gaussian (double gain, vector<float> taps(ntaps); double scale = 0; double dt = 1.0/spb; - double s = 1.0/(sqrt(log(2)) / (2*M_PI*bt)); + double s = 1.0/(sqrt(log(2.0)) / (2*M_PI*bt)); double t0 = -0.5 * ntaps; double ts; for(int i=0;i<ntaps;i++) diff --git a/gnuradio-core/src/lib/general/gr_ofdm_frame_sink.cc b/gnuradio-core/src/lib/general/gr_ofdm_frame_sink.cc index 3457370eb..279945766 100644 --- a/gnuradio-core/src/lib/general/gr_ofdm_frame_sink.cc +++ b/gnuradio-core/src/lib/general/gr_ofdm_frame_sink.cc @@ -281,7 +281,7 @@ gr_ofdm_frame_sink::set_sym_value_out(const std::vector<gr_complex> &sym_positio d_sym_position = sym_position; d_sym_value_out = sym_value_out; - d_nbits = (unsigned long)ceil(log10(d_sym_value_out.size()) / log10(2.0)); + d_nbits = (unsigned long)ceil(log10(float(d_sym_value_out.size())) / log10(2.0)); return true; } diff --git a/gnuradio-core/src/lib/general/gr_ofdm_mapper_bcv.cc b/gnuradio-core/src/lib/general/gr_ofdm_mapper_bcv.cc index 370b029cd..cc4aba0cb 100644 --- a/gnuradio-core/src/lib/general/gr_ofdm_mapper_bcv.cc +++ b/gnuradio-core/src/lib/general/gr_ofdm_mapper_bcv.cc @@ -113,7 +113,7 @@ gr_ofdm_mapper_bcv::gr_ofdm_mapper_bcv (const std::vector<gr_complex> &constella throw std::invalid_argument("gr_ofdm_mapper_bcv: subcarriers allocated exceeds size of occupied carriers"); } - d_nbits = (unsigned long)ceil(log10(d_constellation.size()) / log10(2.0)); + d_nbits = (unsigned long)ceil(log10(float(d_constellation.size())) / log10(2.0)); } gr_ofdm_mapper_bcv::~gr_ofdm_mapper_bcv(void) diff --git a/gnuradio-core/src/lib/general/gri_fft.cc b/gnuradio-core/src/lib/general/gri_fft.cc index e535f28c7..eebe3b9c5 100644 --- a/gnuradio-core/src/lib/general/gri_fft.cc +++ b/gnuradio-core/src/lib/general/gri_fft.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2003,2008 Free Software Foundation, Inc. + * Copyright 2003,2008,2011 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -29,6 +29,17 @@ #include <cassert> #include <stdexcept> +#include <boost/filesystem/operations.hpp> +#include <boost/filesystem/path.hpp> +namespace fs = boost::filesystem; + +static std::string get_home_dir(void){ + #if defined(BOOST_WINDOWS) + return getenv ("APPDATA"); + #else + return getenv ("HOME"); + #endif +} boost::mutex & gri_fft_planner::mutex() @@ -38,26 +49,18 @@ gri_fft_planner::mutex() return s_planning_mutex; } -static char * +static const char * wisdom_filename () { - static const char *filename = ".gr_fftw_wisdom"; - - char *home = getenv ("HOME"); - if (home){ - char *p = new char[strlen (home) + strlen (filename) + 2]; - strcpy (p, home); - strcat (p, "/"); - strcat (p, filename); - return p; - } - return 0; + static fs::path path; + path = fs::path(get_home_dir()) / ".gr_fftw_wisdom"; + return path.string().c_str(); } static void gri_fftw_import_wisdom () { - char *filename = wisdom_filename (); + const char *filename = wisdom_filename (); FILE *fp = fopen (filename, "r"); if (fp != 0){ int r = fftwf_import_wisdom_from_file (fp); @@ -66,13 +69,12 @@ gri_fftw_import_wisdom () fprintf (stderr, "gri_fftw: can't import wisdom from %s\n", filename); } } - delete [] filename; } static void gri_fftw_export_wisdom () { - char *filename = wisdom_filename (); + const char *filename = wisdom_filename (); FILE *fp = fopen (filename, "w"); if (fp != 0){ fftwf_export_wisdom_to_file (fp); @@ -82,7 +84,6 @@ gri_fftw_export_wisdom () fprintf (stderr, "gri_fftw: "); perror (filename); } - delete [] filename; } // ---------------------------------------------------------------- diff --git a/gnuradio-core/src/lib/general/qa_gr_fxpt_vco.cc b/gnuradio-core/src/lib/general/qa_gr_fxpt_vco.cc index 9885b3852..113006a22 100644 --- a/gnuradio-core/src/lib/general/qa_gr_fxpt_vco.cc +++ b/gnuradio-core/src/lib/general/qa_gr_fxpt_vco.cc @@ -53,7 +53,7 @@ qa_gr_fxpt_vco::t0 () float input[SIN_COS_BLOCK_SIZE]; for (int i = 0; i < SIN_COS_BLOCK_SIZE; i++){ - input[i] = sin(i); + input[i] = sin(double(i)); } for (int i = 0; i < SIN_COS_BLOCK_SIZE; i++){ @@ -85,7 +85,7 @@ qa_gr_fxpt_vco::t1 () double max_error = 0; for (int i = 0; i < SIN_COS_BLOCK_SIZE; i++){ - input[i] = sin(i); + input[i] = sin(double(i)); } ref_vco.cos (ref_block, input, SIN_COS_BLOCK_SIZE, SIN_COS_K, SIN_COS_AMPL); diff --git a/gnuradio-core/src/lib/missing/Makefile.am b/gnuradio-core/src/lib/missing/Makefile.am index bd18cf143..1cc6014a1 100644 --- a/gnuradio-core/src/lib/missing/Makefile.am +++ b/gnuradio-core/src/lib/missing/Makefile.am @@ -1,5 +1,5 @@ # -# Copyright 2003,2004,2008,2009 Free Software Foundation, Inc. +# Copyright 2003,2004,2008,2009,2011 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -21,7 +21,7 @@ include $(top_srcdir)/Makefile.common -AM_CPPFLAGS = $(GNURADIO_INCLUDES) $(WITH_INCLUDES) +AM_CPPFLAGS = $(GRUEL_INCLUDES) $(GNURADIO_INCLUDES) $(WITH_INCLUDES) EXTRA_DIST += \ getopt.h \ diff --git a/gnuradio-core/src/lib/runtime/gr_preferences.cc b/gnuradio-core/src/lib/runtime/gr_preferences.cc index 5f7412248..e9216e4ac 100644 --- a/gnuradio-core/src/lib/runtime/gr_preferences.cc +++ b/gnuradio-core/src/lib/runtime/gr_preferences.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2003,2010 Free Software Foundation, Inc. + * Copyright 2003,2010,2011 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -33,12 +33,17 @@ #include <unistd.h> #include <string.h> +#include <boost/filesystem/operations.hpp> +#include <boost/filesystem/path.hpp> +namespace fs = boost::filesystem; -#ifdef MKDIR_TAKES_ONE_ARG -#define gr_mkdir(pathname, mode) mkdir(pathname) -#else -#define gr_mkdir(pathname, mode) mkdir((pathname), (mode)) -#endif +static std::string get_home_dir(void){ + #if defined(BOOST_WINDOWS) + return getenv ("APPDATA"); + #else + return getenv ("HOME"); + #endif +} /* * The simplest thing that could possibly work: @@ -48,27 +53,19 @@ static const char * pathname (const char *key) { - static char buf[200]; - snprintf (buf, sizeof (buf), "%s/.gnuradio/prefs/%s", getenv ("HOME"), key); - return buf; + static fs::path path; + path = fs::path(get_home_dir()) / ".gnuradio" / "prefs" / key; + return path.string().c_str(); } static void ensure_dir_path () { - char path[200]; - struct stat statbuf; - - snprintf (path, sizeof (path), "%s/.gnuradio/prefs", getenv ("HOME")); - if (stat (path, &statbuf) == 0 && S_ISDIR (statbuf.st_mode)) - return; - - // blindly try to make it // FIXME make this robust. C++ SUCKS! + fs::path path = fs::path(get_home_dir()) / ".gnuradio"; + if (!fs::is_directory(path)) fs::create_directory(path); - snprintf (path, sizeof (path), "%s/.gnuradio", getenv ("HOME")); - gr_mkdir (path, 0750); - snprintf (path, sizeof (path), "%s/.gnuradio/prefs", getenv ("HOME")); - gr_mkdir (path, 0750); + path = path / "prefs"; + if (!fs::is_directory(path)) fs::create_directory(path); } const char * diff --git a/gnuradio-core/src/lib/runtime/gr_unittests.h b/gnuradio-core/src/lib/runtime/gr_unittests.h index 70aa6f294..59149bb2e 100644 --- a/gnuradio-core/src/lib/runtime/gr_unittests.h +++ b/gnuradio-core/src/lib/runtime/gr_unittests.h @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2010 Free Software Foundation, Inc. + * Copyright 2010,2011 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -31,37 +31,11 @@ #include <sys/stat.h> #include <unistd.h> +#include <boost/filesystem/operations.hpp> +#include <boost/filesystem/path.hpp> -#ifdef MKDIR_TAKES_ONE_ARG -#define gr_mkdir(pathname, mode) mkdir(pathname) -#else -#define gr_mkdir(pathname, mode) mkdir((pathname), (mode)) -#endif - -/* - * Mostly taken from gr_preferences.cc/h - * The simplest thing that could possibly work: - * the key is the filename; the value is the file contents. - */ - -static void -ensure_unittest_path (const char *path) -{ - struct stat statbuf; - if (stat (path, &statbuf) == 0 && S_ISDIR (statbuf.st_mode)) - return; - - // blindly try to make it // FIXME make this robust. C++ SUCKS! - gr_mkdir (path, 0750); +static std::string get_unittest_path(const std::string &filename){ + boost::filesystem::path path = boost::filesystem::current_path() / ".unittests"; + if (!boost::filesystem::is_directory(path)) boost::filesystem::create_directory(path); + return (path / filename).string(); } - -static void -get_unittest_path (const char *filename, char *fullpath, size_t pathsize) -{ - char path[200]; - snprintf (path, sizeof(path), "./.unittests"); - snprintf (fullpath, pathsize, "%s/%s", path, filename); - - ensure_unittest_path(path); -} - diff --git a/gnuradio-core/src/tests/benchmark_vco.cc b/gnuradio-core/src/tests/benchmark_vco.cc index ed0ae3b67..3a6ade78c 100644 --- a/gnuradio-core/src/tests/benchmark_vco.cc +++ b/gnuradio-core/src/tests/benchmark_vco.cc @@ -63,7 +63,7 @@ benchmark (void test (float *x, const float *y), const char *implementation_name // touch memory memset(output, 0, BLOCK_SIZE*sizeof(float)); for (int i = 0; i<BLOCK_SIZE; i++) - input[i] = sin(i); + input[i] = sin(double(i)); // get starting CPU usage #ifdef HAVE_SYS_RESOURCE_H diff --git a/gnuradio-core/src/tests/test_all.cc b/gnuradio-core/src/tests/test_all.cc index 17ee32f34..6cec8ad0e 100644 --- a/gnuradio-core/src/tests/test_all.cc +++ b/gnuradio-core/src/tests/test_all.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2002,2010 Free Software Foundation, Inc. + * Copyright 2002,2010,2011 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -34,11 +34,8 @@ int main (int argc, char **argv) { - char path[200]; - get_unittest_path ("gnuradio_core_all.xml", path, 200); - CppUnit::TextTestRunner runner; - std::ofstream xmlfile(path); + std::ofstream xmlfile(get_unittest_path("gnuradio_core_all.xml").c_str()); CppUnit::XmlOutputter *xmlout = new CppUnit::XmlOutputter(&runner.result(), xmlfile); runner.addTest (qa_runtime::suite ()); diff --git a/gnuradio-core/src/tests/test_atsc.cc b/gnuradio-core/src/tests/test_atsc.cc index 51642f81a..66cb2a312 100644 --- a/gnuradio-core/src/tests/test_atsc.cc +++ b/gnuradio-core/src/tests/test_atsc.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2002 Free Software Foundation, Inc. + * Copyright 2002,2011 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -29,11 +29,8 @@ int main (int argc, char **argv) { - char path[200]; - get_unittest_path ("gnuradio_core_atsc.xml", path, 200); - CppUnit::TextTestRunner runner; - std::ofstream xmlfile(path); + std::ofstream xmlfile(get_unittest_path("gnuradio_core_atsc.xml").c_str()); CppUnit::XmlOutputter *xmlout = new CppUnit::XmlOutputter(&runner.result(), xmlfile); runner.addTest (qa_atsc::suite ()); diff --git a/gnuradio-core/src/tests/test_filter.cc b/gnuradio-core/src/tests/test_filter.cc index 2781cfb35..3227a9ff2 100644 --- a/gnuradio-core/src/tests/test_filter.cc +++ b/gnuradio-core/src/tests/test_filter.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2002,2010 Free Software Foundation, Inc. + * Copyright 2002,2010,2011 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -29,11 +29,8 @@ int main (int argc, char **argv) { - char path[200]; - get_unittest_path ("gnuradio_core_filter.xml", path, 200); - CppUnit::TextTestRunner runner; - std::ofstream xmlfile(path); + std::ofstream xmlfile(get_unittest_path("gnuradio_core_filter.xml").c_str()); CppUnit::XmlOutputter *xmlout = new CppUnit::XmlOutputter(&runner.result(), xmlfile); runner.addTest (qa_filter::suite ()); diff --git a/gnuradio-core/src/tests/test_general.cc b/gnuradio-core/src/tests/test_general.cc index 16ee9c3ad..ca6dee40a 100644 --- a/gnuradio-core/src/tests/test_general.cc +++ b/gnuradio-core/src/tests/test_general.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2002,2010 Free Software Foundation, Inc. + * Copyright 2002,2010,2011 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -29,11 +29,8 @@ int main (int argc, char **argv) { - char path[200]; - get_unittest_path ("gnuradio_core_general.xml", path, 200); - CppUnit::TextTestRunner runner; - std::ofstream xmlfile(path); + std::ofstream xmlfile(get_unittest_path("gnuradio_core_general.xml").c_str()); CppUnit::XmlOutputter *xmlout = new CppUnit::XmlOutputter(&runner.result(), xmlfile); runner.addTest (qa_general::suite ()); diff --git a/gnuradio-core/src/tests/test_runtime.cc b/gnuradio-core/src/tests/test_runtime.cc index c7983a23e..77af3001b 100644 --- a/gnuradio-core/src/tests/test_runtime.cc +++ b/gnuradio-core/src/tests/test_runtime.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2002,2010 Free Software Foundation, Inc. + * Copyright 2002,2010,2011 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -29,11 +29,8 @@ int main (int argc, char **argv) { - char path[200]; - get_unittest_path ("gnuradio_core_runtime.xml", path, 200); - CppUnit::TextTestRunner runner; - std::ofstream xmlfile(path); + std::ofstream xmlfile(get_unittest_path("gnuradio_core_runtime.xml").c_str()); CppUnit::XmlOutputter *xmlout = new CppUnit::XmlOutputter(&runner.result(), xmlfile); runner.addTest (qa_runtime::suite ()); |