Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: "Martin Storsjö" <martin@martin.st>
To: ffmpeg-devel@ffmpeg.org
Subject: Re: [FFmpeg-devel] [PATCH] aarch64: Factorize code for CPU feature detection on Apple platforms
Date: Wed, 10 Apr 2024 10:38:45 +0300 (EEST)
Message-ID: <68a13f38-568a-665b-c4bb-e2117f496d8@martin.st> (raw)
In-Reply-To: <20240312082719.1884075-1-martin@martin.st>

On Tue, 12 Mar 2024, Martin Storsjö wrote:

> ---
> libavutil/aarch64/cpu.c | 25 +++++++++++++------------
> 1 file changed, 13 insertions(+), 12 deletions(-)
>
> diff --git a/libavutil/aarch64/cpu.c b/libavutil/aarch64/cpu.c
> index 7a05391343..196bdaf6b0 100644
> --- a/libavutil/aarch64/cpu.c
> +++ b/libavutil/aarch64/cpu.c
> @@ -45,22 +45,23 @@ static int detect_flags(void)
> #elif defined(__APPLE__) && HAVE_SYSCTLBYNAME
> #include <sys/sysctl.h>
>
> +static int have_feature(const char *feature) {
> +    uint32_t value = 0;
> +    size_t size = sizeof(value);
> +    if (!sysctlbyname(feature, &value, &size, NULL, 0))
> +        return value;
> +    return 0;
> +}
> +
> static int detect_flags(void)
> {
> -    uint32_t value = 0;
> -    size_t size;
>     int flags = 0;
>
> -    size = sizeof(value);
> -    if (!sysctlbyname("hw.optional.arm.FEAT_DotProd", &value, &size, NULL, 0)) {
> -        if (value)
> -            flags |= AV_CPU_FLAG_DOTPROD;
> -    }
> -    size = sizeof(value);
> -    if (!sysctlbyname("hw.optional.arm.FEAT_I8MM", &value, &size, NULL, 0)) {
> -        if (value)
> -            flags |= AV_CPU_FLAG_I8MM;
> -    }
> +    if (have_feature("hw.optional.arm.FEAT_DotProd"))
> +        flags |= AV_CPU_FLAG_DOTPROD;
> +    if (have_feature("hw.optional.arm.FEAT_I8MM"))
> +        flags |= AV_CPU_FLAG_I8MM;
> +
>     return flags;
> }

Will apply.

// Martin
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

      reply	other threads:[~2024-04-10  7:39 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-12  8:27 Martin Storsjö
2024-04-10  7:38 ` Martin Storsjö [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=68a13f38-568a-665b-c4bb-e2117f496d8@martin.st \
    --to=martin@martin.st \
    --cc=ffmpeg-devel@ffmpeg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git