[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] [gnuradio] 07/12: android: runtime: issues related to
From: |
git |
Subject: |
[Commit-gnuradio] [gnuradio] 07/12: android: runtime: issues related to vmcircbuf; only mmap_tmpfile version working currently. |
Date: |
Fri, 19 Feb 2016 13:58:39 +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 eb381a5a4c63605b43fc02b8b246a0cd4c4f88ce
Author: Tom Rondeau <address@hidden>
Date: Fri Jan 2 17:35:28 2015 -0500
android: runtime: 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 | 10 +++++++-
gnuradio-runtime/lib/vmcircbuf_mmap_tmpfile.cc | 32 +++++++++++++++++---------
gnuradio-runtime/lib/vmcircbuf_sysv_shm.cc | 4 ++--
3 files changed, 32 insertions(+), 14 deletions(-)
diff --git a/gnuradio-runtime/lib/vmcircbuf.cc
b/gnuradio-runtime/lib/vmcircbuf.cc
index 05f08ce..cfc0f2c 100644
--- a/gnuradio-runtime/lib/vmcircbuf.cc
+++ b/gnuradio-runtime/lib/vmcircbuf.cc
@@ -68,8 +68,16 @@ namespace gr {
std::vector<gr::vmcircbuf_factory *> all = all_factories ();
+ // FIXME: Clean up between Android/normal
+ #if ANDROID
+ int ret = 35;
+ char name[35] = "gr::vmcircbuf_mmap_tmpfile_factory";
+ #else
char name[1024];
- if (gr::vmcircbuf_prefs::get(FACTORY_PREF_KEY, name, sizeof(name)) >= 0) {
+ int ret = gr::vmcircbuf_prefs::get(FACTORY_PREF_KEY, name, sizeof(name));
+ #endif
+
+ if(ret) {
for(unsigned int i = 0; i < all.size (); i++) {
if(strncmp(name, all[i]->name(), strlen(all[i]->name())) == 0) {
s_default_factory = all[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 updated (ff27361 -> b7870d6), git, 2016/02/19
- [Commit-gnuradio] [gnuradio] 12/12: analog: add ControlPort interfaces to frequency_modulator block., git, 2016/02/19
- [Commit-gnuradio] [gnuradio] 05/12: android: logger: adding Android log functions for different logging levels., git, 2016/02/19
- [Commit-gnuradio] [gnuradio] 07/12: android: runtime: issues related to vmcircbuf; only mmap_tmpfile version working currently.,
git <=
- [Commit-gnuradio] [gnuradio] 03/12: android: cmake: changed to using C checks for headers instead of C++., git, 2016/02/19
- [Commit-gnuradio] [gnuradio] 08/12: android: runtime: 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, 2016/02/19
- [Commit-gnuradio] [gnuradio] 04/12: android: cmake: adding Boost deps used static builds; ordering in this patch is important., git, 2016/02/19
- [Commit-gnuradio] [gnuradio] 06/12: android: runtime: Android does not support pthread_setaffinity_np; turned this into a nop call., git, 2016/02/19
- [Commit-gnuradio] [gnuradio] 09/12: android: runtime: moved global block registry to a static get function., git, 2016/02/19
- [Commit-gnuradio] [gnuradio] 10/12: android: rutnime: better logging and cleanup, git, 2016/02/19
- [Commit-gnuradio] [gnuradio] 11/12: cmake: cmake should get native thrift binary when cross compiling., git, 2016/02/19
- [Commit-gnuradio] [gnuradio] 01/12: android: fft: problems with wisdom files and MEASURE version of FFTW. Using a setting for the FFTW plan options if android or not., git, 2016/02/19
- [Commit-gnuradio] [gnuradio] 02/12: android: cmake: adding toolchain file for building., git, 2016/02/19