This is an automated email from the git hooks/post-receive script. Git pushed a commit to branch master in repository ffmpeg.
commit cf7e2b67735d500768b06c6f411826bfef923b0f Author: Andreas Rheinhardt <[email protected]> AuthorDate: Sun Dec 7 10:38:05 2025 +0100 Commit: Andreas Rheinhardt <[email protected]> CommitDate: Sun Jan 4 15:49:30 2026 +0100 tests/checkasm: Add support for using opaques to decide whether to test This is in preparation for adding checkasm support for av_crc(), which will always call the same function, but uses different CRC tables to distinguish different implementations. This reuses checkasm_check_func() for this; one could also add a new function or use unions. This would allow to avoid casting const away in the crc test to be added. It would also allow to avoid converting function pointers to void* (which ISO C does not allow). Signed-off-by: Andreas Rheinhardt <[email protected]> --- tests/checkasm/checkasm.h | 51 ++++++++++++++++++++++++++++------------------- 1 file changed, 30 insertions(+), 21 deletions(-) diff --git a/tests/checkasm/checkasm.h b/tests/checkasm/checkasm.h index a54231dd0d..7d4fc086c6 100644 --- a/tests/checkasm/checkasm.h +++ b/tests/checkasm/checkasm.h @@ -203,6 +203,7 @@ extern uint64_t bench_runs; /* Decide whether or not the specified function needs to be tested */ #define check_func(func, ...) (checkasm_save_context(), func_ref = checkasm_check_func((func_new = func), __VA_ARGS__)) +#define check_key(key, ...) (checkasm_save_context(), checkasm_check_func(key, __VA_ARGS__)) /* Declare the function prototype. The first argument is the return value, the remaining * arguments are the function parameters. Naming parameters is optional. */ @@ -218,10 +219,15 @@ extern uint64_t bench_runs; /* Call the reference function */ #define call_ref(...)\ + checkasm_call((func_type *)func_ref, __VA_ARGS__) + +#define checkasm_call(func, ...) \ (checkasm_set_signal_handler_state(1),\ - ((func_type *)func_ref)(__VA_ARGS__));\ + (func)(__VA_ARGS__));\ checkasm_set_signal_handler_state(0) +#define call_new(...) checkasm_call_checked(((func_type *)func_new), __VA_ARGS__) + #if ARCH_X86 && HAVE_X86ASM /* Verifies that clobbered callee-saved registers are properly saved and restored * and that either no MMX registers are touched or emms is issued */ @@ -253,20 +259,21 @@ void checkasm_stack_clobber(uint64_t clobber, ...); ((cpu_flags) & av_get_cpu_flags()) ? (void *)checkasm_checked_call_emms : \ (void *)checkasm_checked_call; #define CLOB (UINT64_C(0xdeadbeefdeadbeef)) -#define call_new(...) (checkasm_set_signal_handler_state(1),\ - checkasm_stack_clobber(CLOB,CLOB,CLOB,CLOB,CLOB,CLOB,CLOB,CLOB,CLOB,CLOB,CLOB,\ - CLOB,CLOB,CLOB,CLOB,CLOB,CLOB,CLOB,CLOB,CLOB,CLOB),\ - checked_call(func_new, 0, 0, 0, 0, 0, __VA_ARGS__));\ - checkasm_set_signal_handler_state(0) +#define checkasm_call_checked(func, ...) \ + (checkasm_set_signal_handler_state(1),\ + checkasm_stack_clobber(CLOB,CLOB,CLOB,CLOB,CLOB,CLOB,CLOB,CLOB,CLOB,CLOB,CLOB,\ + CLOB,CLOB,CLOB,CLOB,CLOB,CLOB,CLOB,CLOB,CLOB,CLOB),\ + checked_call((func), 0, 0, 0, 0, 0, __VA_ARGS__));\ + checkasm_set_signal_handler_state(0) #elif ARCH_X86_32 #define declare_new(ret, ...) ret (*checked_call)(void *, __VA_ARGS__) = (void *)checkasm_checked_call; #define declare_new_float(ret, ...) ret (*checked_call)(void *, __VA_ARGS__) = (void *)checkasm_checked_call_float; #define declare_new_emms(cpu_flags, ret, ...) ret (*checked_call)(void *, __VA_ARGS__) = \ ((cpu_flags) & av_get_cpu_flags()) ? (void *)checkasm_checked_call_emms : \ (void *)checkasm_checked_call; -#define call_new(...)\ +#define checkasm_call_checked(func, ...)\ (checkasm_set_signal_handler_state(1),\ - checked_call(func_new, __VA_ARGS__));\ + checked_call((func), __VA_ARGS__));\ checkasm_set_signal_handler_state(0) #endif #elif ARCH_ARM && HAVE_ARMV5TE_EXTERNAL @@ -279,9 +286,9 @@ extern void (*checkasm_checked_call)(void *func, int dummy, ...); #define declare_new(ret, ...) ret (*checked_call)(void *, int dummy, __VA_ARGS__, \ int, int, int, int, int, int, int, int, \ int, int, int, int, int, int, int) = (void *)checkasm_checked_call; -#define call_new(...) \ +#define checkasm_call_checked(func, ...) \ (checkasm_set_signal_handler_state(1),\ - checked_call(func_new, 0, __VA_ARGS__, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 0, 0, 0));\ + checked_call((func), 0, __VA_ARGS__, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 0, 0, 0));\ checkasm_set_signal_handler_state(0) #elif ARCH_AARCH64 && !defined(__APPLE__) void checkasm_stack_clobber(uint64_t clobber, ...); @@ -291,10 +298,10 @@ void checkasm_checked_call(void *func, ...); int, int, int, int, int, int, int)\ = (void *)checkasm_checked_call; #define CLOB (UINT64_C(0xdeadbeefdeadbeef)) -#define call_new(...) (checkasm_set_signal_handler_state(1),\ +#define checkasm_call_checked(func, ...) (checkasm_set_signal_handler_state(1),\ checkasm_stack_clobber(CLOB,CLOB,CLOB,CLOB,CLOB,CLOB,CLOB,CLOB,CLOB,CLOB,CLOB,CLOB,\ CLOB,CLOB,CLOB,CLOB,CLOB,CLOB,CLOB,CLOB,CLOB,CLOB,CLOB),\ - checked_call(func_new, 0, 0, 0, 0, 0, 0, 0, __VA_ARGS__,\ + checked_call((func), 0, 0, 0, 0, 0, 0, 0, __VA_ARGS__,\ 7, 6, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0));\ checkasm_set_signal_handler_state(0) #elif ARCH_RISCV @@ -304,15 +311,15 @@ void *checkasm_get_wrapper(void); #if HAVE_RV && (__riscv_xlen == 64) && defined (__riscv_d) #define declare_new(ret, ...) \ ret (*checked_call)(__VA_ARGS__) = checkasm_get_wrapper(); -#define call_new(...) \ +#define checkasm_call_checked(func, ...) \ (checkasm_set_signal_handler_state(1),\ - checkasm_set_function(func_new), checked_call(__VA_ARGS__));\ + checkasm_set_function(func), checked_call(__VA_ARGS__));\ checkasm_set_signal_handler_state(0) #else #define declare_new(ret, ...) -#define call_new(...)\ +#define checkasm_call_checked(func, ...)\ (checkasm_set_signal_handler_state(1),\ - ((func_type *)func_new)(__VA_ARGS__));\ + (func)(__VA_ARGS__));\ checkasm_set_signal_handler_state(0) #endif #else @@ -320,9 +327,9 @@ void *checkasm_get_wrapper(void); #define declare_new_float(ret, ...) #define declare_new_emms(cpu_flags, ret, ...) /* Call the function */ -#define call_new(...)\ +#define checkasm_call_checked(func, ...)\ (checkasm_set_signal_handler_state(1),\ - ((func_type *)func_new)(__VA_ARGS__));\ + (func)(__VA_ARGS__));\ checkasm_set_signal_handler_state(0) #endif @@ -377,12 +384,12 @@ typedef struct CheckasmPerf { } while (0) /* Benchmark the function */ -#define bench_new(...)\ +#define bench(func, ...)\ do {\ if (checkasm_bench_func()) {\ struct CheckasmPerf *perf = checkasm_get_perf_context();\ av_unused const int sysfd = perf->sysfd;\ - func_type *tfunc = func_new;\ + func_type *tfunc = func;\ uint64_t tsum = 0;\ uint64_t ti, tcount = 0;\ uint64_t t = 0; \ @@ -405,11 +412,13 @@ typedef struct CheckasmPerf { }\ } while (0) #else -#define bench_new(...) while(0) +#define bench(func, ...) while(0) #define PERF_START(t) while(0) #define PERF_STOP(t) while(0) #endif +#define bench_new(...) bench(func_new, __VA_ARGS__) + #define BUF_RECT(type, name, w, h) \ LOCAL_ALIGNED_32(type, name##_buf, [((h)+32)*(FFALIGN(w,64)+64) + 64]); \ av_unused ptrdiff_t name##_stride = sizeof(type)*(FFALIGN(w,64)+64); \ _______________________________________________ ffmpeg-cvslog mailing list -- [email protected] To unsubscribe send an email to [email protected]
