Commit 6eb7510072 for ffmpeg
commit 6eb75100726e1a580d93112ad7c4235455178959
Author: Niklas Haas <git@haasn.dev>
Date: Thu Oct 22 19:59:09 2026 +0200
swscale/uops_macros_gen: use a per-backend header include guard
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Niklas Haas <git@haasn.dev>
diff --git a/libswscale/uops_macros_gen.c b/libswscale/uops_macros_gen.c
index 7927de4f5c..6985451168 100644
--- a/libswscale/uops_macros_gen.c
+++ b/libswscale/uops_macros_gen.c
@@ -222,6 +222,7 @@ enum {
typedef struct Backend {
const char *name;
+ const char *guard; /* include guard for the generated C header */
SwsUOpFlags flags[2]; /* all flag combinations used by the backend */
} Backend;
@@ -229,6 +230,7 @@ static const Backend backends[] = {
{
/* Currently also covers all uops used by the x86 backend */
.name = "c",
+ .guard = "SWSCALE_UOPS_MACROS_H",
.flags = {
COMMON_FLAGS,
COMMON_FLAGS | SWS_UOP_FLAG_PSHUFB | SWS_UOP_FLAG_FMA,
@@ -387,7 +389,8 @@ fail:
* Returns 0 or a negative error code. On success, an allocated string is
* returned via `out_str`, and must be av_free()'d by the caller.
*/
-static int print_macros(struct AVTreeNode *root, char **out_str)
+static int print_macros(struct AVTreeNode *root, const Backend *backend,
+ char **out_str)
{
AVBPrint bprint, *const bp = &bprint;
av_bprint_init(bp, 0, AV_BPRINT_SIZE_UNLIMITED);
@@ -397,10 +400,9 @@ static int print_macros(struct AVTreeNode *root, char **out_str)
" * This file is automatically generated. Do not edit manually.\n"
" * To regenerate, run: make fate-sws-uops-macros GEN=1\n"
" */\n"
-"\n"
-"#ifndef SWSCALE_UOPS_MACROS_H\n"
-"#define SWSCALE_UOPS_MACROS_H\n"
-"\n"
+"\n");
+ av_bprintf(bp, "#ifndef %s\n#define %s\n\n", backend->guard, backend->guard);
+ BPRINT_STR(
"/**\n"
" * Boilerplate helper macros, for template-based backends. These will be\n"
" * instantiated like this, with parameters in struct order:\n"
@@ -429,7 +431,7 @@ static int print_macros(struct AVTreeNode *root, char **out_str)
}
}
- BPRINT_STR("\n#endif /* SWSCALE_UOPS_MACROS_H */");
+ av_bprintf(bp, "\n#endif /* %s */", backend->guard);
return av_bprint_finalize(bp, out_str);
}
@@ -520,7 +522,7 @@ int main(int argc, char **argv)
return ret;
char *macros = NULL;
- ret = print_macros(root, ¯os);
+ ret = print_macros(root, backend, ¯os);
if (ret >= 0)
puts(macros);
av_free(macros);