summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/CMakeLists.txt1
-rw-r--r--lib/gr_block.cpp2
-rw-r--r--lib/sbuffer.cpp69
3 files changed, 71 insertions, 1 deletions
diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt
index 8baa38d..414e13a 100644
--- a/lib/CMakeLists.txt
+++ b/lib/CMakeLists.txt
@@ -23,6 +23,7 @@ endif()
########################################################################
list(APPEND gnuradio_core_sources
${CMAKE_CURRENT_SOURCE_DIR}/element.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/sbuffer.cpp
${CMAKE_CURRENT_SOURCE_DIR}/block.cpp
${CMAKE_CURRENT_SOURCE_DIR}/block_task.cpp
${CMAKE_CURRENT_SOURCE_DIR}/block_allocator.cpp
diff --git a/lib/gr_block.cpp b/lib/gr_block.cpp
index ce1b09e..1f59bb1 100644
--- a/lib/gr_block.cpp
+++ b/lib/gr_block.cpp
@@ -67,7 +67,7 @@ bool gr_block::is_unaligned(void)
//TODO
//probably dont need this since volk dispatcher checks alignment
//32 byte aligned is good enough for you
- return ((*this)->work_io_ptr_mask & ptrdiff_t(0x1f)) != 0;
+ return ((*this)->work_io_ptr_mask & ptrdiff_t(GRAS_MAX_ALIGNMENT-1)) != 0;
}
size_t gr_block::fixed_rate_noutput_to_ninput(const size_t noutput_items)
diff --git a/lib/sbuffer.cpp b/lib/sbuffer.cpp
new file mode 100644
index 0000000..2877b2e
--- /dev/null
+++ b/lib/sbuffer.cpp
@@ -0,0 +1,69 @@
+//
+// Copyright 2012 Josh Blum
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with io_sig program. If not, see <http://www.gnu.org/licenses/>.
+
+#include <gnuradio/sbuffer.hpp>
+#include <numanuma.hpp>
+#include <boost/bind.hpp>
+
+using namespace gnuradio;
+
+static void numanuma_mem_deleter(SBuffer &, numanuma::mem *m)
+{
+ delete m;
+}
+
+static void default_allocator_deleter(SBuffer &, char *m)
+{
+ delete m;
+}
+
+static void default_allocator(SBufferConfig &config)
+{
+ if (config.affinity == Affinity())
+ {
+ char *m = new char[config.length + GRAS_MAX_ALIGNMENT - 1];
+ size_t x = size_t(m) + GRAS_MAX_ALIGNMENT - 1;
+ x -= x % GRAS_MAX_ALIGNMENT;
+ config.memory = (void *)x;
+ config.deleter = boost::bind(&default_allocator_deleter, _1, m);
+ }
+ else
+ {
+ numanuma::mem *m = numanuma::mem::make(config.affinity, config.length);
+ config.memory = m->get();
+ config.length = m->len();
+ config.deleter = boost::bind(&numanuma_mem_deleter, _1, m);
+ }
+}
+
+SBuffer::SBuffer(void):
+ offset(0),
+ length(0)
+{
+ //NOP
+}
+
+SBuffer::SBuffer(const SBufferConfig &config):
+ offset(0),
+ length(0)
+{
+ this->reset(new SBufferImpl(config));
+ if (config.memory == NULL)
+ {
+ default_allocator((*this)->config);
+ }
+ this->length = this->get_actual_length();
+}