From 81bf4921d490fea6004a8af01490cca940f818a2 Mon Sep 17 00:00:00 2001 From: Deomid Ryabkov <rojer@cesanta.com> Date: Mon, 2 May 2016 17:16:27 +0200 Subject: [PATCH] Compile mg-iot-cc3200 with ARM compiler, step 1 Code size: 167144 vs 199440 More changes to come (console support, warnings cleanup). PUBLISHED_FROM=cbc06efcb354c240654518b493496a69293ebc2a --- mongoose.c | 31 +++++++++++++++++++++++++++++-- mongoose.h | 3 +++ 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/mongoose.c b/mongoose.c index b2f6d9f78..bad492b49 100644 --- a/mongoose.c +++ b/mongoose.c @@ -4307,6 +4307,8 @@ struct mg_cgi_env_block { int nvars; /* Number of variables in envp[] */ }; +#ifndef MG_DISABLE_FILESYSTEM + #define MIME_ENTRY(_ext, _type) \ { _ext, sizeof(_ext) - 1, _type } static const struct { @@ -4364,8 +4366,6 @@ static const struct { MIME_ENTRY("bmp", "image/bmp"), {NULL, 0, NULL}}; -#ifndef MG_DISABLE_FILESYSTEM - #ifndef MG_DISABLE_DAV static int mg_mkdir(const char *path, uint32_t mode) { #ifndef _WIN32 @@ -10203,6 +10203,33 @@ int mg_set_protocol_coap(struct mg_connection *nc) { #define CONSOLE_UART UARTA0_BASE +#ifdef __TI_COMPILER_VERSION__ +int asprintf(char **strp, const char *fmt, ...) { + va_list ap; + int len; + + *strp = malloc(BUFSIZ); + if (*strp == NULL) return -1; + + va_start(ap, fmt); + len = vsnprintf(*strp, BUFSIZ, fmt, ap); + va_end(ap); + + if (len > 0) { + *strp = realloc(*strp, len); + if (*strp == NULL) return -1; + } + + if (len >= BUFSIZ) { + va_start(ap, fmt); + len = vsnprintf(*strp, len, fmt, ap); + va_end(ap); + } + + return len; +} +#endif /* __TI_COMPILER_VERSION__ */ + #ifndef __TI_COMPILER_VERSION__ int _gettimeofday_r(struct _reent *r, struct timeval *tp, void *tzp) { #else diff --git a/mongoose.h b/mongoose.h index 75a763a21..e8834facc 100644 --- a/mongoose.h +++ b/mongoose.h @@ -449,6 +449,9 @@ extern "C" { struct SlTimeval_t; #define timeval SlTimeval_t int gettimeofday(struct timeval *t, void *tz); + +int asprintf(char **strp, const char *fmt, ...); + #endif long int random(void); -- GitLab