mirror of
https://github.com/libretro/RetroArch.git
synced 2026-11-23 00:36:42 -10:00
strdup(), strcasecmp(), fstatat(), O_CLOEXEC, M_PI, sigaltstack() and syscall() all sit behind __USE_XOPEN2K8 or __USE_MISC, so a consumer compiling the library under a stricter feature profile than the default sees none of them. The Debian/Launchpad core packaging passes -D_XOPEN_SOURCE=600, where ten of these translation units reach an implicitly declared function; at -D_POSIX_C_SOURCE=200112L strdup joins them, and an implicit strdup returns int, so the pointer is truncated on LP64 rather than merely warned about. Add retro_posix_source.h, which asks for that profile, and include it first in the files that need it. The guards only raise the profile and ask for what a build passing no feature macros already gets, so no path the library selects changes: every touched object is byte-identical under the default profile. nbio_linux.c defined _GNU_SOURCE after its first include, where it had no effect; retro_posix_source.h replaces it. Verified: all 221 standalone-compilable libretro-common units clean under no macros, _XOPEN_SOURCE 600 and 700, _POSIX_C_SOURCE 200112L and 200809L, and _GNU_SOURCE, with implicit declarations and int-conversion as errors; the fifteen samples suites that link these units build and pass; compile-matrix.sh gives results identical to before the change. Building with -DRETRO_POSIX_SOURCE_CHECK_ORDER turns a late include into an error, and was itself checked both ways.