Use prctl on Linux to follow standard GNU/Linux functions

This commit is contained in:
Medicine Yeh 2016-02-03 18:42:20 +08:00
parent ff84a85f43
commit 49e5cbe5af
1 changed files with 5 additions and 4 deletions

View File

@ -8,9 +8,6 @@
*
********************************/
#if defined(__linux__)
#define _GNU_SOURCE
#endif
#include <unistd.h>
#include <signal.h>
#include <stdio.h>
@ -18,6 +15,9 @@
#include <pthread.h>
#include <errno.h>
#include <time.h>
#if defined(__linux__)
#include <sys/prctl.h>
#endif
#include "thpool.h"
#ifdef THPOOL_DEBUG
@ -306,7 +306,8 @@ static void* thread_do(struct thread* thread_p){
sprintf(thread_name, "thread-pool-%d", thread_p->id);
#if defined(__linux__)
pthread_setname_np(thread_p->pthread, thread_name);
/* Use prctl instead to prevent using _GNU_SOURCE flag and implicit declaration */
prctl(PR_SET_NAME, thread_name);
#elif defined(__APPLE__) && defined(__MACH__)
pthread_setname_np(thread_name);
#else