From 5b372917ced44b7bcbb635b48e76e5a947d554bc Mon Sep 17 00:00:00 2001 From: Stefan Reinauer Date: Sat, 30 May 2026 19:55:38 -0700 Subject: [PATCH] slirp: add Unix libc compatibility fallbacks Provide container_of when the bundled SLIRP code needs it, and avoid redeclaring the libc index function on Unix hosts that expose it. --- slirp/slirp.h | 4 ++++ slirp/slirp_config.h | 3 +++ 2 files changed, 7 insertions(+) diff --git a/slirp/slirp.h b/slirp/slirp.h index 5458c69b..255f827a 100644 --- a/slirp/slirp.h +++ b/slirp/slirp.h @@ -81,6 +81,10 @@ typedef int ioctlsockopt_t; # include #endif +#ifndef container_of +#define container_of(address, type, field) ((type *)((char *)(address) - (uintptr_t)(&((type *)0)->field))) +#endif + #ifdef NEED_TYPEDEFS typedef char int8_t; typedef unsigned char u_int8_t; diff --git a/slirp/slirp_config.h b/slirp/slirp_config.h index 0fed9bc6..794b7683 100644 --- a/slirp/slirp_config.h +++ b/slirp/slirp_config.h @@ -92,6 +92,9 @@ /* Define if you have index() */ #undef HAVE_INDEX +#ifndef _WIN32 +#define HAVE_INDEX +#endif /* Define if you have bcmp() */ #undef HAVE_BCMP -- 2.47.3