From 32f3c48b655dc42ff45b743f0fda317f2eafeeef Mon Sep 17 00:00:00 2001 From: Sergey Lyubka Date: Mon, 24 Jan 2022 02:20:45 +0000 Subject: [PATCH] Fix FreeBSD build --- Makefile | 4 ++-- mongoose.h | 17 +++++++++++++---- src/arch_unix.h | 1 + src/tls_mbed.h | 3 ++- 4 files changed, 18 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index 8d8e17b0..fa3ad419 100644 --- a/Makefile +++ b/Makefile @@ -18,12 +18,12 @@ CFLAGS ?= $(OPTS) $(WARN) $(INCS) $(DEFS) $(ASAN) -DMG_ENABLE_IPV6=$(IPV6) $(TFL .PHONY: examples test ifeq "$(SSL)" "MBEDTLS" -MBEDTLS ?= /usr +MBEDTLS ?= /usr/local CFLAGS += -DMG_ENABLE_MBEDTLS=1 -I$(MBEDTLS)/include -I/usr/include LDFLAGS ?= -L$(MBEDTLS)/lib -lmbedtls -lmbedcrypto -lmbedx509 endif ifeq "$(SSL)" "OPENSSL" -OPENSSL ?= /usr +OPENSSL ?= /usr/local CFLAGS += -DMG_ENABLE_OPENSSL=1 -I$(OPENSSL)/include LDFLAGS ?= -L$(OPENSSL)/lib -lssl -lcrypto endif diff --git a/mongoose.h b/mongoose.h index 1b136526..917f1a3d 100644 --- a/mongoose.h +++ b/mongoose.h @@ -312,6 +312,7 @@ struct timeval { #include #include #include +#include #include #include #include @@ -590,17 +591,24 @@ bool mg_log_prefix(int ll, const char *file, int line, const char *fname); void mg_log_set(const char *spec); void mg_log_set_callback(void (*fn)(const void *, size_t, void *), void *param); +// Let the compiler always see the log invocation in order to check parameters +// For MG_ENABLE_LOG=0 case, the call will be optimised out, anyway + #if MG_ENABLE_LOG + #define LOG(level, args) \ do { \ if (mg_log_prefix((level), __FILE__, __LINE__, __func__)) mg_log args; \ } while (0) + #else + #define LOG(level, args) \ do { \ (void) level; \ if (0) mg_log args; \ } while (0) + #endif @@ -983,11 +991,12 @@ long mg_tls_recv(struct mg_connection *, void *buf, size_t len); void mg_tls_handshake(struct mg_connection *); + + + + + #if MG_ENABLE_MBEDTLS - - - - #include #include #include diff --git a/src/arch_unix.h b/src/arch_unix.h index 4a9e9a3c..8d64285e 100644 --- a/src/arch_unix.h +++ b/src/arch_unix.h @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include diff --git a/src/tls_mbed.h b/src/tls_mbed.h index 9b02a464..445cf663 100644 --- a/src/tls_mbed.h +++ b/src/tls_mbed.h @@ -1,10 +1,11 @@ #pragma once -#if MG_ENABLE_MBEDTLS +#include "config.h" #include "log.h" #include "url.h" #include "util.h" +#if MG_ENABLE_MBEDTLS #include #include #include