Commit 436e2dfa authored by Steffen Vogel's avatar Steffen Vogel 🎅🏼
Browse files

utils: move killme() to C++ code in order to avoid global objects

parent 19dd8df1
......@@ -37,8 +37,6 @@ extern "C" {
#include <villas/config.h>
#include <villas/log.h>
extern pthread_t main_thread;
#ifdef __GNUC__
#define LIKELY(x) __builtin_expect((x),1)
#define UNLIKELY(x) __builtin_expect((x),0)
......
......@@ -34,8 +34,6 @@
#include <villas/config.h>
#include <villas/utils.h>
pthread_t main_thread;
double box_muller(float m, float s)
{
double x1, x2, y1;
......@@ -113,15 +111,6 @@ void * memdup(const void *src, size_t bytes)
return dst;
}
void killme(int sig)
{
/* Send only to main thread in case the ID was initilized by signals_init() */
if (main_thread)
pthread_kill(main_thread, sig);
else
kill(0, sig);
}
pid_t spawn(const char* name, char *const argv[])
{
pid_t pid;
......
......@@ -35,6 +35,8 @@
namespace villas {
namespace utils {
static pthread_t main_thread;
std::vector<std::string>
tokenize(std::string s, std::string delimiter)
{
......@@ -156,5 +158,18 @@ char * decolor(char *str)
return str;
}
extern "C" {
void killme(int sig)
{
/* Send only to main thread in case the ID was initilized by signals_init() */
if (main_thread)
pthread_kill(main_thread, sig);
else
kill(0, sig);
}
}
} // namespace utils
} // namespace villas
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment