From patchwork Sun Sep 15 05:39:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brad Smith X-Patchwork-Id: 51608 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a59:9fc3:0:b0:48e:c0f8:d0de with SMTP id k3csp627608vqy; Sat, 14 Sep 2024 22:40:13 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWUtIh3M7YjZWh+dQLZiAzUqjp99WJfRbvyI2t6tnD/CGvhc7lvgV6tiIim+cLP+WTZZosMUrorOLwuP6sMyxCx@gmail.com X-Google-Smtp-Source: AGHT+IE8vOcW/nZ8Ds6pqafrYKHpOCw/rZqTwDOWxEay/4T0LyVG+RRNF9vLHy8zdnM6HeFl5I4P X-Received: by 2002:a17:907:1b20:b0:a8d:446a:ded8 with SMTP id a640c23a62f3a-a9029504e9fmr1299618466b.22.1726378812896; Sat, 14 Sep 2024 22:40:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1726378812; cv=none; d=google.com; s=arc-20240605; b=NudLLyPAjx3Ze0FBuu2tu3uWxTWxPy5W1jVc7kJpoVZQ69nX4VBfSfgLdnb1UnjxCB CTDhzgq/UnpIOFsNa8sOubFHeF818xuOXEf7pE1nO/Nqq/TAVJoX2wlOKs0kAG/Kyl+J lvrVtylpSUkhpRLJnrQiOMZ+VyYDVpEZC44FmHSQjN5wJXA5D7q8XDTBKondj52oJ4ZY ZCd9fcSsvWakxDyN+25u9PFxD+8BwjATTmAdlVevhsHvNGUToQKk3ei/FNQSgQ7UQq/p 6AU9+zi/cBBvpZX0ORT3w+Dx2agzTiQzERdzn9tPjkHYSJ8DPUwiHfapGvc3zPn3ds6l 33hw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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=bzJrhRK0Toa9cjLBcsQtnQJvXocCFgk0BzXbbEGDP+c=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=JhKdU6Y5oQMkcfHE3qFaKfTBcrkzpxrMxqm7mwHup090l7d/jRBMroDcebF4uMZ8jz pFW78sEde11EmbEdNi4HEB5jFRAU6M0JU+LCsthJBjo5K1/mNuZTN4iwm8RuRt36zEGV AtFGn4Zu57R/CHvRRU08swKIuO3QkE8gUbC+6RFU5bSb7/1lWx/pMhHPJcoJ1LDlgXGy mHH3uThhUQie7glmHqRhXtfsfWOWRiAzK+lG4+bztrkDoClmwipwQ6IXi5x92jwTyC18 DN2MGtBhFRDpsODJf7h6jc7Cl0ihIVl9vOpdQujo7BoSkP6W3nZEZT7GcnXYXcrngln/ lMHA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@comstyle.com header.s=default header.b=dGUmr+yX; 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 a640c23a62f3a-a906109a2a1si184861566b.26.2024.09.14.22.40.12; Sat, 14 Sep 2024 22:40:12 -0700 (PDT) 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=dGUmr+yX; 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 5545868CD5F; Sun, 15 Sep 2024 08:40:09 +0300 (EEST) 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 AA44368CAAD for ; Sun, 15 Sep 2024 08:40:02 +0300 (EEST) Received: from mail.comstyle.com (localhost [127.0.0.1]) by mail.comstyle.com (Postfix) with ESMTP id 4X5xhJ51jJz8PbP for ; Sun, 15 Sep 2024 01:40:00 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=comstyle.com; h=date :from:to:subject:message-id:mime-version:content-type; s= default; bh=6XV9b0WzIX2yX2a9OyvwnCrAJ9ihkdShYGseFSMh6+g=; b=dGUm r+yXtJiId32eH9C1KF7PsUf1kBqmEgzY6kH2rMa/jdX4gETk6tKq9cQLF+NuJgBy 5b1F41Wy8WXJZsA5HIGP3xG+1zR2K+O2SXuywPBLdJCzMeCWWXZi/0ge54pPXPO9 Kj8DwQmhjoA8ZNRWk5W15zkWwsWnXfYWy9s2M8M= 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= ksMeyFeL4xa5GRM/VKEAugV0zZCW61173KXrowGeemjhrR/9e3cuZDR5rC9aQf5/ Zf5iIdVJaemThGLY+brtiiWBlHXuRDOqC0db0FdDo/mWpdt7wCBzh8JRo+lMdseo CrBI4/hRGBP5OPbZxyPP4dPlAWc0rZkYQ6Oc62QEb60= Received: from humpty.home.comstyle.com (unknown [IPv6:2001:470:b050:3:5a1a:61d2:d8a4:7628]) (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 4X5xhJ4Phmz8PbN for ; Sun, 15 Sep 2024 01:40:00 -0400 (EDT) Date: Sun, 15 Sep 2024 01:39:58 -0400 From: Brad Smith To: ffmpeg-devel@ffmpeg.org Message-ID: MIME-Version: 1.0 Content-Disposition: inline Subject: [FFmpeg-devel] [PATCH v3] libavutil/ppc: Make use of getauxval() and elf_aux_info() on ppc 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: J08Kr86ZcfHN libavutil/ppc: Make use of getauxval() and elf_aux_info() on ppc Modern Linux has getauxval() and FreeBSD/OpenBSD ppc have elf_aux_info(). Signed-off-by: Brad Smith --- v2: adjust to build with older glibc. v3: freebsd/ppc requires machine/cpu.h header for feature flags. libavutil/ppc/cpu.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/libavutil/ppc/cpu.c b/libavutil/ppc/cpu.c index 2b13cda662..9381272175 100644 --- a/libavutil/ppc/cpu.c +++ b/libavutil/ppc/cpu.c @@ -20,6 +20,11 @@ #ifdef __APPLE__ #include +#elif HAVE_GETAUXVAL || HAVE_ELF_AUX_INFO +#ifdef __FreeBSD__ +#include +#endif +#include #elif defined(__linux__) #include #include @@ -56,6 +61,26 @@ int ff_get_cpu_flags_ppc(void) if (result == VECTORTYPE_ALTIVEC) return AV_CPU_FLAG_ALTIVEC; return 0; +#elif HAVE_GETAUXVAL || HAVE_ELF_AUX_INFO + int flags = 0; + + unsigned long hwcap = ff_getauxval(AT_HWCAP); +#ifdef PPC_FEATURE2_ARCH_2_07 + unsigned long hwcap2 = ff_getauxval(AT_HWCAP2); +#endif + + if (hwcap & PPC_FEATURE_HAS_ALTIVEC) + flags |= AV_CPU_FLAG_ALTIVEC; +#ifdef PPC_FEATURE_HAS_VSX + if (hwcap & PPC_FEATURE_HAS_VSX) + flags |= AV_CPU_FLAG_VSX; +#endif +#ifdef PPC_FEATURE2_ARCH_2_07 + if (hwcap2 & PPC_FEATURE2_ARCH_2_07) + flags |= AV_CPU_FLAG_POWER8; +#endif + + return flags; #elif defined(__APPLE__) || defined(__NetBSD__) || defined(__OpenBSD__) #if defined(__NetBSD__) || defined(__OpenBSD__) int sels[2] = {CTL_MACHDEP, CPU_ALTIVEC};