From 70d39a2ff9210a69d65f947fc77aa82892758593 Mon Sep 17 00:00:00 2001 From: Archit Gupta Date: Fri, 12 Jun 2026 21:02:20 +0000 Subject: [PATCH] Use slirp_pollfds_fill_socket on libslirp >= 4.9.0 slirp_pollfds_fill and its int-based SlirpAddPollCb callback were deprecated in libslirp 4.9.0 in favour of slirp_pollfds_fill_socket and SlirpAddPollSocketCb, which carry the descriptor as a slirp_os_socket. Building against libslirp >= 4.9.0 therefore emits a -Wdeprecated-declarations warning in vReceiveThread. Guard the poll-fill call and the add-poll callback signature on SLIRP_CHECK_VERSION( 4, 9, 0 ) so modern libslirp uses the socket-based API while older versions keep the existing behaviour. Fixes #1325 --- .../libslirp/MBuffNetifBackendLibslirp.c | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/source/portable/NetworkInterface/libslirp/MBuffNetifBackendLibslirp.c b/source/portable/NetworkInterface/libslirp/MBuffNetifBackendLibslirp.c index d544d2135..4b327eaac 100644 --- a/source/portable/NetworkInterface/libslirp/MBuffNetifBackendLibslirp.c +++ b/source/portable/NetworkInterface/libslirp/MBuffNetifBackendLibslirp.c @@ -574,13 +574,22 @@ static inline int lNativePollEventsToSlirpEvents( int lPosixPollFlags ) return lSlirpPollFlags; } +/* Descriptor type accepted by the add-poll callback. libslirp 4.9.0 switched + * the callback from an int to a slirp_os_socket. */ +#if SLIRP_CHECK_VERSION( 4U, 9U, 0U ) + typedef slirp_os_socket SlirpPollFd_t; +#else + typedef int SlirpPollFd_t; +#endif + /** - * @brief SlirpAddPollCb implementation passed to libslirp during initialization. - * @param [in] fd File descriptor to add to the polling list. + * @brief SlirpAddPollCb / SlirpAddPollSocketCb implementation passed to libslirp + * during initialization. + * @param [in] lFd File descriptor to add to the polling list. * @param [in] lSlirpFlags Flags to be placed in the relevant events field. * @param [in] pvOpaque Opaque pointer to the relevant SlirpBackendContext_t. */ -static int lSlirpAddPollCallback( int lFd, +static int lSlirpAddPollCallback( SlirpPollFd_t lFd, int lSlirpFlags, void * pvOpaque ) { @@ -706,7 +715,11 @@ static THREAD_RETURN THREAD_FUNC_DEF vReceiveThread( void * pvParameters ) vLockSlirpContext( pxCtx ); { pxCtx->nfds = 0; - slirp_pollfds_fill( pxCtx->pxSlirp, &ulPollerTimeoutMs, lSlirpAddPollCallback, pxCtx ); + #if SLIRP_CHECK_VERSION( 4U, 9U, 0U ) + slirp_pollfds_fill_socket( pxCtx->pxSlirp, &ulPollerTimeoutMs, lSlirpAddPollCallback, pxCtx ); + #else + slirp_pollfds_fill( pxCtx->pxSlirp, &ulPollerTimeoutMs, lSlirpAddPollCallback, pxCtx ); + #endif } vUnlockSlirpContext( pxCtx );