diff --git a/.travis.yml b/.travis.yml index 92cdb3d3..2ce83db7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,9 +15,6 @@ matrix: - os: osx compiler: clang script: make mg_prefix - - os: linux - compiler: clang - script: cat /usr/include/mbedtls/net.h ; grep -r mbedtls_net_send /usr/include/mbedtls/ - os: linux compiler: msvc98 script: make vc98 vc2017 diff --git a/Makefile b/Makefile index 268a1b97..ae63a210 100644 --- a/Makefile +++ b/Makefile @@ -48,7 +48,7 @@ fuzz: mongoose.c mongoose.h Makefile test/fuzz.c # make CLANG=/usr/local/opt/llvm\@8/bin/clang ASAN_OPTIONS=detect_leaks=1 test: CFLAGS += -DMG_ENABLE_IPV6=1 -fsanitize=address#,undefined -test: mongoose.c mongoose.h clean Makefile test/unit_test.c +test: mongoose.c mongoose.h Makefile test/unit_test.c $(CLANG) mongoose.c test/unit_test.c $(CFLAGS) -coverage $(LDFLAGS) -g -o unit_test ASAN_OPTIONS=$(ASAN_OPTIONS) $(DEBUGGER) ./unit_test @@ -59,17 +59,17 @@ infer: infer run -- cc test/unit_test.c -c -W -Wall -Werror -Isrc -I. -O2 -DMG_ENABLE_MBEDTLS=1 -DMG_ENABLE_LINES -I/usr/local/Cellar/mbedtls/2.23.0/include -DMG_ENABLE_IPV6=1 -g -o /dev/null #vc98: VCFLAGS += -DMG_ENABLE_IPV6=1 -vc98: clean Makefile mongoose.c mongoose.h test/unit_test.c +vc98: Makefile mongoose.c mongoose.h test/unit_test.c $(VC98) wine cl mongoose.c test/unit_test.c $(VCFLAGS) ws2_32.lib /Fe$@.exe $(VC98) wine $@.exe vc2017: CFLAGS += -DMG_ENABLE_IPV6=1 -vc2017: clean Makefile mongoose.c mongoose.h test/unit_test.c +vc2017: Makefile mongoose.c mongoose.h test/unit_test.c $(VC2017) wine64 cl mongoose.c test/unit_test.c $(VCFLAGS) ws2_32.lib /Fe$@.exe $(VC2017) wine64 $@.exe linux: CFLAGS += -DMG_ENABLE_IPV6=1 -fsanitize=address,undefined -linux: clean Makefile mongoose.c mongoose.h test/unit_test.c +linux: Makefile mongoose.c mongoose.h test/unit_test.c $(GCC) $(CC) mongoose.c test/unit_test.c $(CFLAGS) $(LDFLAGS) -o unit_test_gcc $(GCC) ./unit_test_gcc @@ -85,4 +85,3 @@ mongoose.h: $(HDRS) Makefile clean: EXAMPLE_TARGET = clean clean: ex rm -rf $(PROG) *.o *.dSYM unit_test* ut fuzzer *.gcov *.gcno *.gcda *.obj *.exe *.ilk *.pdb slow-unit* _CL_* infer-out - diff --git a/mongoose.c b/mongoose.c index 1c41ef37..be8fa62f 100644 --- a/mongoose.c +++ b/mongoose.c @@ -2923,13 +2923,17 @@ void mg_timer_poll(unsigned long now_ms) { #include #include -#include -#if MBEDTLS_VERSION_NUMBER > 0x02070000 -#include + +// Different versions have those in different files, so declare here +#ifdef __cplusplus +#define EXTERN_C extern "C" #else -#include +#define EXTERN_C #endif +EXTERN_C int mbedtls_net_recv(void *, unsigned char *, size_t); +EXTERN_C int mbedtls_net_send(void *, const unsigned char *, size_t); + struct mg_tls { char *cafile; // CA certificate path mbedtls_x509_crt ca; // Parsed CA certificate diff --git a/src/tls.c b/src/tls.c index e564bdab..bf1d0992 100644 --- a/src/tls.c +++ b/src/tls.c @@ -9,8 +9,14 @@ #include // Different versions have those in different files, so declare here -int mbedtls_net_recv(void *ctx, unsigned char *buf, size_t len); -int mbedtls_net_send(void *ctx, const unsigned char *buf, size_t len); +#ifdef __cplusplus +#define EXTERN_C extern "C" +#else +#define EXTERN_C +#endif + +EXTERN_C int mbedtls_net_recv(void *, unsigned char *, size_t); +EXTERN_C int mbedtls_net_send(void *, const unsigned char *, size_t); struct mg_tls { char *cafile; // CA certificate path