Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: "J. Dekker" <jdek@itanimul.li>
To: ffmpeg-devel@ffmpeg.org
Cc: Niklas Haas <git@haasn.dev>
Subject: [FFmpeg-devel] [PATCH 5/7] avutil/riscv/asm: add helper macro to count varargs
Date: Tue, 13 Aug 2024 16:03:34 +0200
Message-ID: <20240813140338.143045-5-jdek@itanimul.li> (raw)
In-Reply-To: <20240813140338.143045-1-jdek@itanimul.li>

From: Niklas Haas <git@haasn.dev>

(Ab)using nested macros to get the number of arguments passed to a
variadic macro. Useful for stack manipulation.
---
 libavutil/riscv/asm.S | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/libavutil/riscv/asm.S b/libavutil/riscv/asm.S
index 175f2a8672..db190e99ca 100644
--- a/libavutil/riscv/asm.S
+++ b/libavutil/riscv/asm.S
@@ -271,3 +271,20 @@
 #error Unhandled value of XLEN
 #endif
         .endm
+
+        .macro  count_args_inner num, arg, args:vararg
+        .ifb \arg
+        .equ    num_args, \num
+        .else
+        count_args_inner \num + 1, \args
+        .endif
+        .endm
+
+        /**
+         * Helper macro to count the number of arguments to a macro. Assigns
+         * the count to the symbol `num_args`.
+         * @param args arguments to count
+         */
+        .macro  count_args args:vararg
+        count_args_inner 0, \args
+        .endm
-- 
2.45.1

_______________________________________________
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".

  parent reply	other threads:[~2024-08-13 14:04 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-13 14:03 [FFmpeg-devel] [PATCH 1/7] checkasm: add csv/tsv bench output J. Dekker
2024-08-13 14:03 ` [FFmpeg-devel] [PATCH 2/7] checkasm: improve print format J. Dekker
2024-08-13 16:39   ` Lynne via ffmpeg-devel
2024-08-13 14:03 ` [FFmpeg-devel] [PATCH 3/7] checkasm: add wildcompares for test & functions J. Dekker
2024-08-13 14:03 ` [FFmpeg-devel] [PATCH 4/7] avutil/riscv/asm: add stack pushing helpers J. Dekker
2024-08-13 15:51   ` Rémi Denis-Courmont
2024-08-13 16:10     ` epirat07
2024-08-13 16:13       ` Rémi Denis-Courmont
2024-08-13 14:03 ` J. Dekker [this message]
2024-08-13 14:03 ` [FFmpeg-devel] [PATCH 6/7] avutil/riscv/asm: add generic push/pop helpers J. Dekker
2024-08-13 15:55   ` Rémi Denis-Courmont
2024-08-15 12:13     ` Niklas Haas
2024-08-13 14:03 ` [FFmpeg-devel] [PATCH 7/7] avcodec/riscv: add h264 qpel J. Dekker

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=20240813140338.143045-5-jdek@itanimul.li \
    --to=jdek@itanimul.li \
    --cc=ffmpeg-devel@ffmpeg.org \
    --cc=git@haasn.dev \
    /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