Introduce MG_ENABLE_CUSTOM_MILLIS

This commit is contained in:
Sergey Lyubka 2022-04-04 18:14:59 +01:00
parent 417533e90c
commit 0ed64707f3
5 changed files with 16 additions and 1 deletions

View File

@ -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 |

View File

@ -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"

View File

@ -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

View File

@ -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

View File

@ -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