mirror of
https://github.com/oxen-io/lokinet
synced 2023-12-14 06:53:00 +01:00
Merge pull request #695 from majestrate/fix-freebsd-pthread
fix freebsd build for real
This commit is contained in:
commit
a768a9ad59
2 changed files with 12 additions and 5 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -29,6 +29,8 @@ callgrind.*
|
|||
shadow.data
|
||||
shadow.config.xml
|
||||
*.log
|
||||
*.pdf
|
||||
*.xz
|
||||
|
||||
testnet_tmp
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
#ifdef POSIX
|
||||
#include <pthread.h>
|
||||
#ifdef __FreeBSD__
|
||||
#if defined(__FreeBSD__)
|
||||
#include <pthread_np.h>
|
||||
#endif
|
||||
#endif
|
||||
|
@ -17,18 +17,23 @@ namespace llarp
|
|||
SetThreadName(const std::string& name)
|
||||
{
|
||||
#ifdef POSIX
|
||||
#ifdef __MACH__
|
||||
const int rc = pthread_setname_np(name.c_str());
|
||||
#elif defined(__FreeBSD__)
|
||||
const int rc = pthread_setname_np(pthread_self(), name.c_str(), nullptr);
|
||||
#if defined(__FreeBSD__)
|
||||
/* on free bsd this function has void return type */
|
||||
pthread_set_name_np(pthread_self(), name.c_str();
|
||||
#else
|
||||
#if defined(__MACH__)
|
||||
const int rc = pthread_setname_np(name.c_str());
|
||||
#elif defined(__linux__)
|
||||
const int rc = pthread_setname_np(pthread_self(), name.c_str());
|
||||
#else
|
||||
#error "unsupported platform"
|
||||
#endif
|
||||
if(rc)
|
||||
{
|
||||
LogError("Failed to set thread name to ", name, " errno = ", rc,
|
||||
" errstr = ", strerror(rc));
|
||||
}
|
||||
#endif
|
||||
#else
|
||||
LogInfo("Thread name setting not supported on this platform");
|
||||
(void)name;
|
||||
|
|
Loading…
Reference in a new issue