aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2017-12-15 10:07:03 +0100
committerMatthias P. Braendli <matthias.braendli@mpb.li>2017-12-15 10:07:03 +0100
commitf041360ac17bc032c7e5a4553372893e42ba68c6 (patch)
tree99c66c42e7a1fa41e139a334bab6fde39b79c735
parent477782190324caf69445f59e2a9ce02152c06106 (diff)
downloaddabmod-f041360ac17bc032c7e5a4553372893e42ba68c6.tar.gz
dabmod-f041360ac17bc032c7e5a4553372893e42ba68c6.tar.bz2
dabmod-f041360ac17bc032c7e5a4553372893e42ba68c6.zip
Check for prctl portability
-rw-r--r--configure.ac11
-rw-r--r--src/Utils.cpp6
-rw-r--r--src/Utils.h1
3 files changed, 17 insertions, 1 deletions
diff --git a/configure.ac b/configure.ac
index 9bb0ebc..261d444 100644
--- a/configure.ac
+++ b/configure.ac
@@ -173,6 +173,17 @@ AC_COMPILE_IFELSE(
[AC_MSG_RESULT([yes])], [AC_MSG_RESULT([no]) AC_DEFINE([M_PIl], [M_PI], [Replacing define])])
AC_LANG_POP([C++])
+# Linux has prctl to set thread names
+AC_MSG_CHECKING(for prctl and PR_SET_NAME)
+AC_COMPILE_IFELSE([ AC_LANG_PROGRAM([[
+ #include <sys/prctl.h>
+ void set_thread_name() {
+ prctl(PR_SET_NAME,"test",0,0,0);
+ }
+ ]])],
+ [ AC_MSG_RESULT(yes)
+ AC_DEFINE(HAVE_PRCTL, 1, [Define this symbol if you have prctl and PR_SET_NAME]) ],
+ [ AC_MSG_RESULT(no) ])
# Check for march
AS_IF([test "x$enable_native" = "xyes"],
diff --git a/src/Utils.cpp b/src/Utils.cpp
index cd116c7..f423dc1 100644
--- a/src/Utils.cpp
+++ b/src/Utils.cpp
@@ -27,7 +27,9 @@
#include "Utils.h"
#include "GainControl.h"
-#include <sys/prctl.h>
+#if defined(HAVE_PRCTL)
+# include <sys/prctl.h>
+#endif
#include <pthread.h>
static void printHeader()
@@ -160,7 +162,9 @@ int set_realtime_prio(int prio)
void set_thread_name(const char *name)
{
+#if defined(HAVE_PRCTL)
prctl(PR_SET_NAME,name,0,0,0);
+#endif
}
double parseChannel(const std::string& chan)
diff --git a/src/Utils.h b/src/Utils.h
index 8da3a1b..6a36baf 100644
--- a/src/Utils.h
+++ b/src/Utils.h
@@ -62,6 +62,7 @@ inline long timespecdiff_us(struct timespec& oldTime, struct timespec& time)
// Set SCHED_RR with priority prio (0=lowest)
int set_realtime_prio(int prio);
+// Set the name of the thread
void set_thread_name(const char *name);
// Convert a channel like 10A to a frequency