[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] [gnuradio] 04/14: runtime: android: issues related to
From: |
git |
Subject: |
[Commit-gnuradio] [gnuradio] 04/14: runtime: android: issues related to vmcircbuf; only mmap_tmpfile version working currently. |
Date: |
Thu, 12 Mar 2015 19:38:13 +0000 (UTC) |
This is an automated email from the git hooks/post-receive script.
trondeau pushed a commit to branch android
in repository gnuradio.
commit bcc38653f13bc98ca7e27c2cd4a58d85ae377145
Author: Tom Rondeau <address@hidden>
Date: Fri Jan 2 17:35:28 2015 -0500
runtime: android: issues related to vmcircbuf; only mmap_tmpfile version
working currently.
- updated checks in sysv_shm circbuf to protect when shm.h exists but
shmget doesn't.
- fixed mmap_tmpfile circbuf class to work better with android.
- open parameters set for Android (does not support O_EXCL).
- The gr::tmp_path() works only if the TMP env var is defined, which we
have to do specially through the Java app we create.
- Use GR_X log methods for logger info
---
gnuradio-runtime/lib/vmcircbuf.cc | 3 ++-
gnuradio-runtime/lib/vmcircbuf_mmap_tmpfile.cc | 32 +++++++++++++++++---------
gnuradio-runtime/lib/vmcircbuf_sysv_shm.cc | 4 ++--
3 files changed, 25 insertions(+), 14 deletions(-)
diff --git a/gnuradio-runtime/lib/vmcircbuf.cc
b/gnuradio-runtime/lib/vmcircbuf.cc
index d17ed72..93b0021 100644
--- a/gnuradio-runtime/lib/vmcircbuf.cc
+++ b/gnuradio-runtime/lib/vmcircbuf.cc
@@ -68,7 +68,8 @@ namespace gr {
std::vector<gr::vmcircbuf_factory *> all = all_factories ();
- const char *name = gr::vmcircbuf_prefs::get(FACTORY_PREF_KEY);
+ //const char *name = gr::vmcircbuf_prefs::get(FACTORY_PREF_KEY);
+ const char *name = "gr::vmcircbuf_mmap_tmpfile_factory";
if(name) {
for(unsigned int i = 0; i < all.size (); i++) {
diff --git a/gnuradio-runtime/lib/vmcircbuf_mmap_tmpfile.cc
b/gnuradio-runtime/lib/vmcircbuf_mmap_tmpfile.cc
index 7a02fe2..5e9abc7 100644
--- a/gnuradio-runtime/lib/vmcircbuf_mmap_tmpfile.cc
+++ b/gnuradio-runtime/lib/vmcircbuf_mmap_tmpfile.cc
@@ -41,6 +41,7 @@
#include <string.h>
#include "pagesize.h"
#include <gnuradio/sys_paths.h>
+#include <gnuradio/logger.h>
namespace gr {
@@ -48,13 +49,13 @@ namespace gr {
: gr::vmcircbuf (size)
{
#if !defined(HAVE_MMAP)
- fprintf(stderr, "gr::vmcircbuf_mmap_tmpfile: mmap or mkstemp is not
available\n");
+ GR_ERROR("gr_log", "gr::vmcircbuf_mmap_tmpfile: mmap or mkstemp is not
available");
throw std::runtime_error("gr::vmcircbuf_mmap_tmpfile");
#else
gr::thread::scoped_lock guard(s_vm_mutex);
if(size <= 0 || (size % gr::pagesize ()) != 0) {
- fprintf(stderr, "gr::vmcircbuf_mmap_tmpfile: invalid size = %d\n", size);
+ GR_ERROR("gr_log", boost::format("gr::vmcircbuf_mmap_tmpfile: invalid
size = %1%") % size);
throw std::runtime_error("gr::vmcircbuf_mmap_tmpfile");
}
@@ -69,7 +70,14 @@ namespace gr {
"%s/gnuradio-%d-%d-XXXXXX", gr::tmp_path(), getpid(),
s_seg_counter);
s_seg_counter++;
+#ifndef ANDROID
seg_fd = open(seg_name, O_RDWR | O_CREAT | O_EXCL, 0600);
+#else
+ seg_fd = open(seg_name, O_RDWR | O_CREAT, 0600);
+#endif /* ANDROID */
+
+ GR_INFO("gr_log", boost::format("gr::mvcircbuf_mmap_tmpfile: opened:
%1%") % seg_fd);
+
if(seg_fd == -1) {
if(errno == EEXIST) // File already exists (shouldn't happen). Try
again
continue;
@@ -77,14 +85,15 @@ namespace gr {
char msg[1024];
snprintf(msg, sizeof (msg),
"gr::vmcircbuf_mmap_tmpfile: open [%s]", seg_name);
- perror(msg);
+ GR_ERROR("gr_log", boost::format("gr::vmcircbuf_mmap_tmpfile: open
failed [%1%], errno: %1%") \
+ % seg_name % (strerror(errno)));
throw std::runtime_error("gr::vmcircbuf_mmap_tmpfile");
}
break;
}
if(unlink (seg_name) == -1) {
- perror("gr::vmcircbuf_mmap_tmpfile: unlink");
+ GR_ERROR("gr_log", boost::format("gr::vmcircbuf_mmap_tmpfile: unlink,
errno: %1%") % (strerror(errno)));
throw std::runtime_error ("gr::vmcircbuf_mmap_tmpfile");
}
@@ -92,7 +101,8 @@ namespace gr {
// Now set it's length to 2x what we really want and mmap it in.
if(ftruncate (seg_fd, (off_t) 2 * size) == -1) {
close(seg_fd); // cleanup
- perror("gr::vmcircbuf_mmap_tmpfile: ftruncate (1)");
+ GR_ERROR("gr_log", boost::format("gr::vmcircbuf_mmap_tmpfile: ftruncate
(1), errno: %1%") \
+ % (strerror(errno)));
throw std::runtime_error("gr::vmcircbuf_mmap_tmpfile");
}
@@ -102,14 +112,14 @@ namespace gr {
if(first_copy == MAP_FAILED) {
close(seg_fd); // cleanup
- perror("gr::vmcircbuf_mmap_tmpfile: mmap (1)");
+ GR_ERROR("gr_log", boost::format("gr::vmcircbuf_mmap_tmpfile: mmap (1),
errno: %1%") % (strerror(errno)));
throw std::runtime_error ("gr::vmcircbuf_mmap_tmpfile");
}
// unmap the 2nd half
if(munmap ((char *) first_copy + size, size) == -1) {
close(seg_fd); // cleanup
- perror("gr::vmcircbuf_mmap_tmpfile: munmap (1)");
+ GR_ERROR("gr_log", boost::format("gr::vmcircbuf_mmap_tmpfile: munmap
(1), errno: %1%") % (strerror(errno)));
throw std::runtime_error("gr::vmcircbuf_mmap_tmpfile");
}
@@ -122,7 +132,7 @@ namespace gr {
if(second_copy == MAP_FAILED) {
munmap(first_copy, size); //
cleanup
close(seg_fd);
- perror("gr::vmcircbuf_mmap_tmpfile: mmap(2)");
+ GR_ERROR("gr_log", boost::format("gr::vmcircbuf_mmap_tmpfile: mmap (2),
errno: %1%") % (strerror(errno)));
throw std::runtime_error("gr::vmcircbuf_mmap_tmpfile");
}
@@ -131,7 +141,7 @@ namespace gr {
munmap(first_copy, size); //
cleanup
munmap(second_copy, size);
close(seg_fd);
- perror("gr::vmcircbuf_mmap_tmpfile: non-contiguous second copy");
+ GR_ERROR("gr_log", boost::format("gr::vmcircbuf_mmap_tmpfile:
non-contiguous second copy, errno: %1%") % (strerror(errno)));
throw std::runtime_error("gr::vmcircbuf_mmap_tmpfile");
}
@@ -140,7 +150,7 @@ namespace gr {
munmap(first_copy, size); //
cleanup
munmap(second_copy, size);
close(seg_fd);
- perror("gr::vmcircbuf_mmap_tmpfile: ftruncate (2)");
+ GR_ERROR("gr_log", boost::format("gr::vmcircbuf_mmap_tmpfile: ftruncate
(2), errno: %1%") % (strerror(errno)));
throw std::runtime_error("gr::vmcircbuf_mmap_tmpfile");
}
@@ -159,7 +169,7 @@ namespace gr {
gr::thread::scoped_lock guard(s_vm_mutex);
if(munmap(d_base, 2 * d_size) == -1) {
- perror("gr::vmcircbuf_mmap_tmpfile: munmap(2)");
+ GR_ERROR("gr_log", boost::format("gr::vmcircbuf_mmap_tmpfile: munmap
(2), errno: %1%") % (strerror(errno)));
}
#endif
}
diff --git a/gnuradio-runtime/lib/vmcircbuf_sysv_shm.cc
b/gnuradio-runtime/lib/vmcircbuf_sysv_shm.cc
index c368128..f1c742c 100644
--- a/gnuradio-runtime/lib/vmcircbuf_sysv_shm.cc
+++ b/gnuradio-runtime/lib/vmcircbuf_sysv_shm.cc
@@ -47,7 +47,7 @@ namespace gr {
vmcircbuf_sysv_shm::vmcircbuf_sysv_shm(int size)
: gr::vmcircbuf(size)
{
-#if !defined(HAVE_SYS_SHM_H)
+#if !defined(HAVE_SHM_OPEN)
fprintf(stderr, "gr::vmcircbuf_sysv_shm: sysv shared memory is not
available\n");
throw std::runtime_error("gr::vmcircbuf_sysv_shm");
#else
@@ -162,7 +162,7 @@ namespace gr {
vmcircbuf_sysv_shm::~vmcircbuf_sysv_shm()
{
-#if defined(HAVE_SYS_SHM_H)
+#if defined(HAVE_SHM_OPEN)
gr::thread::scoped_lock guard(s_vm_mutex);
if(shmdt(d_base - gr::pagesize()) == -1
- [Commit-gnuradio] [gnuradio] branch android created (now 1e31c64), git, 2015/03/12
- [Commit-gnuradio] [gnuradio] 08/14: volk: Using C checks for Volk C FLags instead of CXX., git, 2015/03/12
- [Commit-gnuradio] [gnuradio] 05/14: fft: android: problems with wisdom files and MEASURE version of FFTW. Defaulting to suboptimal ESTIMATE until we figure it out., git, 2015/03/12
- [Commit-gnuradio] [gnuradio] 04/14: runtime: android: issues related to vmcircbuf; only mmap_tmpfile version working currently.,
git <=
- [Commit-gnuradio] [gnuradio] 09/14: runtime: trying to use ANDROID to define certain behavior, git, 2015/03/12
- [Commit-gnuradio] [gnuradio] 11/14: fft: defined a setting for the FFTW plan options if android or not., git, 2015/03/12
- [Commit-gnuradio] [gnuradio] 02/14: logger: android: adding Android log functions for different logging levels., git, 2015/03/12
- [Commit-gnuradio] [gnuradio] 13/14: runtime: android: more conversion of statics vars to static functions., git, 2015/03/12
- [Commit-gnuradio] [gnuradio] 12/14: runtime: android: need to use a usable, writable location for android apps, so use the tmp path that we set up to point to the app's home directory., git, 2015/03/12
- [Commit-gnuradio] [gnuradio] 06/14: volk: using hypot instead of cabsf., git, 2015/03/12
- [Commit-gnuradio] [gnuradio] 10/14: cmake: changed to using C checks for headers instead of C++., git, 2015/03/12
- [Commit-gnuradio] [gnuradio] 01/14: cmake: android: adding exceptions and atomic to Boost deps; ordering in this patch is important., git, 2015/03/12
- [Commit-gnuradio] [gnuradio] 03/14: runtime: android: Android does not support pthread_setaffinity_np; turned this into a nop call., git, 2015/03/12
- [Commit-gnuradio] [gnuradio] 07/14: volk: force some support required for android builds; boost unit tests not working yet., git, 2015/03/12