summaryrefslogtreecommitdiffstats
path: root/osdep/threads.c
diff options
context:
space:
mode:
Diffstat (limited to 'osdep/threads.c')
-rw-r--r--osdep/threads.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/osdep/threads.c b/osdep/threads.c
index 8cb03045e4..c41007b2cb 100644
--- a/osdep/threads.c
+++ b/osdep/threads.c
@@ -14,6 +14,9 @@
* You should have received a copy of the GNU General Public License along
* with mpv. If not, see <http://www.gnu.org/licenses/>.
*/
+#include <stdio.h>
+
+#include "config.h"
#include "threads.h"
#include "timer.h"
@@ -40,3 +43,16 @@ int mpthread_mutex_init_recursive(pthread_mutex_t *mutex)
pthread_mutexattr_destroy(&attr);
return r;
}
+
+void mpthread_set_name(const char *name)
+{
+ char tname[90];
+ snprintf(tname, sizeof(tname), "mpv %s", name);
+#if HAVE_GLIBC_THREAD_NAME
+ pthread_setname_np(pthread_self(), tname);
+#elif HAVE_BSD_THREAD_NAME
+ pthread_set_name_np(pthread_self(), tname);
+#elif HAVE_OSX_THREAD_NAME
+ pthread_setname_np(tname);
+#endif
+}