Skip to content

Commit 098759d

Browse files
etrclaude
andcommitted
Fix CI: gate POSIX struct iovec asserts on !_WIN32
MSYS2/mingw does not ship <sys/uio.h>, so the layout-pinning asserts that compare httpserver::iovec_entry against POSIX struct iovec must be gated. The MHD_IoVec asserts stay unconditional — that's the type the dispatch path actually casts to, and libmicrohttpd ships its own portable MHD_IoVec definition. Files: - src/iovec_response.cpp: wrap <sys/uio.h> include and the four POSIX struct iovec asserts (size/base/len/alignof) in #ifndef _WIN32. - src/details/body.cpp: same — body.cpp duplicates the iovec_response.cpp asserts during the M2 transition. - src/httpserver/details/body.hpp: drop <sys/uio.h> include outright; body.hpp uses iovec_entry (the portable replacement) and MHD_IoVec but never references POSIX struct iovec. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent c05e355 commit 098759d

3 files changed

Lines changed: 24 additions & 10 deletions

File tree

src/details/body.cpp

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,10 @@
2424
#include <microhttpd.h>
2525
#include <sys/stat.h>
2626
#include <sys/types.h>
27-
#include <sys/uio.h>
2827
#include <unistd.h>
28+
#ifndef _WIN32
29+
#include <sys/uio.h> // POSIX struct iovec — used for layout-pin asserts
30+
#endif
2931

3032
#include <cstddef>
3133
#include <cstdint>
@@ -47,7 +49,12 @@ namespace detail {
4749
//
4850
// LIBHTTPSERVER_TODO_TASK013: drop the originals from iovec_response.cpp
4951
// when iovec_response is removed.
52+
//
53+
// The POSIX `struct iovec` asserts are gated on !_WIN32 (no <sys/uio.h> on
54+
// MSYS2/mingw); the MHD_IoVec asserts run everywhere because that's the
55+
// type the dispatch path actually casts to.
5056
// ---------------------------------------------------------------------------
57+
#ifndef _WIN32
5158
static_assert(sizeof(::httpserver::iovec_entry) == sizeof(struct iovec),
5259
"iovec_entry size must match POSIX struct iovec — divergent platform; "
5360
"implement memcpy fallback (see TASK-004)");
@@ -57,6 +64,10 @@ static_assert(offsetof(::httpserver::iovec_entry, base) ==
5764
static_assert(offsetof(::httpserver::iovec_entry, len) ==
5865
offsetof(struct iovec, iov_len),
5966
"iovec_entry::len offset must match struct iovec::iov_len");
67+
static_assert(alignof(::httpserver::iovec_entry) == alignof(struct iovec),
68+
"iovec_entry alignment must match POSIX struct iovec — divergent platform; "
69+
"implement memcpy fallback (see TASK-004)");
70+
#endif // !_WIN32
6071

6172
static_assert(sizeof(::httpserver::iovec_entry) == sizeof(MHD_IoVec),
6273
"iovec_entry size must match libmicrohttpd MHD_IoVec — MHD layout drift");
@@ -66,10 +77,6 @@ static_assert(offsetof(::httpserver::iovec_entry, base) ==
6677
static_assert(offsetof(::httpserver::iovec_entry, len) ==
6778
offsetof(MHD_IoVec, iov_len),
6879
"iovec_entry::len offset must match MHD_IoVec::iov_len");
69-
70-
static_assert(alignof(::httpserver::iovec_entry) == alignof(struct iovec),
71-
"iovec_entry alignment must match POSIX struct iovec — divergent platform; "
72-
"implement memcpy fallback (see TASK-004)");
7380
static_assert(alignof(::httpserver::iovec_entry) == alignof(MHD_IoVec),
7481
"iovec_entry alignment must match MHD_IoVec — MHD layout drift");
7582

src/httpserver/details/body.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737

3838
#include <microhttpd.h>
3939
#include <sys/types.h> // ssize_t
40-
#include <sys/uio.h> // private header may include POSIX scatter/gather
4140

4241
#include <cassert>
4342
#include <cstddef>

src/iovec_response.cpp

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@
2121
#include "httpserver/iovec_response.hpp"
2222

2323
#include <microhttpd.h>
24-
#include <sys/uio.h>
24+
#ifndef _WIN32
25+
#include <sys/uio.h> // POSIX struct iovec — used for layout-pin asserts
26+
#endif
2527

2628
#include <cstddef>
2729
#include <limits>
@@ -52,7 +54,12 @@ namespace httpserver {
5254
// asserts are the gate — a build failure on the divergent platform is
5355
// the desired outcome (loud, immediate, with the assert string naming
5456
// what diverged).
57+
//
58+
// The POSIX `struct iovec` asserts are gated on !_WIN32: MSYS2/mingw does
59+
// not ship <sys/uio.h>. The MHD_IoVec asserts are unconditional — that's
60+
// the type the dispatch path actually casts to.
5561
// ---------------------------------------------------------------------------
62+
#ifndef _WIN32
5663
static_assert(sizeof(::httpserver::iovec_entry) == sizeof(struct iovec),
5764
"iovec_entry size must match POSIX struct iovec — divergent platform; "
5865
"implement memcpy fallback (see TASK-004)");
@@ -62,6 +69,10 @@ static_assert(offsetof(::httpserver::iovec_entry, base) ==
6269
static_assert(offsetof(::httpserver::iovec_entry, len) ==
6370
offsetof(struct iovec, iov_len),
6471
"iovec_entry::len offset must match struct iovec::iov_len");
72+
static_assert(alignof(::httpserver::iovec_entry) == alignof(struct iovec),
73+
"iovec_entry alignment must match POSIX struct iovec — divergent platform; "
74+
"implement memcpy fallback (see TASK-004)");
75+
#endif // !_WIN32
6576

6677
static_assert(sizeof(::httpserver::iovec_entry) == sizeof(MHD_IoVec),
6778
"iovec_entry size must match libmicrohttpd MHD_IoVec — MHD layout drift");
@@ -75,9 +86,6 @@ static_assert(offsetof(::httpserver::iovec_entry, len) ==
7586
// Alignment pinning: ensures the reinterpret_cast array stride is safe on
7687
// architectures that trap on misaligned loads (SPARC, some ARM configs).
7788
// CWE-704: without alignof equality the cast is UB even when size/offset match.
78-
static_assert(alignof(::httpserver::iovec_entry) == alignof(struct iovec),
79-
"iovec_entry alignment must match POSIX struct iovec — divergent platform; "
80-
"implement memcpy fallback (see TASK-004)");
8189
static_assert(alignof(::httpserver::iovec_entry) == alignof(MHD_IoVec),
8290
"iovec_entry alignment must match MHD_IoVec — MHD layout drift");
8391

0 commit comments

Comments
 (0)