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 <unistd.h>, 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*.
This commit is contained in:
janusch
2026-08-01 08:35:01 +03:00
committed by Sam Lantinga
parent ec4bdfd118
commit c15b6a1457

View File

@@ -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();
}