mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2026-07-09 21:00:49 +02:00
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:
@@ -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 */
|
||||
|
||||
Reference in New Issue
Block a user