From: Niklas Haas <g...@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-requ...@ffmpeg.org with subject "unsubscribe".