1
0
mirror of https://git.ffmpeg.org/ffmpeg.git synced 2026-10-24 02:09:03 +03:00

swscale/jit: Fix getting MAP_ANONYMOUS defined on older glibc

This file attempts to define _DEFAULT_SOURCE and similar macros
to affect the system headers regarding what APIs they expose.

However, as this file includes libavutil/error.h before defining
the _*_SOURCE macros, we may end up including system headers that
end up initializing which features are exposed, before we set our
defines (before including <sys/mman.h>).

This is not an issue with glibc 2.37 and newer, since those versions
stopped looking for defines like _DEFAULT_SOURCE for exposing
MAP_ANONYMOUS (see [1]). This wasn't an issue before these functions
were split out to a separate file in
4d9be5f57c either, as these defines
used to be set at the top of libswscale/utils.c, before including other
headers than config.h.

[1] https://sourceware.org/git/?p=glibc.git;a=commit;h=954b8f38958de72c4712088735eb175118f17b51
This commit is contained in:
Martin Storsjö
2026-09-07 11:12:49 +03:00
parent 1de77bb898
commit 35b7df64a0

View File

@@ -21,10 +21,6 @@
#include "config.h"
#include "libavutil/error.h"
#include "jit.h"
#if HAVE_MMAP && HAVE_MPROTECT
# define _DEFAULT_SOURCE
# define _SVID_SOURCE // needed for MAP_ANONYMOUS
@@ -35,6 +31,10 @@
# endif
#endif
#include "libavutil/error.h"
#include "jit.h"
#if HAVE_MMAP && HAVE_MPROTECT && defined(MAP_ANONYMOUS)
void *ff_sws_jit_alloc(size_t size)