Files
Sergio Ammirata e428a6d524 fix(build): force _WIN32_WINNT>=0x0600 on Windows
librist unconditionally calls WSAPoll and uses inet_pton/inet_ntop on
Windows. mingw-w64's <winsock2.h> and <ws2tcpip.h> only declare those
symbols (plus POLLIN/POLLOUT/POLLRDNORM/POLLRDBAND/POLLPRI/POLLHUP/
struct pollfd) under _WIN32_WINNT >= 0x0600 (Vista).

Downstream consumers that pin a lower baseline break the librist build
without any librist source change: VLC 3.0's contrib toolchain, for
example, passes -D_WIN32_WINNT=0x0502 -DWINVER=0x0502 after librist's
own meson-supplied -D_WIN32_WINNT=0x0600, and the later definition
wins, leaving every polling/inet_* symbol undeclared.

Bump _WIN32_WINNT to at least 0x0600 at the top of every translation
unit that pulls in <winsock2.h>, <windows.h> or <ws2tcpip.h>, so the
first system header to be processed sees the Vista baseline and the
include guards do not short-circuit later consumers:

  include/librist/udpsocket.h   (public header, defines EVSOCKET_EV_READ POLLIN)
  src/libevsocket.c             (uses WSAPoll via contrib/poll_win.c)
  contrib/pthread-shim.h        (pulled in via rist-private.h)
  contrib/socket-shim.h         (pulled in via rist-private.h)
  contrib/endian-shim.h         (ntohs/htonl helpers)
  contrib/time-shim.h           (gettimeofday/clock helpers)

The block is a no-op when the caller already targets Vista or newer.
This mirrors the pattern VLC uses in its own modules/audio_output/
wasapi.c, modules/audio_output/mmdevice.c and modules/video_output/
win32/direct3d11.c to selectively target a higher Windows minimum
than the project-wide baseline.

librist already requires Vista+ at runtime (no select-based fallback
for WSAPoll); this change only surfaces that requirement at build
time when an XP-era baseline is forced by the consumer.

Verified by cross-compiling with x86_64-w64-mingw32-gcc 15.2.0 and
CFLAGS=-D_WIN32_WINNT=0x0502 (VLC 3.0 contrib baseline): build
produces a clean librist.dll with zero compile errors. Without this
patch the same command fails with 'POLLIN undeclared' in udpsocket.h
and 'implicit declaration of inet_pton/inet_ntop' in udp.c and
rist-common.c, matching the VLC MR CI output.
2026-04-18 05:03:14 -04:00
..