From patchwork Sun Oct 20 07:44:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brad Smith X-Patchwork-Id: 52405 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:612c:143:b0:48e:c0f8:d0de with SMTP id h3csp2024211vqi; Sun, 20 Oct 2024 05:30:37 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCX/OWeAAaN5rJqRRyr+odIr6wBAAOgY6KFnRLkUSD+kLrZgYXROj2MYUdEswC9iCIm4zz6/F6/lsCByfcMgY96b@gmail.com X-Google-Smtp-Source: AGHT+IGHrIgaspdcws0JR43PI6yyW04CHiQgTn51qFE2Zrowfi2FfvnPW/544IZp3CVn7pwBJAan X-Received: by 2002:a17:907:94c2:b0:a99:f29a:bc9a with SMTP id a640c23a62f3a-a9a69a642c7mr922894366b.7.1729427437208; Sun, 20 Oct 2024 05:30:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1729427437; cv=none; d=google.com; s=arc-20240605; b=F12NGAwkW1NV7D4vxNZdM3guxE+UQczFGPeVuu2L5vnxkpj/OtRszDb8lHpZ6Ojuyb bbUsMhpwUpkehnD/Ntv81K9jinYjDWk0Cg0HgRkMSWxLjkfu+AOmXtbrFLBTNGoYFK4Z IuwNflWOw7DTHFe5HZm78wx8mOOyvIIDrkCqEzmxf/Q8hCpigblYGofoaOn4GQqbnUKX fc74aeK4V9j3hNXjdp4EGDATVpLy1CFGmVi+NKLJ+RZRFCYJyoizC+E13UCSsu1aUdZP L3bOzjcYtsY9UGv+F75wqcdP4mScgHUhvtpwov8Ezap8ZVgn7pxQ+mvA43y5YCM/GEHT GcoQ== 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=KPlpx0f2iPC01203mLa3dwBxO3ICT5sdM3cU+mLnwe0=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=SGAbhG4pGq9BIlNLJj5CStr5nQKmloO0MxjkT7KMTzwiFKJt6gAz4s7fmUpGRlmThV cefd/n70UCR2LLSsVTjQ7oVtU4i+5NuC+M8qH7e3NaOKhYacLIOKr2At2ATJ5GW2AYCD Q8f+YDjZcrxDzuh18ghHNUHTTdVOsaKuEWGraRCAcSfRvgLFns9bkavWJ8SzfcgNFpb4 b/f31FROIw6VMz3Q9NOd9OVTWNYaqzypOCYPdJ4wc619yBh7fyQNACPTPyox3YY7vSMr UARSCW70crlxfhdjGB+uDmnIzYmjdZCOknX39TbPEAkVh9+QRi5KneiuM5Mndrpcm0i/ ht2g==; 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="Z/1QYpKN"; 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-a9a9134dd89si111910566b.696.2024.10.20.05.30.36; Sun, 20 Oct 2024 05:30:37 -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="Z/1QYpKN"; 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 8261A68DB2F; Sun, 20 Oct 2024 15:30:33 +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 1E78968D9DF for ; Sun, 20 Oct 2024 15:30:27 +0300 (EEST) Received: from mail.comstyle.com (localhost [127.0.0.1]) by mail.comstyle.com (Postfix) with ESMTP id 4XWVnG04Ghz8PbP for ; Sun, 20 Oct 2024 03:44:02 -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=imcvxF6zgn6VuGIfNL9dGiKRWWUhus6/98YpMIjcfsk=; b=Z/1Q YpKNcXeGKOS5emN5eHT9Q25InjHuAKC0rR900AFU1tg3yzGjRTnqvpJaJZ7nyg04 86QsS5L0XSDPWYq6Acf2VMB9kT4c6lyOZ3O2Ou+X74j1fS0luyigCF+ile4ARsYr tcQpl+xCxMc3JgJopQr+u6cMOH8xi63UUCVpous= 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= KMJkyeI1jqgqEs8xv0OQLbHIjoMgj5K96791tukUu3NceYKCxgRig+9BmUPa9KMs 9nQI9ipipKWYHIRqcfRgUlEVLyhhOW7DcAoUK7mwNs0h1PcaCQ1O+NzH3H9ULbmQ oT9giQjFSI2fY1l+QbfpNDYU0A59Okl/IXMWF+cOL9I= Received: from humpty.home.comstyle.com (unknown [IPv6:2001:470:b050:3:eb0a:8c1d:643c:e474]) (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 4XWVnF6bN8z8PbN for ; Sun, 20 Oct 2024 03:44:01 -0400 (EDT) Date: Sun, 20 Oct 2024 03:44:00 -0400 From: Brad Smith To: ffmpeg-devel@ffmpeg.org Message-ID: MIME-Version: 1.0 Content-Disposition: inline Subject: [FFmpeg-devel] [PATCH] libavutil/ppc: Include the hardware feature flags like the other archs 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: 03aWYMAa940o libavutil/ppc: Include the hardware feature flags like the other archs Also include the hardware feature flags like the other archs do and clean up the code a bit. Tested on Linux POWER8. Signed-off-by: Brad Smith --- libavutil/ppc/cpu.c | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/libavutil/ppc/cpu.c b/libavutil/ppc/cpu.c index 9381272175..62d495ec1d 100644 --- a/libavutil/ppc/cpu.c +++ b/libavutil/ppc/cpu.c @@ -46,6 +46,17 @@ #include "libavutil/cpu.h" #include "libavutil/cpu_internal.h" +#ifndef AT_HWCAP +#define AT_HWCAP 16 +#endif +#ifndef AT_HWCAP2 +#define AT_HWCAP2 26 +#endif + +#define HWCAP_PPC_VSX (1 << 7) +#define HWCAP_PPC_ALTIVEC (1 << 28) +#define HWCAP2_PPC_ARCH_2_07 (1 << 31) + /** * This function MAY rely on signal() or fork() in order to make sure AltiVec * is present. @@ -65,20 +76,14 @@ int ff_get_cpu_flags_ppc(void) 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) + if (hwcap & HWCAP_PPC_ALTIVEC) flags |= AV_CPU_FLAG_ALTIVEC; -#ifdef PPC_FEATURE_HAS_VSX - if (hwcap & PPC_FEATURE_HAS_VSX) + if (hwcap & HWCAP_PPC_VSX) flags |= AV_CPU_FLAG_VSX; -#endif -#ifdef PPC_FEATURE2_ARCH_2_07 - if (hwcap2 & PPC_FEATURE2_ARCH_2_07) + if (hwcap2 & HWCAP2_PPC_ARCH_2_07) flags |= AV_CPU_FLAG_POWER8; -#endif return flags; #elif defined(__APPLE__) || defined(__NetBSD__) || defined(__OpenBSD__) @@ -112,23 +117,17 @@ int ff_get_cpu_flags_ppc(void) if (buf[i] == AT_NULL) goto out; if (buf[i] == AT_HWCAP) { - if (buf[i + 1] & PPC_FEATURE_HAS_ALTIVEC) + if (buf[i + 1] & HWCAP_PPC_ALTIVEC) ret = AV_CPU_FLAG_ALTIVEC; -#ifdef PPC_FEATURE_HAS_VSX - if (buf[i + 1] & PPC_FEATURE_HAS_VSX) + if (buf[i + 1] & HWCAP_PPC_VSX) ret |= AV_CPU_FLAG_VSX; -#endif if (ret & AV_CPU_FLAG_VSX) av_assert0(ret & AV_CPU_FLAG_ALTIVEC); } -#ifdef AT_HWCAP2 /* not introduced until glibc 2.18 */ else if (buf[i] == AT_HWCAP2) { -#ifdef PPC_FEATURE2_ARCH_2_07 - if (buf[i + 1] & PPC_FEATURE2_ARCH_2_07) + if (buf[i + 1] & HWCAP2_PPC_ARCH_2_07) ret |= AV_CPU_FLAG_POWER8; -#endif } -#endif /* AT_HWCAP2 */ } }