Skip to content

Commit

Permalink
fixed previous commit
Browse files Browse the repository at this point in the history
pthread.h was not included in thread.c in the end

\+ small improvements
  • Loading branch information
MartinPulec committed Nov 10, 2023
1 parent 9f5530d commit ddaba11
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
9 changes: 6 additions & 3 deletions src/utils/thread.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@
#endif

#include <libgen.h>
#ifndef _WIN32
#include <pthread.h>
#endif
#ifdef HAVE_SETTHREADDESCRIPTION
#include <processthreadsapi.h>
#endif
Expand All @@ -65,7 +68,7 @@ static inline char *get_argv_program_name(void) {
#endif

void set_thread_name(const char *name) {
#ifdef HAVE_LINUX
#ifdef __linux__
// thread name can have at most 16 chars (including terminating null char)
char *prog_name = get_argv_program_name();
char tmp[16];
Expand All @@ -74,14 +77,14 @@ void set_thread_name(const char *name) {
free(prog_name);
strncat(tmp, name, sizeof tmp - strlen(tmp) - 1);
pthread_setname_np(pthread_self(), tmp);
#elif defined HAVE_MACOSX
#elif defined __APPLE__
char *prog_name = get_argv_program_name();
char *tmp = (char *) alloca(strlen(prog_name) + strlen(name) + 1);
strcpy(tmp, prog_name);
free(prog_name);
strcat(tmp, name);
pthread_setname_np(tmp);
#elif defined WIN32
#elif defined _WIN32
// supported from Windows 10, not yet in headers
#ifdef HAVE_SETTHREADDESCRIPTION
const char *prog_name = get_argv_program_name();
Expand Down
2 changes: 1 addition & 1 deletion src/utils/worker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@
#include "utils/thread.h"
#include "utils/worker.h"

#include <cassert>
#include <algorithm>
#include <cassert>
#include <pthread.h>
#include <queue>
#include <set>
Expand Down

0 comments on commit ddaba11

Please sign in to comment.