summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGrant Cox <grant.cox@deepspaceamps.com>2019-11-02 16:25:57 -0500
committerMarcus Müller <marcus@hostalia.de>2019-11-07 23:47:00 +0100
commita6e36bfe5de6d4d8b0fa0d82a7b8f871f4f97abc (patch)
tree81b1ff80c7e67d7007d0365b1f001540ac10fb35
parenta402fc432ec2019e5bfc70c3f78beef83b450f01 (diff)
Remove circular_file.cc from codebase, cmake, qa, and ConfigChecks #2874
-rw-r--r--gnuradio-runtime/ConfigChecks.cmake1
-rw-r--r--gnuradio-runtime/lib/CMakeLists.txt2
-rw-r--r--gnuradio-runtime/lib/circular_file.cc200
-rw-r--r--gnuradio-runtime/lib/circular_file.h65
-rw-r--r--gnuradio-runtime/lib/qa_circular_file.cc66
-rw-r--r--gr-blocks/lib/ConfigChecks.cmake1
6 files changed, 0 insertions, 335 deletions
diff --git a/gnuradio-runtime/ConfigChecks.cmake b/gnuradio-runtime/ConfigChecks.cmake
index e1ba20c1f1..9f7ca1076f 100644
--- a/gnuradio-runtime/ConfigChecks.cmake
+++ b/gnuradio-runtime/ConfigChecks.cmake
@@ -28,7 +28,6 @@ ENDIF(MSVC)
GR_CHECK_HDR_N_DEF(sys/time.h HAVE_SYS_TIME_H)
GR_CHECK_HDR_N_DEF(sys/types.h HAVE_SYS_TYPES_H)
GR_CHECK_HDR_N_DEF(sys/socket.h HAVE_SYS_SOCKET_H)
-GR_CHECK_HDR_N_DEF(io.h HAVE_IO_H)
GR_CHECK_HDR_N_DEF(sys/mman.h HAVE_SYS_MMAN_H)
GR_CHECK_HDR_N_DEF(sys/ipc.h HAVE_SYS_IPC_H)
GR_CHECK_HDR_N_DEF(sys/shm.h HAVE_SYS_SHM_H)
diff --git a/gnuradio-runtime/lib/CMakeLists.txt b/gnuradio-runtime/lib/CMakeLists.txt
index 5aa90a5e1c..b9253414fb 100644
--- a/gnuradio-runtime/lib/CMakeLists.txt
+++ b/gnuradio-runtime/lib/CMakeLists.txt
@@ -59,7 +59,6 @@ add_library(gnuradio-runtime
block_gateway_impl.cc
block_registry.cc
buffer.cc
- circular_file.cc
feval.cc
flat_flowgraph.cc
flowgraph.cc
@@ -298,7 +297,6 @@ if(ENABLE_TESTING)
list(APPEND test_gnuradio_runtime_sources
qa_buffer.cc
qa_io_signature.cc
- qa_circular_file.cc
qa_logger.cc
qa_vmcircbuf.cc
)
diff --git a/gnuradio-runtime/lib/circular_file.cc b/gnuradio-runtime/lib/circular_file.cc
deleted file mode 100644
index dcfccf9af3..0000000000
--- a/gnuradio-runtime/lib/circular_file.cc
+++ /dev/null
@@ -1,200 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2002,2010,2013 Free Software Foundation, Inc.
- *
- * This file is part of GNU Radio
- *
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- *
- * GNU Radio 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with GNU Radio; see the file COPYING. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include "circular_file.h"
-
-#include <unistd.h>
-#ifdef HAVE_SYS_MMAN_H
-#include <sys/mman.h>
-#endif
-
-#include <assert.h>
-#include <fcntl.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <unistd.h>
-
-#include <stdio.h>
-#include <string.h>
-#include <algorithm>
-
-#ifdef HAVE_IO_H
-#include <io.h>
-#endif
-
-namespace gr {
-
-static const int HEADER_SIZE = 4096;
-static const int HEADER_MAGIC = 0xEB021026;
-
-static const int HD_MAGIC = 0;
-static const int HD_HEADER_SIZE = 1; // integer offsets into header
-static const int HD_BUFFER_SIZE = 2;
-static const int HD_BUFFER_BASE = 3;
-static const int HD_BUFFER_CURRENT = 4;
-
-circular_file::circular_file(const char* filename, bool writable, int size)
- : d_fd(-1), d_header(0), d_buffer(0), d_mapped_size(0), d_bytes_read(0)
-{
- int mm_prot;
- if (writable) {
-#ifdef HAVE_MMAP
- mm_prot = PROT_READ | PROT_WRITE;
-#endif
- d_fd = open(filename, O_CREAT | O_RDWR | O_TRUNC, 0664);
- if (d_fd < 0) {
- perror(filename);
- exit(1);
- }
-#ifdef HAVE_MMAP /* FIXME */
- if (ftruncate(d_fd, size + HEADER_SIZE) != 0) {
- perror(filename);
- exit(1);
- }
-#endif
- } else {
-#ifdef HAVE_MMAP
- mm_prot = PROT_READ;
-#endif
- d_fd = open(filename, O_RDONLY);
- if (d_fd < 0) {
- perror(filename);
- exit(1);
- }
- }
-
- struct stat statbuf;
- if (fstat(d_fd, &statbuf) < 0) {
- perror(filename);
- exit(1);
- }
-
- if (statbuf.st_size < HEADER_SIZE) {
- fprintf(stderr, "%s: file too small to be circular buffer\n", filename);
- exit(1);
- }
-
- d_mapped_size = statbuf.st_size;
-#ifdef HAVE_MMAP
- void* p = mmap(0, d_mapped_size, mm_prot, MAP_SHARED, d_fd, 0);
- if (p == MAP_FAILED) {
- perror("gr::circular_file: mmap failed");
- exit(1);
- }
-
- d_header = (int*)p;
-#else
- perror("gr::circular_file: mmap unsupported by this system");
- exit(1);
-#endif
-
- if (writable) { // init header
-
- if (size < 0) {
- fprintf(stderr, "gr::circular_buffer: size must be > 0 when writable\n");
- exit(1);
- }
-
- d_header[HD_MAGIC] = HEADER_MAGIC;
- d_header[HD_HEADER_SIZE] = HEADER_SIZE;
- d_header[HD_BUFFER_SIZE] = size;
- d_header[HD_BUFFER_BASE] = HEADER_SIZE; // right after header
- d_header[HD_BUFFER_CURRENT] = 0;
- }
-
- // sanity check (the asserts are a bit unforgiving...)
-
- assert(d_header[HD_MAGIC] == HEADER_MAGIC);
- assert(d_header[HD_HEADER_SIZE] == HEADER_SIZE);
- assert(d_header[HD_BUFFER_SIZE] > 0);
- assert(d_header[HD_BUFFER_BASE] >= d_header[HD_HEADER_SIZE]);
- assert(d_header[HD_BUFFER_BASE] + d_header[HD_BUFFER_SIZE] <= d_mapped_size);
- assert(d_header[HD_BUFFER_CURRENT] >= 0 &&
- d_header[HD_BUFFER_CURRENT] < d_header[HD_BUFFER_SIZE]);
-
- d_bytes_read = 0;
- d_buffer = (unsigned char*)d_header + d_header[HD_BUFFER_BASE];
-}
-
-circular_file::~circular_file()
-{
-#ifdef HAVE_MMAP
- if (munmap((char*)d_header, d_mapped_size) < 0) {
- perror("gr::circular_file: munmap");
- exit(1);
- }
-#endif
- close(d_fd);
-}
-
-bool circular_file::write(void* vdata, int nbytes)
-{
- unsigned char* data = (unsigned char*)vdata;
- int buffer_size = d_header[HD_BUFFER_SIZE];
- int buffer_current = d_header[HD_BUFFER_CURRENT];
-
- while (nbytes > 0) {
- int n = std::min(nbytes, buffer_size - buffer_current);
- memcpy(d_buffer + buffer_current, data, n);
-
- buffer_current += n;
- if (buffer_current >= buffer_size)
- buffer_current = 0;
-
- data += n;
- nbytes -= n;
- }
-
- d_header[HD_BUFFER_CURRENT] = buffer_current;
- return true;
-}
-
-int circular_file::read(void* vdata, int nbytes)
-{
- unsigned char* data = (unsigned char*)vdata;
- int buffer_current = d_header[HD_BUFFER_CURRENT];
- int buffer_size = d_header[HD_BUFFER_SIZE];
- int total = 0;
-
- nbytes = std::min(nbytes, buffer_size - d_bytes_read);
-
- while (nbytes > 0) {
- int offset = (buffer_current + d_bytes_read) % buffer_size;
- int n = std::min(nbytes, buffer_size - offset);
- memcpy(data, d_buffer + offset, n);
- data += n;
- d_bytes_read += n;
- total += n;
- nbytes -= n;
- }
- return total;
-}
-
-void circular_file::reset_read_pointer() { d_bytes_read = 0; }
-
-} /* namespace gr */
diff --git a/gnuradio-runtime/lib/circular_file.h b/gnuradio-runtime/lib/circular_file.h
deleted file mode 100644
index 69cb82c81c..0000000000
--- a/gnuradio-runtime/lib/circular_file.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2002,2013 Free Software Foundation, Inc.
- *
- * This file is part of GNU Radio
- *
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- *
- * GNU Radio 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with GNU Radio; see the file COPYING. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifndef GR_CIRCULAR_FILE_H
-#define GR_CIRCULAR_FILE_H
-
-#include <gnuradio/api.h>
-
-namespace gr {
-
-/*
- * writes input data into a circular buffer on disk.
- *
- * the file contains a fixed header:
- * 0x0000: int32 magic (0xEB021026)
- * 0x0004: int32 size in bytes of header (constant 4096)
- * 0x0008: int32 size in bytes of circular buffer (not including header)
- * 0x000C: int32 file offset to beginning of circular buffer
- * 0x0010: int32 byte offset from beginning of circular buffer to
- * current start of data
- */
-class GR_RUNTIME_API circular_file
-{
-private:
- int d_fd;
- int* d_header;
- unsigned char* d_buffer;
- int d_mapped_size;
- int d_bytes_read;
-
-public:
- circular_file(const char* filename, bool writable = false, int size = 0);
- ~circular_file();
-
- bool write(void* data, int nbytes);
-
- // returns # of bytes actually read or 0 if end of buffer, or -1 on error.
- int read(void* data, int nbytes);
-
- // reset read pointer to beginning of buffer.
- void reset_read_pointer();
-};
-
-} /* namespace gr */
-
-#endif /* GR_CIRCULAR_FILE_H */
diff --git a/gnuradio-runtime/lib/qa_circular_file.cc b/gnuradio-runtime/lib/qa_circular_file.cc
deleted file mode 100644
index 53c98e9f87..0000000000
--- a/gnuradio-runtime/lib/qa_circular_file.cc
+++ /dev/null
@@ -1,66 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2002,2013,2018 Free Software Foundation, Inc.
- *
- * This file is part of GNU Radio
- *
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- *
- * GNU Radio 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with GNU Radio; see the file COPYING. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "circular_file.h"
-#include <unistd.h>
-#include <boost/test/unit_test.hpp>
-
-static const char* test_file = "qa_gr_circular_file.data";
-static const int BUFFER_SIZE = 8192;
-static const int NWRITE = 8192 * 9 / 8;
-
-BOOST_AUTO_TEST_CASE(t1)
-{
-#ifdef HAVE_MMAP
- gr::circular_file* cf_writer;
- gr::circular_file* cf_reader;
-
- // write the data...
- cf_writer = new gr::circular_file(test_file, true, BUFFER_SIZE * sizeof(short));
-
- short sd;
- for (int i = 0; i < NWRITE; i++) {
- sd = i;
- cf_writer->write(&sd, sizeof(sd));
- }
-
- delete cf_writer;
-
- // now read it back...
- cf_reader = new gr::circular_file(test_file);
- for (int i = 0; i < BUFFER_SIZE; i++) {
- int n = cf_reader->read(&sd, sizeof(sd));
- BOOST_CHECK_EQUAL((int)sizeof(sd), n);
- BOOST_CHECK_EQUAL(NWRITE - BUFFER_SIZE + i, (int)sd);
- }
-
- int n = cf_reader->read(&sd, sizeof(sd));
- BOOST_CHECK_EQUAL(0, n);
-
- delete cf_reader;
- unlink(test_file);
-#endif // HAVE_MMAP
-}
diff --git a/gr-blocks/lib/ConfigChecks.cmake b/gr-blocks/lib/ConfigChecks.cmake
index d359a54d95..3356cf9e1a 100644
--- a/gr-blocks/lib/ConfigChecks.cmake
+++ b/gr-blocks/lib/ConfigChecks.cmake
@@ -28,7 +28,6 @@ ENDIF(MSVC)
GR_CHECK_HDR_N_DEF(sys/time.h HAVE_SYS_TIME_H)
GR_CHECK_HDR_N_DEF(sys/types.h HAVE_SYS_TYPES_H)
GR_CHECK_HDR_N_DEF(sys/socket.h HAVE_SYS_SOCKET_H)
-GR_CHECK_HDR_N_DEF(io.h HAVE_IO_H)
GR_CHECK_HDR_N_DEF(sys/mman.h HAVE_SYS_MMAN_H)
GR_CHECK_HDR_N_DEF(sys/ipc.h HAVE_SYS_IPC_H)
GR_CHECK_HDR_N_DEF(sys/shm.h HAVE_SYS_SHM_H)