Description
The discussion in free-audio/clap#448 gave me the idea of marking real-time functions with a macro, say CLAP_REALTIME
, rather than marking them as real-time in a comment.
By default, CLAP_REALTIME
would be empty and do nothing (besides being documentation), but when compiled with Clang's new RealtimeSanitizer enabled in C or C++, it could provide runtime checking of CLAP API functions marked as real-time:
#if defined(__has_feature) && __has_feature(realtime_sanitizer)
# define CLAP_REALTIME [[clang::nonblocking]]
#else
# define CLAP_REALTIME
#endif
At least that's what I hoped we could do, but unfortunately it appears unlikely that I was wrong, it actually is possible to use on function pointers.[[clang::nonblocking]]
can be applied to function pointers like those the CLAP API uses, though I haven't confirmed this yet.
Fortunately it should be possible to apply the RealtimeSanitizer here since this library uses regular functions instead of function pointers. clap-helpers is probably more fitting for this sort of thing anyway given the focus on enforcing correctness through the use of checking levels and misbehavior handlers. Putting them in the CLAP API will allow C23 programs to benefit from RtSan too.
Does this sound like a good idea?