summaryrefslogtreecommitdiffstats
path: root/media/ffvpx/libavutil/thread.h
diff options
context:
space:
mode:
Diffstat (limited to 'media/ffvpx/libavutil/thread.h')
-rw-r--r--media/ffvpx/libavutil/thread.h20
1 files changed, 18 insertions, 2 deletions
diff --git a/media/ffvpx/libavutil/thread.h b/media/ffvpx/libavutil/thread.h
index 2ded498c89..2c00c7cc35 100644
--- a/media/ffvpx/libavutil/thread.h
+++ b/media/ffvpx/libavutil/thread.h
@@ -26,6 +26,8 @@
#if HAVE_PRCTL
#include <sys/prctl.h>
+#elif (HAVE_PTHREAD_SETNAME_NP || HAVE_PTHREAD_SET_NAME_NP) && HAVE_PTHREAD_NP_H
+#include <pthread_np.h>
#endif
#include "error.h"
@@ -213,11 +215,25 @@ static inline int ff_thread_once(char *control, void (*routine)(void))
static inline int ff_thread_setname(const char *name)
{
+ int ret = 0;
+
#if HAVE_PRCTL
- return AVERROR(prctl(PR_SET_NAME, name));
+ ret = AVERROR(prctl(PR_SET_NAME, name));
+#elif HAVE_PTHREAD_SETNAME_NP
+#if defined(__APPLE__)
+ ret = AVERROR(pthread_setname_np(name));
+#elif defined(__NetBSD__)
+ ret = AVERROR(pthread_setname_np(pthread_self(), "%s", name));
+#else
+ ret = AVERROR(pthread_setname_np(pthread_self(), name));
+#endif
+#elif HAVE_PTHREAD_SET_NAME_NP
+ pthread_set_name_np(pthread_self(), name);
+#else
+ ret = AVERROR(ENOSYS);
#endif
- return AVERROR(ENOSYS);
+ return ret;
}
#endif /* AVUTIL_THREAD_H */