diff options
| author | Daniel Mack <zonque@gmail.com> | 2011-04-22 04:28:11 +0200 | 
|---|---|---|
| committer | Colin Guthrie <colin@mageia.org> | 2011-04-23 18:23:37 +0100 | 
| commit | 2411d9accd3b7b31e37fcfe083f06b5e35d84679 (patch) | |
| tree | 85336199198d124ac218a0741e1a386760a3a2a6 /src | |
| parent | 98f2209663596ec7d022af2aa8328ef224f2b80b (diff) | |
thread-posix: Use pthread_(get|set)name_np() if available
Newer generations of libpthread have functions to set and get the thread
names. If available, use them.
Diffstat (limited to 'src')
| -rw-r--r-- | src/pulsecore/thread-posix.c | 9 | 
1 files changed, 9 insertions, 0 deletions
diff --git a/src/pulsecore/thread-posix.c b/src/pulsecore/thread-posix.c index 7d5252d6..58bcb72a 100644 --- a/src/pulsecore/thread-posix.c +++ b/src/pulsecore/thread-posix.c @@ -73,6 +73,8 @@ static void* internal_thread_func(void *userdata) {  #ifdef __linux__      prctl(PR_SET_NAME, t->name); +#elif defined(HAVE_PTHREAD_SETNAME_NP) && defined(OS_IS_DARWIN) +    pthread_setname_np(t->name);  #endif      t->id = pthread_self(); @@ -177,6 +179,8 @@ void pa_thread_set_name(pa_thread *t, const char *name) {  #ifdef __linux__      prctl(PR_SET_NAME, name); +#elif defined(HAVE_PTHREAD_SETNAME_NP) && defined(OS_IS_DARWIN) +    pthread_setname_np(name);  #endif  } @@ -194,6 +198,11 @@ const char *pa_thread_get_name(pa_thread *t) {              t->name = NULL;          }      } +#elif defined(HAVE_PTHREAD_GETNAME_NP) && defined(OS_IS_DARWIN) +    if (!t->name) { +        t->name = pa_xmalloc0(17); +        pthread_getname_np(t->id, t->name, 16); +    }  #endif      return t->name;  | 
