examples/benchmark/dtls_bench: build a stub on non-POSIX platforms

dtls_bench.c is built whenever DTLS and the example servers are enabled,
including the cross-mingw-all-crypto multi-test scenario, which cross-
compiles for Windows. It directly includes POSIX-only headers
(<sys/socket.h>, <arpa/inet.h>, <netdb.h>, <net/if.h>) that mingw does
not ship, so the build failed there.

Gate the networking includes and the whole benchmark body behind a
DTLS_BENCH_ENABLED check (WOLFSSL_DTLS, not USE_WINDOWS_API, not
WOLFSSL_NO_SOCK). When the platform lacks POSIX BSD sockets, compile a
small stub main() that reports the tool is unsupported, so the source
tree still builds.
This commit is contained in:
Juliusz Sosinowicz
2026-06-05 21:52:51 +00:00
parent c815d98ef4
commit d2c9f53ef6
+23 -1
View File
@@ -52,12 +52,23 @@
#include <wolfssl/wolfcrypt/settings.h>
#include <wolfssl/ssl.h>
#include <stdio.h>
/* Needs DTLS and POSIX BSD sockets; build a stub main() elsewhere
* (e.g. Windows/mingw, which lacks <sys/socket.h> et al.). */
#if defined(WOLFSSL_DTLS) && !defined(USE_WINDOWS_API) && \
!defined(WOLFSSL_NO_SOCK)
#define DTLS_BENCH_ENABLED
#endif
#ifdef DTLS_BENCH_ENABLED
#include <wolfssl/error-ssl.h>
#define USE_CERT_BUFFERS_2048
#include <wolfssl/certs_test.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
@@ -764,3 +775,14 @@ int main(int argc, char** argv)
}
return c.isServer ? dtls_server(&c) : dtls_client(&c);
}
#else /* DTLS_BENCH_ENABLED */
int main(void)
{
printf("dtls_bench not supported in this build "
"(requires DTLS and POSIX BSD sockets)\n");
return 0;
}
#endif /* DTLS_BENCH_ENABLED */