[FFmpeg-devel] [FFmpeg-cvslog] tests/checkasm: Add partial support for wasm

Zhao Zhili quinkblack at foxmail.com
Wed Dec 4 13:48:48 EET 2024



> On Dec 4, 2024, at 17:56, Martin Storsjö <martin at martin.st> wrote:
> 
> On Wed, 4 Dec 2024, Zhao Zhili wrote:
> 
>> ffmpeg | branch: master | Zhao Zhili <zhilizhao at tencent.com> | Wed Nov 20 20:45:35 2024 +0800| [ea3d21c349db5bbfee7840857de81e4b2fc757fa] | committer: Zhao Zhili
>> 
>> tests/checkasm: Add partial support for wasm
>> 
>> WASI mssing signal and siglongjmp support. This patch workaround
>> build error and add simd128 flag. Please note that many tests use
>> large array on stack, so you need to increase the stack size when
>> build checkasm, e.g., --extra-ldflags='-Wl,-z,stack-size=10485760'
>> 
>> Signed-off-by: Zhao Zhili <zhilizhao at tencent.com>
>> 
>>> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=ea3d21c349db5bbfee7840857de81e4b2fc757fa
>> ---
>> 
>> tests/checkasm/checkasm.c |  8 ++++++++
>> tests/checkasm/checkasm.h | 15 +++++++++++++--
>> 2 files changed, 21 insertions(+), 2 deletions(-)
>> 
>> diff --git a/tests/checkasm/checkasm.c b/tests/checkasm/checkasm.c
>> index f30c53cec2..544e3ee9ba 100644
>> --- a/tests/checkasm/checkasm.c
>> +++ b/tests/checkasm/checkasm.c
>> @@ -363,6 +363,8 @@ static const struct {
>> #elif ARCH_LOONGARCH
>>    { "LSX",      "lsx",      AV_CPU_FLAG_LSX },
>>    { "LASX",     "lasx",     AV_CPU_FLAG_LASX },
>> +#elif ARCH_WASM
>> +    { "SIMD128",    "simd128",  AV_CPU_FLAG_SIMD128 },
>> #endif
>>    { NULL }
>> };
>> @@ -770,6 +772,8 @@ static LONG NTAPI signal_handler(EXCEPTION_POINTERS *e) {
>> }
>> #endif
>> #else
>> +
>> +#ifndef _WASI_EMULATED_SIGNAL
>> static void signal_handler(int s);
>> 
>> static const struct sigaction signal_handler_act = {
>> @@ -784,6 +788,8 @@ static void signal_handler(int s) {
>>        checkasm_load_context(s);
>>    }
>> }
>> +#endif // _WASI_EMULATED_SIGNAL
>> +
>> #endif
>> 
>> /* Compares a string with a wildcard pattern. */
>> @@ -933,10 +939,12 @@ int main(int argc, char *argv[])
>>    AddVectoredExceptionHandler(0, signal_handler);
>> #endif
>> #else
>> +#ifndef _WASI_EMULATED_SIGNAL
>>    sigaction(SIGBUS,  &signal_handler_act, NULL);
>>    sigaction(SIGFPE,  &signal_handler_act, NULL);
>>    sigaction(SIGILL,  &signal_handler_act, NULL);
>>    sigaction(SIGSEGV, &signal_handler_act, NULL);
>> +#endif // _WASI_EMULATED_SIGNAL
>> #endif
>> #if HAVE_PRCTL && defined(PR_SET_UNALIGN)
>>    prctl(PR_SET_UNALIGN, PR_UNALIGN_SIGBUS);
>> diff --git a/tests/checkasm/checkasm.h b/tests/checkasm/checkasm.h
>> index 0ba5c3040d..a1bd19c54a 100644
>> --- a/tests/checkasm/checkasm.h
>> +++ b/tests/checkasm/checkasm.h
>> @@ -66,12 +66,23 @@ typedef struct { CONTEXT c; int status; } checkasm_context;
>> #define checkasm_save_context() 0
>> #define checkasm_load_context() do {} while (0)
>> #endif
>> -#else
>> +#else  // _WIN32
>> +
>> +#ifdef _WASI_EMULATED_SIGNAL
> 
> Why the nested #else + #ifdef, why not #elif defined()? I think that would keep the logic slightly less complex.

Should be fixed by
https://ffmpeg.org/pipermail/ffmpeg-devel/2024-December/337041.html

By the way, how to make nested conditional compile readable? The code use nested #if already:

#ifdef _WIN32
#include <windows.h>
#if ARCH_X86_32
#include <setjmp.h>

I remember this patch use nested #else + #ifdef is for easy to comment. Should we use indent like in VLC?

> 
> // Martin
> 
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request at ffmpeg.org with subject "unsubscribe".



More information about the ffmpeg-devel mailing list