Skip to content

Commit

Permalink
Support pthread_setname_np() on FreeBSD and while here use
Browse files Browse the repository at this point in the history
positive logic in the ifdefs.
  • Loading branch information
glebius authored and john-preston committed Sep 17, 2021
1 parent dbe340b commit 05a896f
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions threading.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
#ifdef __APPLE__
#include "os/darwin/DarwinSpecific.h"
#endif
#ifdef __FreeBSD__
#include <pthread_np.h>
#endif

namespace tgvoip{
class Mutex{
Expand Down Expand Up @@ -92,9 +95,9 @@ namespace tgvoip{
static void* ActualEntryPoint(void* arg){
Thread* self=reinterpret_cast<Thread*>(arg);
if(self->name){
#if !defined(__APPLE__) && !defined(__gnu_hurd__)
#if defined(__linux__) || defined(__FreeBSD__)
pthread_setname_np(self->thread, self->name);
#elif !defined(__gnu_hurd__)
#elif defined(__APPLE__)
pthread_setname_np(self->name);
if(self->maxPriority){
DarwinSpecific::SetCurrentThreadPriority(DarwinSpecific::THREAD_PRIO_USER_INTERACTIVE);
Expand Down

0 comments on commit 05a896f

Please sign in to comment.