From 5e27fdf4998fec2e559a36df7edbb8c9e40370ca Mon Sep 17 00:00:00 2001
From: "Ryan C. Gordon" <[EMAIL REDACTED]>
Date: Thu, 19 Mar 2026 10:18:48 -0400
Subject: [PATCH] unix: Clean up netlink/getifaddrs preprocessor logic a
little.
---
src/SDL_net.c | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/src/SDL_net.c b/src/SDL_net.c
index 9051044..7a524f3 100644
--- a/src/SDL_net.c
+++ b/src/SDL_net.c
@@ -182,16 +182,14 @@ static int WindowsPoll(struct pollfd *fds, unsigned int nfds, int timeout)
#if defined(SDL_PLATFORM_LINUX) || defined(SDL_PLATFORM_ANDROID)
#define USE_NETLINK 1
-#endif
-
-#ifdef USE_NETLINK
#include <linux/netlink.h>
#include <linux/rtnetlink.h>
-#else
+#endif
+
#if defined(SDL_PLATFORM_LINUX) || defined(SDL_PLATFORM_ANDROID) || defined(SDL_PLATFORM_APPLE) || defined(SDL_PLATFORM_FREEBSD) || defined(SDL_PLATFORM_OPENBSD) || defined(SDL_PLATFORM_NETBSD)
+#define USE_GETIFADDRS 1
#include <ifaddrs.h>
#endif
-#endif
#define INVALID_SOCKET -1
#define SOCKET_ERROR -1
@@ -490,7 +488,7 @@ static void RefreshInterfaces(void) // WINDOWS VERSION
SDL_free(addrs);
}
-#elif defined(SDL_PLATFORM_LINUX) || defined(SDL_PLATFORM_ANDROID) || defined(SDL_PLATFORM_APPLE) || defined(SDL_PLATFORM_FREEBSD) || defined(SDL_PLATFORM_OPENBSD) || defined(SDL_PLATFORM_NETBSD)
+#elif defined(USE_NETLINK) || defined(USE_GETIFADDRS)
// AF_NETLINK covers Linux (and by extension Android). PF_ROUTE covers the BSDs (and by extension Apple platforms).
// This doesn't cover all Unix platforms that ever existed, but this hits just about everything that is still being maintained seriously.