From 012f24100536bd7e3d866a752a2e259665699a92 Mon Sep 17 00:00:00 2001
From: Deomid Ryabkov <rojer@cesanta.com>
Date: Mon, 21 Mar 2016 18:34:20 +0100
Subject: [PATCH] Fix the ESP8266_RTOS example, add it to CI

PUBLISHED_FROM=3d58ec06fe3108a81d1c35f8261783690bb12c4d
---
 examples/ESP8266_RTOS/user/Makefile    | 2 +-
 examples/ESP8266_RTOS/user/esp_libc.c  | 4 ----
 examples/ESP8266_RTOS/user/user_main.c | 7 -------
 mongoose.c                             | 1 +
 mongoose.h                             | 8 +++++++-
 5 files changed, 9 insertions(+), 13 deletions(-)

diff --git a/examples/ESP8266_RTOS/user/Makefile b/examples/ESP8266_RTOS/user/Makefile
index 08c7d7416..5e05c6e13 100644
--- a/examples/ESP8266_RTOS/user/Makefile
+++ b/examples/ESP8266_RTOS/user/Makefile
@@ -23,7 +23,7 @@ endif
 #   makefile at its root level - these are then overridden
 #   for a subtree within the makefile rooted therein
 #
-DEFINES += -DMG_LOCALS \
+DEFINES += -DCS_PLATFORM=3 \
            -DMG_NO_BSD_SOCKETS \
            -DMG_DISABLE_FILESYSTEM \
            -DMG_DISABLE_STDIO \
diff --git a/examples/ESP8266_RTOS/user/esp_libc.c b/examples/ESP8266_RTOS/user/esp_libc.c
index 6eedddcff..e13b3b17a 100644
--- a/examples/ESP8266_RTOS/user/esp_libc.c
+++ b/examples/ESP8266_RTOS/user/esp_libc.c
@@ -53,7 +53,3 @@ int _gettimeofday_r(struct _reent *r, struct timeval *tp, void *tzp) {
   tp->tv_usec = time % 1000000;
   return 0;
 }
-
-long int random(void) {
-  return os_random();
-}
diff --git a/examples/ESP8266_RTOS/user/user_main.c b/examples/ESP8266_RTOS/user/user_main.c
index d7dbcb4b1..0fee30766 100644
--- a/examples/ESP8266_RTOS/user/user_main.c
+++ b/examples/ESP8266_RTOS/user/user_main.c
@@ -101,13 +101,6 @@ xTaskHandle s_mg_task_handle;
 void user_init(void) {
   uart_div_modify(0, UART_CLK_FREQ / 115200);
 
-//  setvbuf(stdout, NULL, _IONBF, 0);
-//  setvbuf(stderr, NULL, _IONBF, 0);
-
   xTaskCreate(mg_task, (const signed char *) "mongoose", MG_TASK_STACK_SIZE,
               NULL, MG_TASK_PRIORITY, &s_mg_task_handle);
 }
-
-void call_user_start(void) {
-  user_init();
-}
diff --git a/mongoose.c b/mongoose.c
index 5c5c26366..c96a467df 100644
--- a/mongoose.c
+++ b/mongoose.c
@@ -5231,6 +5231,7 @@ void mg_http_handler(struct mg_connection *nc, int ev, void *ev_data) {
 #endif /* MG_ENABLE_HTTP_STREAMING_MULTIPART */
     }
   }
+  (void) pd;
 }
 
 static size_t mg_get_line_len(const char *buf, size_t buf_len) {
diff --git a/mongoose.h b/mongoose.h
index 3c5b68173..c4e4f54fe 100644
--- a/mongoose.h
+++ b/mongoose.h
@@ -331,7 +331,6 @@ typedef struct stat cs_stat_t;
 
 #include <assert.h>
 #include <ctype.h>
-#include <errno.h>
 #include <fcntl.h>
 #include <inttypes.h>
 #include <string.h>
@@ -344,6 +343,10 @@ typedef struct stat cs_stat_t;
 #include <lwip/netdb.h>
 #include <lwip/dns.h>
 
+#ifndef LWIP_PROVIDE_ERRNO
+#include <errno.h>
+#endif
+
 #define LWIP_TIMEVAL_PRIVATE 0
 
 #if LWIP_SOCKET
@@ -368,6 +371,9 @@ typedef struct stat cs_stat_t;
 #define INT64_X_FMT PRIx64
 #define __cdecl
 
+unsigned long os_random(void);
+#define random os_random
+
 #endif /* CS_PLATFORM == CS_P_ESP_LWIP */
 #endif /* CS_COMMON_PLATFORMS_PLATFORM_ESP_LWIP_H_ */
 /*
-- 
GitLab