From 0ed64707f3958bae8abbf3e2e11b6826ca807288 Mon Sep 17 00:00:00 2001 From: Sergey Lyubka Date: Mon, 4 Apr 2022 18:14:59 +0100 Subject: [PATCH] Introduce MG_ENABLE_CUSTOM_MILLIS --- docs/README.md | 3 ++- mongoose.c | 3 +++ mongoose.h | 4 ++++ src/config.h | 4 ++++ src/util.c | 3 +++ 5 files changed, 16 insertions(+), 1 deletion(-) diff --git a/docs/README.md b/docs/README.md index 808a4966..07a27230 100644 --- a/docs/README.md +++ b/docs/README.md @@ -236,12 +236,13 @@ Here is a list of build constants and their default values: |MG_ENABLE_SOCKET | 1 | Use BSD socket low-level API | |MG_ENABLE_MBEDTLS | 0 | Enable mbedTLS library | |MG_ENABLE_OPENSSL | 0 | Enable OpenSSL library | -|MG_ENABLE_CUSTOM_TLS | 0 | Enable custom TLS library | |MG_ENABLE_IPV6 | 0 | Enable IPv6 | |MG_ENABLE_LOG | 1 | Enable `LOG()` macro | |MG_ENABLE_MD5 | 0 | Use native MD5 implementation | |MG_ENABLE_SSI | 1 | Enable serving SSI files by `mg_http_serve_dir()` | |MG_ENABLE_CUSTOM_RANDOM | 0 | Provide custom RNG function `mg_random()` | +|MG_ENABLE_CUSTOM_TLS | 0 | Enable custom TLS library | +|MG_ENABLE_CUSTOM_MILLIS | 0 | Enable custom `mg_millis()` function | |MG_ENABLE_PACKED_FS | 0 | Enable embedded FS support | |MG_ENABLE_FATFS | 0 | Enable embedded FAT FS support | |MG_IO_SIZE | 2048 | Granularity of the send/recv IO buffer growth | diff --git a/mongoose.c b/mongoose.c index 03a0bf5c..c3f624ef 100644 --- a/mongoose.c +++ b/mongoose.c @@ -4766,6 +4766,8 @@ int mg_check_ip_acl(struct mg_str acl, uint32_t remote_ip) { return allowed == '+'; } +#if MG_ENABLE_CUSTOM_MILLIS +#else int64_t mg_millis(void) { #if MG_ARCH == MG_ARCH_WIN32 return GetTickCount(); @@ -4800,6 +4802,7 @@ int64_t mg_millis(void) { return time(NULL) * 1000; #endif } +#endif #ifdef MG_ENABLE_LINES #line 1 "src/ws.c" diff --git a/mongoose.h b/mongoose.h index 388ca955..1a90ce4e 100644 --- a/mongoose.h +++ b/mongoose.h @@ -548,6 +548,10 @@ int sscanf(const char *, const char *, ...); #define MG_ENABLE_CUSTOM_RANDOM 0 #endif +#ifndef MG_ENABLE_CUSTOM_MILLIS +#define MG_ENABLE_CUSTOM_MILLIS 0 +#endif + #ifndef MG_ENABLE_PACKED_FS #define MG_ENABLE_PACKED_FS 0 #endif diff --git a/src/config.h b/src/config.h index 51d2a00e..17477167 100644 --- a/src/config.h +++ b/src/config.h @@ -57,6 +57,10 @@ #define MG_ENABLE_CUSTOM_RANDOM 0 #endif +#ifndef MG_ENABLE_CUSTOM_MILLIS +#define MG_ENABLE_CUSTOM_MILLIS 0 +#endif + #ifndef MG_ENABLE_PACKED_FS #define MG_ENABLE_PACKED_FS 0 #endif diff --git a/src/util.c b/src/util.c index 7d8760fb..88417068 100644 --- a/src/util.c +++ b/src/util.c @@ -78,6 +78,8 @@ int mg_check_ip_acl(struct mg_str acl, uint32_t remote_ip) { return allowed == '+'; } +#if MG_ENABLE_CUSTOM_MILLIS +#else int64_t mg_millis(void) { #if MG_ARCH == MG_ARCH_WIN32 return GetTickCount(); @@ -112,3 +114,4 @@ int64_t mg_millis(void) { return time(NULL) * 1000; #endif } +#endif