-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
For every variadic function, add a va_list function to the public api #10907
Conversation
My initial reaction is that it adds a bunch of entry points to the API and doesn't actually reduce or simplify much code, it just moves the complexity around. In addition, SDL_SetError() is now slightly slower, which is probably okay, but not a great selling point. @icculus might be super happy about it though, so I'll defer to him. :) |
0c0596a
to
3b89f27
Compare
I see the contrary on my system (which I don't understand). #include <SDL3/SDL.h>
#include <SDL3/SDL_main.h>
int main(int argc, char *argv[]) {
Uint32 i;
for (i = 0; i < 10000000; i++) {
SDL_SetError("Time me %" SDL_PRIu32, i);
}
return 0;
} and comparing times of SDL3 of current main and this pr branch, I see faster times on this pr branch. I tested with SDL3 built in release mode, and I still see the difference: 333 vs 712ms |
3b89f27
to
4987f5a
Compare
I think pass on this for now. |
For what it's worth, the MorphOS version of SDL2 provides similar functions to the ones in this PR, which suggests it's neccessary on some platforms. https://github.com/BeWorld2018/SDL/blob/SDL-2.30.7-release/src/SDL_error.c#L63 |
I added SDL_SetErrorV() in a567786. All the logging functions can be implemented on top of SDL_LogMessageV(), so I don't think they're necessary. |
By providing these
va_list
alternatives,SDL_dynapi.c
can be simplified.It should also help #9580.
What changed:
SDL_dynapi_proc.h now uses 3 macros:
SDL_DYNAPI_PROC
: behavior does not changeSDL_DYNAPI_VPROC
: variadic function returning somethingSDL_DYNAPI_VOID_VPROC
: variadic function returning voidThe
*_VPROC
macros accept 2 additional arguments:forwardfn
andlast_arg
. This is theva_list ap
function to which it should forward its arguments. Thelast_arg
is used as 2nd argument tova_start
.I simply appended a
V
to theva_list
alternatives.Homework for slouken and icculus:
V
declarations to the bottom)