mirror of
https://git.rwth-aachen.de/acs/public/villas/node/
synced 2025-03-30 00:00:11 +01:00
utils: move killme() to C++ code in order to avoid global objects
This commit is contained in:
parent
5fe159de0a
commit
2b67178a04
3 changed files with 15 additions and 13 deletions
|
@ -37,8 +37,6 @@ extern "C" {
|
||||||
#include <villas/config.h>
|
#include <villas/config.h>
|
||||||
#include <villas/log.h>
|
#include <villas/log.h>
|
||||||
|
|
||||||
extern pthread_t main_thread;
|
|
||||||
|
|
||||||
#ifdef __GNUC__
|
#ifdef __GNUC__
|
||||||
#define LIKELY(x) __builtin_expect((x),1)
|
#define LIKELY(x) __builtin_expect((x),1)
|
||||||
#define UNLIKELY(x) __builtin_expect((x),0)
|
#define UNLIKELY(x) __builtin_expect((x),0)
|
||||||
|
|
|
@ -34,8 +34,6 @@
|
||||||
#include <villas/config.h>
|
#include <villas/config.h>
|
||||||
#include <villas/utils.h>
|
#include <villas/utils.h>
|
||||||
|
|
||||||
pthread_t main_thread;
|
|
||||||
|
|
||||||
double box_muller(float m, float s)
|
double box_muller(float m, float s)
|
||||||
{
|
{
|
||||||
double x1, x2, y1;
|
double x1, x2, y1;
|
||||||
|
@ -113,15 +111,6 @@ void * memdup(const void *src, size_t bytes)
|
||||||
return dst;
|
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 spawn(const char* name, char *const argv[])
|
||||||
{
|
{
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
|
|
|
@ -35,6 +35,8 @@
|
||||||
namespace villas {
|
namespace villas {
|
||||||
namespace utils {
|
namespace utils {
|
||||||
|
|
||||||
|
static pthread_t main_thread;
|
||||||
|
|
||||||
std::vector<std::string>
|
std::vector<std::string>
|
||||||
tokenize(std::string s, std::string delimiter)
|
tokenize(std::string s, std::string delimiter)
|
||||||
{
|
{
|
||||||
|
@ -156,5 +158,18 @@ char * decolor(char *str)
|
||||||
return 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 utils
|
||||||
} // namespace villas
|
} // namespace villas
|
||||||
|
|
Loading…
Add table
Reference in a new issue