From patchwork Thu Jan 4 04:19:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brad Smith X-Patchwork-Id: 45476 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:6623:b0:194:e134:edd4 with SMTP id n35csp7638447pzh; Wed, 3 Jan 2024 20:20:09 -0800 (PST) X-Google-Smtp-Source: AGHT+IFJn8OBHsfDxfFB8RjggaXHlK3k6rcUE0F+OdNB5c/6Xm24LjsnI0flOpUEzBZeDBI+90KE X-Received: by 2002:a17:906:a297:b0:a28:aab9:656 with SMTP id i23-20020a170906a29700b00a28aab90656mr724443ejz.94.1704342009252; Wed, 03 Jan 2024 20:20:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704342009; cv=none; d=google.com; s=arc-20160816; b=Qk6LCffanMd9PhJnW8fe2NHJLT1zvibu36m5qrU46t6REb1mDAfcP3vRSaUQ0ivi+y Yb8GazNQO3svT8W0GAsQvAV19chyBaR+kTmXAlr6w6ES8mWtVVYO9FI+74yZKZiiwUYy ZXrVRVSlBqywEBZO43MF81gsAQ497LF5pqFT5yD+BZKxWoOaqcB/qFUzoKyoadHLt/s2 rhvF2bvau8I+9IWCwOjTy7Dulfqk9xB7N3FGChtQcSEsz1ySYSGlZOL9ZZR0G3cyt9Dg 1rMp5pWNxm52jyKVuM+fmCK69FuOtsBsKON3fNxoroCfvDPPoShLjdlZuR+IYa1xX2Wf EEFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:content-disposition:mime-version:message-id:to :from:date:domainkey-signature:dkim-signature:delivered-to; bh=H5Nhahh0ZoifddjH2kHSa62DXuhmrdqrvnNgXGBFG0M=; fh=e5zN9xSzcxLA6bGo3lF+CqTbY/oLwzApV03EO/RBfgQ=; b=o35zVrMxydU8TS1E4/U/x2vA7X3ID5gBQq6onH2Pp0zkczTCRrsFAHG8sJHD06QELp nTdCyIgAINv0Bc0M38orcRDl3OGJU8hz6r5V6OfL2Xx2hyStMRRBlg5Dx/bWuo6M6QTa B/b5u6VABNIuuh2XF2Aeb3NfBEmieAfB9krWZFl+ozGkDyyi/o2vbylI2522Z6Rwm3CP dXwG+F/ogXYFQmaZKBapfS4lpdaq0gDN5XjoTBPic4cuHa3/scbfzDuDxNrqIZY5KqT2 lb5Q1JQuezUqI5mFDBwVkFCOynfQsswHZ9ymD5PKzOniyXybkBQWrbJYPJxsfgrffLF3 JAZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@comstyle.com header.s=default header.b=hSbMAbeH; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id zr13-20020a170907710d00b00a27a507c1c0si4345642ejb.943.2024.01.03.20.20.08; Wed, 03 Jan 2024 20:20:09 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@comstyle.com header.s=default header.b=hSbMAbeH; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 8E9F568CD06; Thu, 4 Jan 2024 06:20:05 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail.comstyle.com (speedy.comstyle.com [206.51.28.2]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id CE7A468C935 for ; Thu, 4 Jan 2024 06:19:59 +0200 (EET) Received: from mail.comstyle.com (localhost [127.0.0.1]) by mail.comstyle.com (Postfix) with ESMTP id 4T5Czd5Xtnz8PbP for ; Wed, 3 Jan 2024 23:19:57 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=comstyle.com; h=date:from :to:subject:message-id:mime-version:content-type; s=default; bh= NLFtU9Az3943qHuhOmY8mp/PErI=; b=hSbMAbeHsnmssIVtJCVkikOObegWeTCF Gm4ao1ZD91UgxNL1JfjvawM2EgUTxnKI0I43nPX6qB8uJ/PyIGQBXR1WrVYGVjgS 39KExarOPp95k3XFgixv4i6ki2xLBDyhd02bEdhCPFNR62i5TGhYxhW8snv8IO76 R0XRlS3g134= DomainKey-Signature: a=rsa-sha1; c=nofws; d=comstyle.com; h=date:from:to :subject:message-id:mime-version:content-type; q=dns; s=default; b= oeXQwmvH0jTNSD+a7ivgwazXu4EVJMgZ7Cac992QO2CyEstNz1F4XWhN5EThsngZ jsK7spPr7YeFyQiQNYyhU/Icj/D6ArMaVx5X7iwzHLKGpP3893QltjefybJ1qR9A truCAotXWF2426jMhXbatVw4pm6ndZ29TzdHWt+NAC4= Received: from humpty.home.comstyle.com (unknown [IPv6:2001:470:b050:3:52f4:81fe:d2d6:ff14]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA512) (No client certificate requested) (Authenticated sender: brad) by mail.comstyle.com (Postfix) with ESMTPSA id 4T5Czd509mz8PbN for ; Wed, 3 Jan 2024 23:19:57 -0500 (EST) Date: Wed, 3 Jan 2024 23:19:56 -0500 From: Brad Smith To: FFmpeg development discussions and patches Message-ID: MIME-Version: 1.0 Content-Disposition: inline Subject: [FFmpeg-devel] [PATCH] lavu/thread: add support for setting thread name on *bsd and solaris X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: oYWBt9eq8vqp lavu/thread: add support for setting thread name on *bsd and solaris FreeBSD/DragonFly/Solaris use pthread_setname_np(). OpenBSD uses pthread_set_name_np(). Signed-off-by: Brad Smith --- configure | 10 ++++++++++ libavutil/thread.h | 14 ++++++++++++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/configure b/configure index d15cfa4703..154db61c16 100755 --- a/configure +++ b/configure @@ -2239,6 +2239,7 @@ HEADERS_LIST=" opencv2_core_core_c_h OpenGL_gl3_h poll_h + pthread_np_h sys_param_h sys_resource_h sys_select_h @@ -2341,6 +2342,8 @@ SYSTEM_FUNCS=" posix_memalign prctl pthread_cancel + pthread_set_name_np + pthread_setname_np sched_getaffinity SecItemImport SetConsoleTextAttribute @@ -6521,6 +6524,7 @@ check_headers malloc.h check_headers mftransform.h check_headers net/udplite.h check_headers poll.h +check_headers pthread_np.h check_headers sys/param.h check_headers sys/resource.h check_headers sys/select.h @@ -6689,6 +6693,12 @@ if ! disabled pthreads && ! enabled w32threads && ! enabled os2threads; then if enabled pthreads; then check_builtin sem_timedwait semaphore.h "sem_t *s; sem_init(s,0,0); sem_timedwait(s,0); sem_destroy(s)" $pthreads_extralibs check_func pthread_cancel $pthreads_extralibs + hdrs=pthread.h + if enabled pthread_np_h; then + hdrs="$hdrs pthread_np.h" + fi + check_lib pthreads "$hdrs" pthread_set_name_np -lpthread + check_lib pthreads "$hdrs" pthread_setname_np -lpthread fi fi diff --git a/libavutil/thread.h b/libavutil/thread.h index 2ded498c89..fa74dd2ea7 100644 --- a/libavutil/thread.h +++ b/libavutil/thread.h @@ -26,6 +26,8 @@ #if HAVE_PRCTL #include +#elif (HAVE_PTHREAD_SETNAME_NP || HAVE_PTHREAD_SET_NAME_NP) && HAVE_PTHREAD_NP_H +#include #endif #include "error.h" @@ -213,11 +215,19 @@ 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 + ret = AVERROR(pthread_setname_np(pthread_self(), name)); +#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 */