[misc] Explicitly check for pthread_setname_np/pthread_set_name_np

Seems there is no pthread_setname_np in OpenWrt
This commit is contained in:
ejurgensen
2016-05-05 19:39:15 +02:00
parent 95d0c25be3
commit 9a56044c77
8 changed files with 36 additions and 29 deletions

View File

@@ -30,7 +30,7 @@
#include <time.h>
#include <string.h>
#include <pthread.h>
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
#ifdef HAVE_PTHREAD_NP_H
# include <pthread_np.h>
#endif
@@ -1859,9 +1859,9 @@ cache_init(void)
goto thread_fail;
}
#if defined(__linux__)
#if defined(HAVE_PTHREAD_SETNAME_NP)
pthread_setname_np(tid_cache, "cache");
#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
#elif defined(HAVE_PTHREAD_SET_NAME_NP)
pthread_set_name_np(tid_cache, "cache");
#endif

View File

@@ -38,6 +38,9 @@
#include <fcntl.h>
#include <dirent.h>
#include <pthread.h>
#ifdef HAVE_PTHREAD_NP_H
# include <pthread_np.h>
#endif
#include <unistr.h>
#include <unictype.h>
@@ -45,10 +48,6 @@
#include <event2/event.h>
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
# include <pthread_np.h>
#endif
#ifdef HAVE_REGEX_H
# include <regex.h>
#endif
@@ -2165,9 +2164,9 @@ filescanner_init(void)
goto thread_fail;
}
#if defined(__linux__)
#if defined(HAVE_PTHREAD_SETNAME_NP)
pthread_setname_np(tid_scan, "filescanner");
#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
#elif defined(HAVE_PTHREAD_SET_NAME_NP)
pthread_set_name_np(tid_scan, "filescanner");
#endif

View File

@@ -28,7 +28,7 @@
#include <limits.h>
#include <errno.h>
#include <pthread.h>
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
#ifdef HAVE_PTHREAD_NP_H
# include <pthread_np.h>
#endif
#include <time.h>
@@ -1401,9 +1401,9 @@ httpd_init(void)
goto thread_fail;
}
#if defined(__linux__)
#if defined(HAVE_PTHREAD_SETNAME_NP)
pthread_setname_np(tid_httpd, "httpd");
#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
#elif defined(HAVE_PTHREAD_SET_NAME_NP)
pthread_set_name_np(tid_httpd, "httpd");
#endif

View File

@@ -28,17 +28,20 @@
#include <limits.h>
#include <errno.h>
#include <pthread.h>
#ifdef HAVE_PTHREAD_NP_H
# include <pthread_np.h>
#endif
#include <sys/param.h>
#include <sys/queue.h>
#include <sys/types.h>
#include <stdint.h>
#include <inttypes.h>
# include <event2/event.h>
# include <event2/buffer.h>
# include <event2/bufferevent.h>
#include <event2/event.h>
#include <event2/buffer.h>
#include <event2/bufferevent.h>
#include <event2/http.h>
# include <event2/listener.h>
#include <event2/listener.h>
#if defined(HAVE_SYS_EVENTFD_H) && defined(HAVE_EVENTFD)
# define USE_EVENTFD
@@ -47,7 +50,6 @@
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
# include <netinet/in.h>
# include <pthread_np.h>
#endif
#include "logger.h"
@@ -4896,9 +4898,9 @@ int mpd_init(void)
goto thread_fail;
}
#if defined(__linux__)
#if defined(HAVE_PTHREAD_SETNAME_NP)
pthread_setname_np(tid_mpd, "mpd");
#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
#elif defined(HAVE_PTHREAD_SET_NAME_NP)
pthread_set_name_np(tid_mpd, "mpd");
#endif

View File

@@ -31,12 +31,14 @@
#include <errno.h>
#include <time.h>
#include <pthread.h>
#ifdef HAVE_PTHREAD_NP_H
# include <pthread_np.h>
#endif
#if defined(__linux__)
# include <sys/timerfd.h>
#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
# include <signal.h>
# include <pthread_np.h>
#endif
#include <event2/event.h>
@@ -4475,13 +4477,12 @@ player_init(void)
DPRINTF(E_FATAL, L_PLAYER, "Could not spawn player thread: %s\n", strerror(errno));
goto thread_fail;
}
#if defined(__linux__)
#if defined(HAVE_PTHREAD_SETNAME_NP)
pthread_setname_np(tid_player, "player");
#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
#elif defined(HAVE_PTHREAD_SET_NAME_NP)
pthread_set_name_np(tid_player, "player");
#endif
return 0;
thread_fail:

View File

@@ -37,7 +37,7 @@
#include <sys/queue.h>
#include <time.h>
#include <pthread.h>
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
#ifdef HAVE_PTHREAD_NP_H
# include <pthread_np.h>
#endif
@@ -2311,9 +2311,9 @@ spotify_init(void)
goto thread_fail;
}
#if defined(__linux__)
#if defined(HAVE_PTHREAD_SETNAME_NP)
pthread_setname_np(tid_spotify, "spotify");
#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
#elif defined(HAVE_PTHREAD_SET_NAME_NP)
pthread_set_name_np(tid_spotify, "spotify");
#endif

View File

@@ -30,7 +30,7 @@
#include <string.h>
#include <errno.h>
#include <pthread.h>
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
#ifdef HAVE_PTHREAD_NP_H
# include <pthread_np.h>
#endif
@@ -343,9 +343,9 @@ worker_init(void)
goto thread_fail;
}
#if defined(__linux__)
#if defined(HAVE_PTHREAD_SETNAME_NP)
pthread_setname_np(tid_worker, "worker");
#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
#elif defined(HAVE_PTHREAD_SET_NAME_NP)
pthread_set_name_np(tid_worker, "worker");
#endif