Skip to content

Use slirp_pollfds_fill_socket on libslirp >= 4.9.0#1346

Open
archigup wants to merge 1 commit into
FreeRTOS:mainfrom
archigup:fix/libslirp-pollfds-fill-socket-deprecation
Open

Use slirp_pollfds_fill_socket on libslirp >= 4.9.0#1346
archigup wants to merge 1 commit into
FreeRTOS:mainfrom
archigup:fix/libslirp-pollfds-fill-socket-deprecation

Conversation

@archigup

Copy link
Copy Markdown
Member

Description

slirp_pollfds_fill() and its int-based SlirpAddPollCb callback were deprecated in libslirp 4.9.0 (2025-01-30) in favour of slirp_pollfds_fill_socket() and SlirpAddPollSocketCb. The new API carries the descriptor as a slirp_os_socket — an int on POSIX, but a pointer-wide SOCKET on Win64 — which is why libslirp introduced it (the old int callback truncates socket handles on Windows).

Building MBuffNetifBackendLibslirp.c against libslirp >= 4.9.0 therefore produces:

MBuffNetifBackendLibslirp.c: In function 'vReceiveThread':
MBuffNetifBackendLibslirp.c:709:13: warning: 'slirp_pollfds_fill' is deprecated [-Wdeprecated-declarations]

This change guards the poll-fill call and the add-poll callback signature on SLIRP_CHECK_VERSION( 4U, 9U, 0U ) (matching the version-guard style already used throughout this file), so:

  • libslirp >= 4.9.0 uses slirp_pollfds_fill_socket() with a slirp_os_socket callback (no warning, correct on Win64),
  • libslirp < 4.9.0 keeps the existing slirp_pollfds_fill() path unchanged.

The callback body is unchanged — it stores the descriptor into struct pollfd.fd (already a SOCKET inside WSAPOLLFD on Windows), so no truncation occurs on either platform.

Fixes #1325

Test Steps

Compiled MBuffNetifBackendLibslirp.c against real libslirp 4.9.3 headers and an emulated 4.8.0 header set:

  • Before (4.9.3): 1 deprecation warning at the slirp_pollfds_fill call.
  • After (4.9.3): compiles clean with -Werror=deprecated-declarations; 0 deprecation warnings. Preprocessor selects slirp_pollfds_fill_socket + the slirp_os_socket callback.
  • After (emulated 4.8.0): preprocessor selects the legacy slirp_pollfds_fill + int callback and compiles successfully, confirming the #else path is preserved for older libslirp.

Checklist:

  • I have tested my changes. No regression in existing tests.
  • I have modified and/or added unit-tests to cover the code changes in this Pull Request. (N/A — build-time/conditional-compilation change against a host library; verified by compiling the backend against libslirp >= 4.9.0 and < 4.9.0.)
  • I have updated Long-Term-Support related files if required.
  • I have run the formatting tool on this PR.

Related Issue

#1325

By submitting this pull request, I confirm that my contribution is made under the terms of the MIT license.

@archigup archigup changed the title Use slirp_pollfds_fill_socket on libslirp >= 4.9.0 (fixes #1325) Use slirp_pollfds_fill_socket on libslirp >= 4.9.0 Jun 12, 2026
@archigup archigup force-pushed the fix/libslirp-pollfds-fill-socket-deprecation branch 2 times, most recently from de2e0f4 to fbf4f3e Compare June 12, 2026 21:03
@archigup archigup enabled auto-merge (rebase) June 12, 2026 21:04
@archigup archigup force-pushed the fix/libslirp-pollfds-fill-socket-deprecation branch from fbf4f3e to 5b41b49 Compare June 12, 2026 21:12
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 FreeRTOS#1325
@archigup archigup force-pushed the fix/libslirp-pollfds-fill-socket-deprecation branch from 5b41b49 to 70d39a2 Compare June 12, 2026 21:41
@kstribrnAmzn

Copy link
Copy Markdown
Member

Looks good to me. Maybe sometime in the distant future we can deprecate this check, but I understand keeping it for current users.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Deprecation warning for slirp_pollfds_fill in MBuffNetifBackendLibslirp.c with libslirp >= 4.9.0

3 participants