diff --git a/.gitignore b/.gitignore index e80131a..0bb33df 100644 --- a/.gitignore +++ b/.gitignore @@ -6,4 +6,5 @@ wsjtx2/ .build/ .DS_Store .vscode/ -__pycache__/ \ No newline at end of file +__pycache__/ +*.exe \ No newline at end of file diff --git a/Makefile b/Makefile index 73ec27b..a2fec81 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,7 @@ BUILD_DIR = .build +USE_ASAN = 1 # Set to 1 to enable AddressSanitizer + FT8_SRC = $(wildcard ft8/*.c) FT8_OBJ = $(patsubst %.c,$(BUILD_DIR)/%.o,$(FT8_SRC)) @@ -11,9 +13,14 @@ FFT_OBJ = $(patsubst %.c,$(BUILD_DIR)/%.o,$(FFT_SRC)) TARGETS = gen_ft8 decode_ft8 test_ft8 -CFLAGS = -fsanitize=address -O3 -ggdb3 +CFLAGS = -D_GNU_SOURCE -O3 -ggdb3 CPPFLAGS = -std=c11 -I. -LDFLAGS = -fsanitize=address -lm +LDFLAGS = -lm + +ifeq ($(USE_ASAN), 1) +CFLAGS += -fsanitize=address +LDFLAGS += -fsanitize=address +endif # Optionally, use Portaudio for live audio input ifdef PORTAUDIO_PREFIX diff --git a/demo/decode_ft8.c b/demo/decode_ft8.c index 1f45967..156c13c 100644 --- a/demo/decode_ft8.c +++ b/demo/decode_ft8.c @@ -17,6 +17,10 @@ #define LOG_LEVEL LOG_INFO #include +#ifdef _WIN32 +#define gmtime_r(timep, result) gmtime_s(result, timep) +#endif + const int kMin_score = 10; // Minimum sync score threshold for candidates const int kMax_candidates = 140; const int kLDPC_iterations = 25; diff --git a/ft8/message.c b/ft8/message.c index 21f5a49..abb0d65 100644 --- a/ft8/message.c +++ b/ft8/message.c @@ -10,6 +10,16 @@ #define NTOKENS ((uint32_t)2063592ul) #define MAXGRID4 ((uint16_t)32400ul) +#ifndef HAVE_STPCPY +#define HAVE_STPCPY + +static char *stpcpy(char *dest, const char *src) { + strcpy(dest, src); + return dest + strlen(src); +} + +#endif + ////////////////////////////////////////////////////// Static function prototypes ////////////////////////////////////////////////////////////// static bool trim_brackets(char* result, const char* original, int length); diff --git a/test/test.c b/test/test.c index 4feffef..18c2f6c 100644 --- a/test/test.c +++ b/test/test.c @@ -15,6 +15,16 @@ #define LOG_LEVEL LOG_INFO #include "ft8/debug.h" +#ifndef HAVE_STPCPY +#define HAVE_STPCPY + +static char *stpcpy(char *dest, const char *src) { + strcpy(dest, src); + return dest + strlen(src); +} + +#endif + // void convert_8bit_to_6bit(uint8_t* dst, const uint8_t* src, int nBits) // { // // Zero-fill the destination array as we will only be setting bits later