diff options
author | David Sorber <david.sorber@blacklynx.tech> | 2021-10-18 08:54:12 -0400 |
---|---|---|
committer | mormj <34754695+mormj@users.noreply.github.com> | 2021-10-25 11:27:01 -0400 |
commit | d4bd90853f499d5b65a61b3b7bf9ecf50e68bf6b (patch) | |
tree | d1bde0753540937bf6678f0cef1734d88ed5f9ce /gnuradio-runtime/lib | |
parent | 47c374211221f3c636e0be2238ef233dd353697d (diff) |
runtime: replace the DEFINE_CUSTOM_BUFFER_TYPE() macro function with
some advanced template magic; also a few minor type corrections for
consistency
Signed-off-by: David Sorber <david.sorber@blacklynx.tech>
Diffstat (limited to 'gnuradio-runtime/lib')
-rw-r--r-- | gnuradio-runtime/lib/block.cc | 4 | ||||
-rw-r--r-- | gnuradio-runtime/lib/buffer_double_mapped.cc | 17 | ||||
-rw-r--r-- | gnuradio-runtime/lib/host_buffer.cc | 18 | ||||
-rw-r--r-- | gnuradio-runtime/lib/qa_buffer.cc | 16 |
4 files changed, 35 insertions, 20 deletions
diff --git a/gnuradio-runtime/lib/block.cc b/gnuradio-runtime/lib/block.cc index 75f9dc6ae4..f2970cd667 100644 --- a/gnuradio-runtime/lib/block.cc +++ b/gnuradio-runtime/lib/block.cc @@ -417,7 +417,7 @@ void block::allocate_detail(int ninputs, } buffer_sptr -block::replace_buffer(uint32_t src_port, uint32_t dst_port, block_sptr block_owner) +block::replace_buffer(size_t src_port, size_t dst_port, block_sptr block_owner) { block_detail_sptr detail_ = detail(); buffer_sptr orig_buffer = detail_->output(src_port); @@ -441,7 +441,7 @@ bool block::update_rate() const { return d_update_rate; } void block::enable_update_rate(bool en) { d_update_rate = en; } -buffer_sptr block::allocate_buffer(int port, +buffer_sptr block::allocate_buffer(size_t port, int downstream_max_nitems, uint64_t downstream_lcm_nitems, uint32_t downstream_max_out_mult) diff --git a/gnuradio-runtime/lib/buffer_double_mapped.cc b/gnuradio-runtime/lib/buffer_double_mapped.cc index 700ebac0c1..e5f8d716f9 100644 --- a/gnuradio-runtime/lib/buffer_double_mapped.cc +++ b/gnuradio-runtime/lib/buffer_double_mapped.cc @@ -31,12 +31,13 @@ namespace gr { * * type_size * nitems == k * page_size */ -static inline long minimum_buffer_items(long type_size, long page_size) +static inline long minimum_buffer_items(size_t type_size, size_t page_size) { return page_size / GR_GCD(type_size, page_size); } -buffer_type buffer_double_mapped::type(buftype_DEFAULT_NON_CUSTOM{}); +buffer_type + buffer_double_mapped::type(buftype<buffer_double_mapped, buffer_double_mapped>{}); buffer_double_mapped::buffer_double_mapped(int nitems, size_t sizeof_item, @@ -67,12 +68,12 @@ buffer_double_mapped::buffer_double_mapped(int nitems, // NB: Added the extra 'block_sptr unused' parameter so that the // call signature matches the other factory-like functions used to create // the buffer_single_mapped subclasses -buffer_sptr make_buffer_double_mapped(int nitems, - size_t sizeof_item, - uint64_t downstream_lcm_nitems, - uint32_t downstream_max_out_mult, - block_sptr link, - block_sptr unused) +buffer_sptr buffer_double_mapped::make_buffer(int nitems, + size_t sizeof_item, + uint64_t downstream_lcm_nitems, + uint32_t downstream_max_out_mult, + block_sptr link, + block_sptr unused) { return buffer_sptr(new buffer_double_mapped( nitems, sizeof_item, downstream_lcm_nitems, downstream_max_out_mult, link)); diff --git a/gnuradio-runtime/lib/host_buffer.cc b/gnuradio-runtime/lib/host_buffer.cc index 535a7a5286..eb5d4bd515 100644 --- a/gnuradio-runtime/lib/host_buffer.cc +++ b/gnuradio-runtime/lib/host_buffer.cc @@ -14,8 +14,6 @@ namespace gr { -buffer_type host_buffer::type(buftype_HOST_BUFFER{}); - void* host_buffer::device_memcpy(void* dest, const void* src, std::size_t count) { // There is no spoon...er... device so fake it out using regular memcpy @@ -28,6 +26,22 @@ void* host_buffer::device_memmove(void* dest, const void* src, std::size_t count return std::memmove(dest, src, count); } +buffer_type host_buffer::type(buftype<host_buffer, host_buffer>{}); + +buffer_sptr host_buffer::make_buffer(int nitems, + size_t sizeof_item, + uint64_t downstream_lcm_nitems, + uint32_t downstream_max_out_mult, + block_sptr link, + block_sptr buf_owner) +{ + return buffer_sptr(new host_buffer(nitems, + sizeof_item, + downstream_lcm_nitems, + downstream_max_out_mult, + link, + buf_owner)); +} host_buffer::host_buffer(int nitems, size_t sizeof_item, diff --git a/gnuradio-runtime/lib/qa_buffer.cc b/gnuradio-runtime/lib/qa_buffer.cc index 1c97fd070d..d787661650 100644 --- a/gnuradio-runtime/lib/qa_buffer.cc +++ b/gnuradio-runtime/lib/qa_buffer.cc @@ -42,8 +42,8 @@ static void t0_body() int nitems = 4000 / sizeof(int); int counter = 0; - gr::buffer_sptr buf( - gr::make_buffer_double_mapped(nitems, sizeof(int), nitems, 1, gr::block_sptr())); + gr::buffer_sptr buf(gr::buffer_double_mapped::make_buffer( + nitems, sizeof(int), nitems, 1, gr::block_sptr())); int last_sa; int sa; @@ -77,8 +77,8 @@ static void t1_body() int write_counter = 0; int read_counter = 0; - gr::buffer_sptr buf( - gr::make_buffer_double_mapped(nitems, sizeof(int), nitems, 1, gr::block_sptr())); + gr::buffer_sptr buf(gr::buffer_double_mapped::make_buffer( + nitems, sizeof(int), nitems, 1, gr::block_sptr())); gr::buffer_reader_sptr r1(gr::buffer_add_reader(buf, 0, gr::block_sptr())); int sa; @@ -149,8 +149,8 @@ static void t2_body() int nitems = (64 * (1L << 10)) / sizeof(int); // 64K worth of ints - gr::buffer_sptr buf( - gr::make_buffer_double_mapped(nitems, sizeof(int), nitems, 1, gr::block_sptr())); + gr::buffer_sptr buf(gr::buffer_double_mapped::make_buffer( + nitems, sizeof(int), nitems, 1, gr::block_sptr())); gr::buffer_reader_sptr r1(gr::buffer_add_reader(buf, 0, gr::block_sptr())); int read_counter = 0; @@ -215,8 +215,8 @@ static void t3_body() int nitems = (64 * (1L << 10)) / sizeof(int); static const int N = 5; - gr::buffer_sptr buf( - gr::make_buffer_double_mapped(nitems, sizeof(int), nitems, 1, gr::block_sptr())); + gr::buffer_sptr buf(gr::buffer_double_mapped::make_buffer( + nitems, sizeof(int), nitems, 1, gr::block_sptr())); gr::buffer_reader_sptr reader[N]; int read_counter[N]; int write_counter = 0; |