From c15b6a14578bf6544cad834473d35bf2e38ff3fd Mon Sep 17 00:00:00 2001 From: janusch <33876434+MrNeRF@users.noreply.github.com> Date: Sat, 1 Aug 2026 08:35:01 +0300 Subject: [PATCH] wayland: don't redeclare getresuid/getresgid When HAVE_GETRESUID/HAVE_GETRESGID are not defined, SDL_waylandvideo.c defines static inline fallbacks using the libc names. glibc declares both functions non-static in , so on a toolchain where the feature checks fail while those declarations are still visible the file fails to compile: error: static declaration of 'getresuid' follows non-static declaration Give the fallbacks SDL-private names and call those, so a fallback can never collide with a libc declaration. Also fixes the fallback getresgid() taking uid_t* parameters where it should take gid_t*. --- src/video/wayland/SDL_waylandvideo.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/video/wayland/SDL_waylandvideo.c b/src/video/wayland/SDL_waylandvideo.c index ec1249dc07..6b88ca8416 100644 --- a/src/video/wayland/SDL_waylandvideo.c +++ b/src/video/wayland/SDL_waylandvideo.c @@ -1604,19 +1604,23 @@ static int SDLCALL LibdecorNewInThread(void *data) } #endif -#ifndef HAVE_GETRESUID +#ifdef HAVE_GETRESUID +#define SDL_getresuid getresuid +#else // Non-POSIX, but Linux and some BSDs have it. // To reduce the number of code paths, if getresuid() isn't available at // compile-time, we behave as though it existed but failed at runtime. -static inline int getresuid(uid_t *ruid, uid_t *euid, uid_t *suid) { +static inline int SDL_getresuid(uid_t *ruid, uid_t *euid, uid_t *suid) { errno = ENOSYS; return -1; } #endif -#ifndef HAVE_GETRESGID +#ifdef HAVE_GETRESGID +#define SDL_getresgid getresgid +#else // Same as getresuid() but for the primary group -static inline int getresgid(uid_t *ruid, uid_t *euid, uid_t *suid) { +static inline int SDL_getresgid(gid_t *rgid, gid_t *egid, gid_t *sgid) { errno = ENOSYS; return -1; } @@ -1638,12 +1642,12 @@ bool CanUseGtk(void) // we don't use Linux getauxval() or prctl PR_GET_DUMPABLE, // BSD issetugid(), or similar OS-specific detection - if (getresuid(&ruid, &euid, &suid) != 0) { + if (SDL_getresuid(&ruid, &euid, &suid) != 0) { ruid = suid = getuid(); euid = geteuid(); } - if (getresgid(&rgid, &egid, &sgid) != 0) { + if (SDL_getresgid(&rgid, &egid, &sgid) != 0) { rgid = sgid = getgid(); egid = getegid(); }