Skip to content

Commit de2e0f4

Browse files
committed
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
1 parent da707f2 commit de2e0f4

1 file changed

Lines changed: 17 additions & 6 deletions

File tree

source/portable/NetworkInterface/libslirp/MBuffNetifBackendLibslirp.c

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -575,14 +575,21 @@ static inline int lNativePollEventsToSlirpEvents( int lPosixPollFlags )
575575
}
576576

577577
/**
578-
* @brief SlirpAddPollCb implementation passed to libslirp during initialization.
579-
* @param [in] fd File descriptor to add to the polling list.
578+
* @brief SlirpAddPollCb / SlirpAddPollSocketCb implementation passed to libslirp
579+
* during initialization.
580+
* @param [in] lFd File descriptor to add to the polling list.
580581
* @param [in] lSlirpFlags Flags to be placed in the relevant events field.
581582
* @param [in] pvOpaque Opaque pointer to the relevant SlirpBackendContext_t.
582583
*/
583-
static int lSlirpAddPollCallback( int lFd,
584-
int lSlirpFlags,
585-
void * pvOpaque )
584+
#if SLIRP_CHECK_VERSION( 4U, 9U, 0U )
585+
static int lSlirpAddPollCallback( slirp_os_socket lFd,
586+
int lSlirpFlags,
587+
void * pvOpaque )
588+
#else
589+
static int lSlirpAddPollCallback( int lFd,
590+
int lSlirpFlags,
591+
void * pvOpaque )
592+
#endif
586593
{
587594
SlirpBackendContext_t * pxCtx = ( SlirpBackendContext_t * ) pvOpaque;
588595

@@ -706,7 +713,11 @@ static THREAD_RETURN THREAD_FUNC_DEF vReceiveThread( void * pvParameters )
706713
vLockSlirpContext( pxCtx );
707714
{
708715
pxCtx->nfds = 0;
709-
slirp_pollfds_fill( pxCtx->pxSlirp, &ulPollerTimeoutMs, lSlirpAddPollCallback, pxCtx );
716+
#if SLIRP_CHECK_VERSION( 4U, 9U, 0U )
717+
slirp_pollfds_fill_socket( pxCtx->pxSlirp, &ulPollerTimeoutMs, lSlirpAddPollCallback, pxCtx );
718+
#else
719+
slirp_pollfds_fill( pxCtx->pxSlirp, &ulPollerTimeoutMs, lSlirpAddPollCallback, pxCtx );
720+
#endif
710721
}
711722
vUnlockSlirpContext( pxCtx );
712723

0 commit comments

Comments
 (0)