Browse Source

Major cleanup - c_whatever is finally history. (#2838)

The PR removed the bulk of non-newlib headers from the NodeMCU source base.  
app/libc has now been cut down to the bare minimum overrides to shadow the 
corresponding functions in the SDK's libc. The old c_xyz.h headerfiles have been 
nuked in favour of the standard <xyz.h> headers, with a few exceptions over in 
sdk-overrides. Again, shipping a libc.a without headers is a terrible thing to do. We're 
still living on a prayer that libc was configured the same was as a default-configured
xtensa gcc toolchain assumes it is. That part I cannot do anything about, unfortunately, 
but it's no worse than it has been before.

This enables our source files to compile successfully using the standard header files, 
and use the typical malloc()/calloc()/realloc()/free(), the strwhatever()s and 
memwhatever()s. These end up, through macro and linker magic, mapped to the 
appropriate SDK or ROM functions.
Johny Mattsson 4 years ago
parent
commit
526d21dab4
100 changed files with 632 additions and 1767 deletions
  1. 15 13
      app/Makefile
  2. 25 25
      app/coap/coap.c
  3. 2 2
      app/coap/coap.h
  4. 3 3
      app/coap/coap_io.c
  5. 2 2
      app/coap/coap_server.c
  6. 1 0
      app/coap/coap_timer.c
  7. 35 35
      app/coap/endpoints.c
  8. 2 2
      app/coap/hash.c
  9. 5 5
      app/coap/node.c
  10. 15 15
      app/coap/pdu.c
  11. 4 4
      app/coap/str.c
  12. 1 1
      app/coap/str.h
  13. 8 8
      app/coap/uri.c
  14. 2 1
      app/crypto/digests.c
  15. 4 3
      app/crypto/mech.c
  16. 1 1
      app/dht/dht.c
  17. 1 1
      app/driver/i2c_master.c
  18. 4 4
      app/driver/rotary.c
  19. 8 8
      app/driver/switec.c
  20. 74 73
      app/fatfs/myfatfs.c
  21. 1 1
      app/http/httpclient.c
  22. 1 1
      app/include/pm/pmSleep.h
  23. 5 0
      app/include/user_config.h
  24. 4 2
      app/include/user_mbedtls.h
  25. 0 16
      app/libc/c_ctype.c
  26. 0 42
      app/libc/c_ctype.h
  27. 0 19
      app/libc/c_errno.h
  28. 0 9
      app/libc/c_fcntl.h
  29. 0 58
      app/libc/c_limits.h
  30. 0 62
      app/libc/c_locale.h
  31. 0 62
      app/libc/c_math.h
  32. 0 6
      app/libc/c_signal.h
  33. 0 22
      app/libc/c_stdarg.h
  34. 0 23
      app/libc/c_stddef.h
  35. 0 273
      app/libc/c_stdint.h
  36. 0 105
      app/libc/c_stdio.h
  37. 0 64
      app/libc/c_stdlib.h
  38. 0 129
      app/libc/c_string.c
  39. 0 50
      app/libc/c_string.h
  40. 2 103
      app/libc/math.c
  41. 31 71
      app/libc/stdio.c
  42. 3 20
      app/libc/stdlib.c
  43. 3 4
      app/lua/lapi.c
  44. 34 35
      app/lua/lauxlib.c
  45. 0 6
      app/lua/lauxlib.h
  46. 8 8
      app/lua/lbaselib.c
  47. 2 2
      app/lua/lcode.c
  48. 19 19
      app/lua/ldblib.c
  49. 4 4
      app/lua/ldebug.c
  50. 1 1
      app/lua/ldo.c
  51. 7 7
      app/lua/ldump.c
  52. 10 10
      app/lua/lflash.c
  53. 2 2
      app/lua/lfunc.c
  54. 4 4
      app/lua/lgc.c
  55. 5 5
      app/lua/llex.c
  56. 0 2
      app/lua/llimits.h
  57. 2 2
      app/lua/lmathlib.c
  58. 0 6
      app/lua/lmem.h
  59. 11 11
      app/lua/loadlib.c
  60. 17 17
      app/lua/lobject.c
  61. 0 4
      app/lua/lobject.h
  62. 1 1
      app/lua/lparser.c
  63. 4 4
      app/lua/lrotable.c
  64. 4 4
      app/lua/lstring.c
  65. 1 1
      app/lua/lstring.h
  66. 16 16
      app/lua/lstrlib.c
  67. 3 3
      app/lua/ltable.c
  68. 1 1
      app/lua/ltm.c
  69. 16 17
      app/lua/lua.c
  70. 4 10
      app/lua/lua.h
  71. 2 3
      app/lua/luac_cross/Makefile
  72. 1 2
      app/lua/luac_cross/mingw32-Makefile.mak
  73. 11 27
      app/lua/luaconf.h
  74. 3 3
      app/lua/lundump.c
  75. 0 4
      app/lua/lundump.h
  76. 6 6
      app/lua/lvm.c
  77. 2 2
      app/lua/lzio.c
  78. 0 9
      app/mbedtls/library/platform.c
  79. 4 0
      app/mbedtls/platform/mbedtls_mem.c
  80. 3 0
      app/mbedtls/platform/memcompat.c
  81. 1 1
      app/modules/ads1115.c
  82. 2 2
      app/modules/adxl345.c
  83. 2 2
      app/modules/apa102.c
  84. 1 1
      app/modules/bit.c
  85. 1 0
      app/modules/bloom.c
  86. 1 1
      app/modules/bme280.c
  87. 1 1
      app/modules/bme680.c
  88. 2 2
      app/modules/bmp085.c
  89. 23 23
      app/modules/coap.c
  90. 3 3
      app/modules/color_utils.c
  91. 3 3
      app/modules/color_utils.h
  92. 2 2
      app/modules/cron.c
  93. 2 2
      app/modules/crypto.c
  94. 3 3
      app/modules/encoder.c
  95. 101 101
      app/modules/enduser_setup.c
  96. 7 7
      app/modules/file.c
  97. 1 1
      app/modules/gpio.c
  98. 1 1
      app/modules/gpio_pulse.c
  99. 3 3
      app/modules/hdc1080.c
  100. 2 2
      app/modules/hmc5883l.c

+ 15 - 13
app/Makefile

@@ -90,31 +90,33 @@ COMPONENTS_eagle.app.v6 = 			\
 # only those) modules are pulled in.
 SELECTED_MODULE_SYMS=$(filter %_module_selected %module_selected1,$(shell $(NM) modules/.output/$(TARGET)/$(FLAVOR)/lib/libmodules.a))
 
-LINKFLAGS_eagle.app.v6 = 			\
-	-Wl,--gc-sections 			\
-	-Wl,-Map=mapfile 			\
+LINKFLAGS_eagle.app.v6 = 	\
+	-Wl,--gc-sections 		\
+	-Wl,-Map=mapfile 		\
 	-nostdlib 				\
-	-T$(LD_FILE) 				\
-	-Wl,@../ld/defsym.rom			\
-	-Wl,--no-check-sections 		\
-	-Wl,-static 				\
+	-T$(LD_FILE) 			\
+	-Wl,@../ld/defsym.rom	\
+	-Wl,--no-check-sections	\
+	-Wl,-static 			\
 	$(addprefix -u , $(SELECTED_MODULE_SYMS)) \
-	-Wl,--start-group 			\
+	-Wl,--start-group 		\
 	-lmain 					\
-	-lc 					\
+	$(DEP_LIBS_eagle.app.v6)\
+	-Wl,--end-group 		\
+	-Wl,--start-group 		\
 	-lgcc 					\
 	-lhal 					\
 	-lphy 					\
 	-lpp 					\
 	-lnet80211 				\
+	-lsmartconfig 			\
 	-lwpa 					\
 	-lwpa2					\
-	-lsmartconfig 				\
 	-lcrypto				\
 	-lwps					\
-	$(DEP_LIBS_eagle.app.v6) 		\
-	-Wl,--end-group 			\
-	-lm
+	-lc 					\
+	-lm						\
+	-Wl,--end-group
 #	-Wl,--cref
 #	-Wl,--wrap=_xtos_set_exception_handler
 

+ 25 - 25
app/coap/coap.c

@@ -1,6 +1,6 @@
 #include "user_config.h"
-#include "c_stdio.h"
-#include "c_string.h"
+#include <stdio.h>
+#include <string.h>
 #include "coap.h"
 #include "uri.h"
 
@@ -10,12 +10,12 @@ extern const coap_endpoint_t endpoints[];
 #ifdef COAP_DEBUG
 void coap_dumpHeader(coap_header_t *hdr)
 {
-    c_printf("Header:\n");
-    c_printf("  ver  0x%02X\n", hdr->ver);
-    c_printf("  t    0x%02X\n", hdr->ver);
-    c_printf("  tkl  0x%02X\n", hdr->tkl);
-    c_printf("  code 0x%02X\n", hdr->code);
-    c_printf("  id   0x%02X%02X\n", hdr->id[0], hdr->id[1]);
+    printf("Header:\n");
+    printf("  ver  0x%02X\n", hdr->ver);
+    printf("  t    0x%02X\n", hdr->ver);
+    printf("  tkl  0x%02X\n", hdr->tkl);
+    printf("  code 0x%02X\n", hdr->code);
+    printf("  id   0x%02X%02X\n", hdr->id[0], hdr->id[1]);
 }
 
 void coap_dump(const uint8_t *buf, size_t buflen, bool bare)
@@ -23,14 +23,14 @@ void coap_dump(const uint8_t *buf, size_t buflen, bool bare)
     if (bare)
     {
         while(buflen--)
-            c_printf("%02X%s", *buf++, (buflen > 0) ? " " : "");
+            printf("%02X%s", *buf++, (buflen > 0) ? " " : "");
     }
     else
     {
-        c_printf("Dump: ");
+        printf("Dump: ");
         while(buflen--)
-            c_printf("%02X%s", *buf++, (buflen > 0) ? " " : "");
-        c_printf("\n");
+            printf("%02X%s", *buf++, (buflen > 0) ? " " : "");
+        printf("\n");
     }
 }
 #endif
@@ -100,7 +100,7 @@ int coap_buildToken(const coap_buffer_t *tokbuf, const coap_header_t *hdr, uint8
         return COAP_ERR_UNSUPPORTED;
 
     if (hdr->tkl > 0)
-        c_memcpy(p, tokbuf->p, hdr->tkl);
+        memcpy(p, tokbuf->p, hdr->tkl);
 
     // http://tools.ietf.org/html/rfc7252#section-3.1
     // inject options
@@ -260,12 +260,12 @@ int coap_buildOptionHeader(uint32_t optDelta, size_t length, uint8_t *buf, size_
 void coap_dumpOptions(coap_option_t *opts, size_t numopt)
 {
     size_t i;
-    c_printf(" Options:\n");
+    printf(" Options:\n");
     for (i=0;i<numopt;i++)
     {
-        c_printf("  0x%02X [ ", opts[i].num);
+        printf("  0x%02X [ ", opts[i].num);
         coap_dump(opts[i].buf.p, opts[i].buf.len, true);
-        c_printf(" ]\n");
+        printf(" ]\n");
     }
 }
 
@@ -273,9 +273,9 @@ void coap_dumpPacket(coap_packet_t *pkt)
 {
     coap_dumpHeader(&pkt->hdr);
     coap_dumpOptions(pkt->opts, pkt->numopts);
-    c_printf("Payload: ");
+    printf("Payload: ");
     coap_dump(pkt->payload.p, pkt->payload.len, true);
-    c_printf("\n");
+    printf("\n");
 }
 #endif
 
@@ -325,7 +325,7 @@ int coap_buffer_to_string(char *strbuf, size_t strbuflen, const coap_buffer_t *b
 {
     if (buf->len+1 > strbuflen)
         return COAP_ERR_BUFFER_TOO_SMALL;
-    c_memcpy(strbuf, buf->p, buf->len);
+    memcpy(strbuf, buf->p, buf->len);
     strbuf[buf->len] = 0;
     return 0;
 }
@@ -360,7 +360,7 @@ int coap_build(uint8_t *buf, size_t *buflen, const coap_packet_t *pkt)
         p += rc;
         left -= rc;
 
-        c_memcpy(p, pkt->opts[i].buf.p, pkt->opts[i].buf.len);
+        memcpy(p, pkt->opts[i].buf.p, pkt->opts[i].buf.len);
         p += pkt->opts[i].buf.len;
         left -= pkt->opts[i].buf.len;
         running_delta = pkt->opts[i].num;
@@ -373,7 +373,7 @@ int coap_build(uint8_t *buf, size_t *buflen, const coap_packet_t *pkt)
         if (*buflen < 4 + 1 + pkt->payload.len + opts_len)
             return COAP_ERR_BUFFER_TOO_SMALL;
         buf[4 + opts_len] = 0xFF;  // payload marker
-        c_memcpy(buf+5 + opts_len, pkt->payload.p, pkt->payload.len);
+        memcpy(buf+5 + opts_len, pkt->payload.p, pkt->payload.len);
         *buflen = opts_len + 5 + pkt->payload.len;
     }
     else
@@ -471,7 +471,7 @@ int coap_make_request(coap_rw_buffer_t *scratch, coap_packet_t *pkt, coap_msgtyp
 
     /* split arg into Uri-* options */
     // const char *addr = uri->host.s;
-    // if(uri->host.length && (c_strlen(addr) != uri->host.length || c_memcmp(addr, uri->host.s, uri->host.length) != 0)){
+    // if(uri->host.length && (strlen(addr) != uri->host.length || memcmp(addr, uri->host.s, uri->host.length) != 0)){
     if(uri->host.length){
         /* add Uri-Host */
         // addr is destination address
@@ -525,9 +525,9 @@ int coap_handle_req(coap_rw_buffer_t *scratch, const coap_packet_t *inpkt, coap_
                 goto next;
             for (i=0;i<ep->path->count;i++)
             {
-                if (opt[i].buf.len != c_strlen(ep->path->elems[i]))
+                if (opt[i].buf.len != strlen(ep->path->elems[i]))
                     goto next;
-                if (0 != c_memcmp(ep->path->elems[i], opt[i].buf.p, opt[i].buf.len))
+                if (0 != memcmp(ep->path->elems[i], opt[i].buf.p, opt[i].buf.len))
                     goto next;
             }
             // pre-path match!
@@ -551,5 +551,5 @@ void coap_setup(void)
 
 int
 check_token(coap_packet_t *pkt) {
-  return pkt->tok.len == the_token.len && c_memcmp(pkt->tok.p, the_token.p, the_token.len) == 0;
+  return pkt->tok.len == the_token.len && memcmp(pkt->tok.p, the_token.p, the_token.len) == 0;
 }

+ 2 - 2
app/coap/coap.h

@@ -5,8 +5,8 @@
 extern "C" {
 #endif
 
-#include "c_stdint.h"
-#include "c_stddef.h"
+#include <stdint.h>
+#include <stddef.h>
 #include "lualib.h"
 #include "lauxlib.h"
 

+ 3 - 3
app/coap/coap_io.c

@@ -1,4 +1,4 @@
-#include "c_string.h"
+#include <string.h>
 #include "coap_io.h"
 #include "node.h"
 #include "espconn.h"
@@ -16,10 +16,10 @@ coap_tid_t coap_send(struct espconn *pesp_conn, coap_pdu_t *pdu) {
   espconn_sent(pesp_conn, (unsigned char *)(pdu->msg.p), pdu->msg.len);
 
   if(pesp_conn->type == ESPCONN_TCP){
-    c_memcpy(&ip, pesp_conn->proto.tcp->remote_ip, sizeof(ip));
+    memcpy(&ip, pesp_conn->proto.tcp->remote_ip, sizeof(ip));
     port = pesp_conn->proto.tcp->remote_port;
   }else{
-    c_memcpy(&ip, pesp_conn->proto.udp->remote_ip, sizeof(ip));
+    memcpy(&ip, pesp_conn->proto.udp->remote_ip, sizeof(ip));
     port = pesp_conn->proto.udp->remote_port;
   }
   coap_transaction_id(ip, port, pdu->pkt, &id);

+ 2 - 2
app/coap/coap_server.c

@@ -1,6 +1,6 @@
 #include "user_config.h"
 #include "c_types.h"
-#include "c_stdlib.h"
+#include <stdlib.h>
 
 #include "coap.h"
 
@@ -51,7 +51,7 @@ size_t coap_server_respond(char *req, unsigned short reqlen, char *rsp, unsigned
 #endif
     }
     if(rsppkt.content.p){
-      c_free(rsppkt.content.p);
+      free(rsppkt.content.p);
       rsppkt.content.p = NULL;
       rsppkt.content.len = 0;
     }

+ 1 - 0
app/coap/coap_timer.c

@@ -1,6 +1,7 @@
 #include "node.h"
 #include "coap_timer.h"
 #include "os_type.h"
+#include "osapi.h"
 #include "pm/swtimer.h"
 
 static os_timer_t coap_timer;

+ 35 - 35
app/coap/endpoints.c

@@ -1,6 +1,6 @@
-#include "c_stdio.h"
-#include "c_string.h"
-#include "c_stdlib.h"
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
 #include "coap.h"
 
 #include "lua.h"
@@ -21,14 +21,14 @@ void endpoint_setup(void)
 static const coap_endpoint_path_t path_well_known_core = {2, {".well-known", "core"}};
 static int handle_get_well_known_core(const coap_endpoint_t *ep, coap_rw_buffer_t *scratch, const coap_packet_t *inpkt, coap_packet_t *outpkt, uint8_t id_hi, uint8_t id_lo)
 {
-    outpkt->content.p = (uint8_t *)c_zalloc(MAX_PAYLOAD_SIZE);      // this should be free-ed when outpkt is built in coap_server_respond()
+    outpkt->content.p = (uint8_t *)calloc(1,MAX_PAYLOAD_SIZE);      // this should be free-ed when outpkt is built in coap_server_respond()
     if(outpkt->content.p == NULL){
         NODE_DBG("not enough memory\n");
         return COAP_ERR_BUFFER_TOO_SMALL;
     }
     outpkt->content.len = MAX_PAYLOAD_SIZE;
     build_well_known_rsp(outpkt->content.p, outpkt->content.len);
-    return coap_make_response(scratch, outpkt, (const uint8_t *)outpkt->content.p, c_strlen(outpkt->content.p), id_hi, id_lo, &inpkt->tok, COAP_RSPCODE_CONTENT, COAP_CONTENTTYPE_APPLICATION_LINKFORMAT);
+    return coap_make_response(scratch, outpkt, (const uint8_t *)outpkt->content.p, strlen(outpkt->content.p), id_hi, id_lo, &inpkt->tok, COAP_RSPCODE_CONTENT, COAP_CONTENTTYPE_APPLICATION_LINKFORMAT);
 }
 
 static const coap_endpoint_path_t path_variable = {2, {"v1", "v"}};
@@ -49,17 +49,17 @@ static int handle_get_variable(const coap_endpoint_t *ep, coap_rw_buffer_t *scra
         {
             coap_luser_entry *h = ep->user_entry->next;     // ->next: skip the first entry(head)
             while(NULL != h){
-                if (opt[count-1].buf.len != c_strlen(h->name))
+                if (opt[count-1].buf.len != strlen(h->name))
                 {
                     h = h->next;
                     continue;
                 }
-                if (0 == c_memcmp(h->name, opt[count-1].buf.p, opt[count-1].buf.len))
+                if (0 == memcmp(h->name, opt[count-1].buf.p, opt[count-1].buf.len))
                 {
                     NODE_DBG("/v1/v/");
                     NODE_DBG((char *)h->name);
                     NODE_DBG(" match.\n");
-                    if(c_strlen(h->name))
+                    if(strlen(h->name))
                     {
                         n = lua_gettop(L);
                         lua_getglobal(L, h->name);
@@ -70,7 +70,7 @@ static int handle_get_variable(const coap_endpoint_t *ep, coap_rw_buffer_t *scra
                         } else {
                             const char *res = lua_tostring(L,-1);
                             lua_settop(L, n);
-                            return coap_make_response(scratch, outpkt, (const uint8_t *)res, c_strlen(res), id_hi, id_lo, &inpkt->tok, COAP_RSPCODE_CONTENT, h->content_type);
+                            return coap_make_response(scratch, outpkt, (const uint8_t *)res, strlen(res), id_hi, id_lo, &inpkt->tok, COAP_RSPCODE_CONTENT, h->content_type);
                         }
                     }
                 } else {
@@ -105,18 +105,18 @@ static int handle_post_function(const coap_endpoint_t *ep, coap_rw_buffer_t *scr
         {
             coap_luser_entry *h = ep->user_entry->next;     // ->next: skip the first entry(head)
             while(NULL != h){
-                if (opt[count-1].buf.len != c_strlen(h->name))
+                if (opt[count-1].buf.len != strlen(h->name))
                 {
                     h = h->next;
                     continue;
                 }
-                if (0 == c_memcmp(h->name, opt[count-1].buf.p, opt[count-1].buf.len))
+                if (0 == memcmp(h->name, opt[count-1].buf.p, opt[count-1].buf.len))
                 {
                     NODE_DBG("/v1/f/");
                     NODE_DBG((char *)h->name);
                     NODE_DBG(" match.\n");
 
-                    if(c_strlen(h->name))
+                    if(strlen(h->name))
                     {
                         n = lua_gettop(L);
                         lua_getglobal(L, h->name);
@@ -173,7 +173,7 @@ static int handle_post_command(const coap_endpoint_t *ep, coap_rw_buffer_t *scra
     {
         char line[LUA_MAXINPUT];
         if (!coap_buffer_to_string(line, LUA_MAXINPUT, &inpkt->payload) &&
-            lua_put_line(line, c_strlen(line))) {
+            lua_put_line(line, strlen(line))) {
             NODE_DBG("\nResult(if any):\n");
             system_os_post (LUA_TASK_PRIO, LUA_PROCESS_LINE_SIG, 0);
         }
@@ -211,7 +211,7 @@ void build_well_known_rsp(char *rsp, uint16_t rsplen)
     int i;
     uint16_t len = rsplen;
 
-    c_memset(rsp, 0, len);
+    memset(rsp, 0, len);
 
     len--; // Null-terminated string
 
@@ -222,57 +222,57 @@ void build_well_known_rsp(char *rsp, uint16_t rsplen)
             continue;
         }
         if (NULL == ep->user_entry){
-            if (0 < c_strlen(rsp)) {
-                c_strncat(rsp, ",", len);
+            if (0 < strlen(rsp)) {
+                strncat(rsp, ",", len);
                 len--;
             }
 
-            c_strncat(rsp, "<", len);
+            strncat(rsp, "<", len);
             len--;
 
             for (i = 0; i < ep->path->count; i++) {
-                c_strncat(rsp, "/", len);
+                strncat(rsp, "/", len);
                 len--;
 
-                c_strncat(rsp, ep->path->elems[i], len);
-                len -= c_strlen(ep->path->elems[i]);
+                strncat(rsp, ep->path->elems[i], len);
+                len -= strlen(ep->path->elems[i]);
             }
 
-            c_strncat(rsp, ">;", len);
+            strncat(rsp, ">;", len);
             len -= 2;
 
-            c_strncat(rsp, ep->core_attr, len);
-            len -= c_strlen(ep->core_attr);
+            strncat(rsp, ep->core_attr, len);
+            len -= strlen(ep->core_attr);
         } else {
             coap_luser_entry *h = ep->user_entry->next;     // ->next: skip the first entry(head)
             while(NULL != h){
-                if (0 < c_strlen(rsp)) {
-                    c_strncat(rsp, ",", len);
+                if (0 < strlen(rsp)) {
+                    strncat(rsp, ",", len);
                     len--;
                 }
 
-                c_strncat(rsp, "<", len);
+                strncat(rsp, "<", len);
                 len--;
 
                 for (i = 0; i < ep->path->count; i++) {
-                    c_strncat(rsp, "/", len);
+                    strncat(rsp, "/", len);
                     len--;
 
-                    c_strncat(rsp, ep->path->elems[i], len);
-                    len -= c_strlen(ep->path->elems[i]);
+                    strncat(rsp, ep->path->elems[i], len);
+                    len -= strlen(ep->path->elems[i]);
                 }
 
-                c_strncat(rsp, "/", len);
+                strncat(rsp, "/", len);
                 len--;
 
-                c_strncat(rsp, h->name, len);
-                len -= c_strlen(h->name);
+                strncat(rsp, h->name, len);
+                len -= strlen(h->name);
 
-                c_strncat(rsp, ">;", len);
+                strncat(rsp, ">;", len);
                 len -= 2;
 
-                c_strncat(rsp, ep->core_attr, len);
-                len -= c_strlen(ep->core_attr);
+                strncat(rsp, ep->core_attr, len);
+                len -= strlen(ep->core_attr);
 
                 h = h->next;
             }

+ 2 - 2
app/coap/hash.c

@@ -1,5 +1,5 @@
 #include "hash.h"
-#include "c_string.h"
+#include <string.h>
 /* Caution: When changing this, update COAP_DEFAULT_WKC_HASHKEY
  * accordingly (see int coap_hash_path());
  */
@@ -20,7 +20,7 @@ void coap_hash(const unsigned char *s, unsigned int len, coap_key_t h) {
 
 void coap_transaction_id(const uint32_t ip, const uint32_t port, const coap_packet_t *pkt, coap_tid_t *id) {
   coap_key_t h;
-  c_memset(h, 0, sizeof(coap_key_t));
+  memset(h, 0, sizeof(coap_key_t));
 
   /* Compare the transport address. */
   coap_hash((const unsigned char *)&(port), sizeof(port), h);

+ 5 - 5
app/coap/node.c

@@ -1,14 +1,14 @@
-#include "c_string.h"
-#include "c_stdlib.h"
+#include <string.h>
+#include <stdlib.h>
 #include "node.h"
 
 static inline coap_queue_t *
 coap_malloc_node(void) {
-  return (coap_queue_t *)c_zalloc(sizeof(coap_queue_t));
+  return (coap_queue_t *)calloc(1,sizeof(coap_queue_t));
 }
 
 void coap_free_node(coap_queue_t *node) {
-  c_free(node);
+  free(node);
 }
 
 int coap_insert_node(coap_queue_t **queue, coap_queue_t *node) {
@@ -73,7 +73,7 @@ coap_queue_t * coap_new_node(void) {
     return NULL;
   }
 
-  c_memset(node, 0, sizeof(*node));
+  memset(node, 0, sizeof(*node));
   return node;
 }
 

+ 15 - 15
app/coap/pdu.c

@@ -1,38 +1,38 @@
-#include "c_stdlib.h"
+#include <stdlib.h>
 #include "pdu.h"
 
 coap_pdu_t * coap_new_pdu(void) {
   coap_pdu_t *pdu = NULL;
-  pdu = (coap_pdu_t *)c_zalloc(sizeof(coap_pdu_t));
+  pdu = (coap_pdu_t *)calloc(1,sizeof(coap_pdu_t));
   if(!pdu){
     NODE_DBG("coap_new_pdu malloc error.\n");
     return NULL;
   }
 
-  pdu->scratch.p = (uint8_t *)c_zalloc(MAX_REQ_SCRATCH_SIZE);
+  pdu->scratch.p = (uint8_t *)calloc(1,MAX_REQ_SCRATCH_SIZE);
   if(!pdu->scratch.p){
     NODE_DBG("coap_new_pdu malloc error.\n");
-    c_free(pdu);
+    free(pdu);
     return NULL;
   }
   pdu->scratch.len = MAX_REQ_SCRATCH_SIZE;
 
-  pdu->pkt = (coap_packet_t *)c_zalloc(sizeof(coap_packet_t));
+  pdu->pkt = (coap_packet_t *)calloc(1,sizeof(coap_packet_t));
   if(!pdu->pkt){
     NODE_DBG("coap_new_pdu malloc error.\n");
-    c_free(pdu->scratch.p);
-    c_free(pdu);
+    free(pdu->scratch.p);
+    free(pdu);
     return NULL;
   }
   pdu->pkt->content.p = NULL;
   pdu->pkt->content.len = 0;
 
-  pdu->msg.p = (uint8_t *)c_zalloc(MAX_REQUEST_SIZE+1); // +1 for string '\0'
+  pdu->msg.p = (uint8_t *)calloc(1,MAX_REQUEST_SIZE+1); // +1 for string '\0'
   if(!pdu->msg.p){
     NODE_DBG("coap_new_pdu malloc error.\n");
-    c_free(pdu->pkt);
-    c_free(pdu->scratch.p);
-    c_free(pdu);
+    free(pdu->pkt);
+    free(pdu->scratch.p);
+    free(pdu);
     return NULL;
   }
   pdu->msg.len = MAX_REQUEST_SIZE;
@@ -44,22 +44,22 @@ void coap_delete_pdu(coap_pdu_t *pdu){
     return;
 
   if(pdu->scratch.p){
-    c_free(pdu->scratch.p);
+    free(pdu->scratch.p);
     pdu->scratch.p = NULL;
     pdu->scratch.len = 0;
   }
 
   if(pdu->pkt){
-    c_free(pdu->pkt);
+    free(pdu->pkt);
     pdu->pkt = NULL;
   }
 
   if(pdu->msg.p){
-    c_free(pdu->msg.p);
+    free(pdu->msg.p);
     pdu->msg.p = NULL;
     pdu->msg.len = 0;
   }
 
-  c_free(pdu);
+  free(pdu);
   pdu = NULL;
 }

+ 4 - 4
app/coap/str.c

@@ -6,23 +6,23 @@
  * README for terms of use.
  */
 
-#include "c_stdlib.h"
+#include <stdlib.h>
 #include "c_types.h"
 
 #include "str.h"
 
 str * coap_new_string(size_t size) {
-  str *s = (str *)c_malloc(sizeof(str) + size + 1);
+  str *s = (str *)malloc(sizeof(str) + size + 1);
   if ( !s ) {
     return NULL;
   }
 
-  c_memset(s, 0, sizeof(str));
+  memset(s, 0, sizeof(str));
   s->s = ((unsigned char *)s) + sizeof(str);
   return s;
 }
 
 void coap_delete_string(str *s) {
-  c_free(s);
+  free(s);
 }
 

+ 1 - 1
app/coap/str.h

@@ -9,7 +9,7 @@
 #ifndef _COAP_STR_H_
 #define _COAP_STR_H_
 
-#include "c_string.h"
+#include <string.h>
 
 typedef struct {
   size_t length;		/* length of string */

+ 8 - 8
app/coap/uri.c

@@ -1,10 +1,10 @@
 /* uri.c -- helper functions for URI treatment
  */
 
-#include "c_stdio.h"
-#include "c_stdlib.h"
-#include "c_string.h"
-#include "c_ctype.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
 
 #include "coap.h"
 #include "uri.h"
@@ -43,7 +43,7 @@ int coap_split_uri(unsigned char *str_var, size_t len, coap_uri_t *uri) {
   if (!str_var || !uri)
     return -1;
 
-  c_memset(uri, 0, sizeof(coap_uri_t));
+  memset(uri, 0, sizeof(coap_uri_t));
   uri->port = COAP_DEFAULT_PORT;
 
   /* search for scheme */
@@ -394,16 +394,16 @@ int coap_split_query(coap_rw_buffer_t *scratch, coap_packet_t *pkt, const unsign
 coap_uri_t * coap_new_uri(const unsigned char *uri, unsigned int length) {
   unsigned char *result;
 
-  result = (unsigned char *)c_malloc(length + 1 + sizeof(coap_uri_t));
+  result = (unsigned char *)malloc(length + 1 + sizeof(coap_uri_t));
 
   if (!result)
     return NULL;
 
-  c_memcpy(URI_DATA(result), uri, length);
+  memcpy(URI_DATA(result), uri, length);
   URI_DATA(result)[length] = '\0'; /* make it zero-terminated */
 
   if (coap_split_uri(URI_DATA(result), length, (coap_uri_t *)result) < 0) {
-    c_free(result);
+    free(result);
     return NULL;
   }
   return (coap_uri_t *)result;

+ 2 - 1
app/crypto/digests.c

@@ -34,7 +34,8 @@
 #include "osapi.h"
 #include "mem.h"
 #include <string.h>
-#include <c_errno.h>
+#include <strings.h>
+#include <errno.h>
 
 #ifdef MD2_ENABLE
 #include "ssl/ssl_crypto.h"

+ 4 - 3
app/crypto/mech.c

@@ -33,7 +33,8 @@
 
 #include "mech.h"
 #include "sdk-aes.h"
-#include "c_string.h"
+#include <string.h>
+#include <strings.h>
 
 /* ----- AES ---------------------------------------------------------- */
 
@@ -58,7 +59,7 @@ static bool do_aes (crypto_op_t *co, bool with_cbc)
 
   char iv[AES_BLOCKSIZE] = { 0 };
   if (with_cbc && co->ivlen)
-    c_memcpy (iv, co->iv, co->ivlen < AES_BLOCKSIZE ? co->ivlen : AES_BLOCKSIZE);
+    memcpy (iv, co->iv, co->ivlen < AES_BLOCKSIZE ? co->ivlen : AES_BLOCKSIZE);
 
   const char *src = co->data;
   char *dst = co->out;
@@ -68,7 +69,7 @@ static bool do_aes (crypto_op_t *co, bool with_cbc)
   {
     char block[AES_BLOCKSIZE] = { 0 };
     size_t n = left > AES_BLOCKSIZE ? AES_BLOCKSIZE : left;
-    c_memcpy (block, src, n);
+    memcpy (block, src, n);
 
     if (with_cbc && co->op == OP_ENCRYPT)
     {

+ 1 - 1
app/dht/dht.c

@@ -29,7 +29,7 @@
 
 #include "user_interface.h"
 #include "platform.h"
-#include "c_stdio.h"
+#include <stdio.h>
 #include "dht.h"
 
 #ifndef LOW

+ 1 - 1
app/driver/i2c_master.c

@@ -24,7 +24,7 @@
  * Rework of original driver: Natalia Sorokina <sonaux@gmail.com>, 2018
  */
 
-#include "../libc/c_stdlib.h"
+#include <stdlib.h>
 #include "ets_sys.h"
 #include "osapi.h"
 #include "gpio.h"

+ 4 - 4
app/driver/rotary.c

@@ -12,8 +12,8 @@
 
 #include "platform.h"
 #include "c_types.h"
-#include "../libc/c_stdlib.h"
-#include "../libc/c_stdio.h"
+#include <stdlib.h>
+#include <stdio.h>
 #include "driver/rotary.h"
 #include "user_interface.h"
 #include "task/task.h"
@@ -87,7 +87,7 @@ int rotary_close(uint32_t channel)
   rotary_clear_pin(d->phase_b_pin);
   rotary_clear_pin(d->press_pin);
 
-  c_free(d);
+  free(d);
 
   set_gpio_bits();
 
@@ -207,7 +207,7 @@ int rotary_setup(uint32_t channel, int phase_a, int phase_b, int press, task_han
     }
   }
 
-  DATA *d = (DATA *) c_zalloc(sizeof(DATA));
+  DATA *d = (DATA *) calloc(1, sizeof(DATA));
   if (!d) {
     return -1;
   }

+ 8 - 8
app/driver/switec.c

@@ -15,8 +15,8 @@
 
 #include "platform.h"
 #include "c_types.h"
-#include "../libc/c_stdlib.h"
-#include "../libc/c_stdio.h"
+#include <stdlib.h>
+#include <stdio.h>
 #include "driver/switec.h"
 #include "ets_sys.h"
 #include "os_type.h"
@@ -101,7 +101,7 @@ int switec_close(uint32_t channel)
   gpio_output_set(0, 0, 0, d->mask);
 
   data[channel] = NULL;
-  c_free(d);
+  free(d);
 
   // See if there are any other channels active
   for (channel = 0; channel < sizeof(data)/sizeof(data[0]); channel++) {
@@ -259,7 +259,7 @@ int switec_setup(uint32_t channel, int *pin, int max_deg_per_sec, task_handle_t
     }
   }
 
-  DATA *d = (DATA *) c_zalloc(sizeof(DATA));
+  DATA *d = (DATA *) calloc(1, sizeof(DATA));
   if (!d) {
     return -1;
   }
@@ -269,7 +269,7 @@ int switec_setup(uint32_t channel, int *pin, int max_deg_per_sec, task_handle_t
     // no autoreload
     if (!platform_hw_timer_init(TIMER_OWNER, FRC1_SOURCE, FALSE)) {
       // Failed to get the timer
-      c_free(d);
+      free(d);
       return -1;
     }
   }
@@ -299,12 +299,12 @@ int switec_setup(uint32_t channel, int *pin, int max_deg_per_sec, task_handle_t
 
 #ifdef SWITEC_DEBUG
   for (i = 0; i < 4; i++) {
-    c_printf("pin[%d]=%d\n", i, pin[i]);
+    printf("pin[%d]=%d\n", i, pin[i]);
   }
 
-  c_printf("Mask=0x%x\n", d->mask);
+  printf("Mask=0x%x\n", d->mask);
   for (i = 0; i < N_STATES; i++) {
-    c_printf("pinstate[%d]=0x%x\n", i, d->pinstate[i]);
+    printf("pinstate[%d]=0x%x\n", i, d->pinstate[i]);
   }
 #endif
 

+ 74 - 73
app/fatfs/myfatfs.c

@@ -1,5 +1,6 @@
-#include <c_stdlib.h>
-#include <c_string.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdbool.h>
 
 #include "vfs_int.h"
 
@@ -12,37 +13,37 @@ static FRESULT last_result = FR_OK;
 
 static const char* const volstr[FF_VOLUMES] = {FF_VOLUME_STRS};
 
-static int is_current_drive = FALSE;
+static int is_current_drive = false;
 
 
 // forward declarations
-static sint32_t myfatfs_close( const struct vfs_file *fd );
-static sint32_t myfatfs_read( const struct vfs_file *fd, void *ptr, size_t len );
-static sint32_t myfatfs_write( const struct vfs_file *fd, const void *ptr, size_t len );
-static sint32_t myfatfs_lseek( const struct vfs_file *fd, sint32_t off, int whence );
-static sint32_t myfatfs_eof( const struct vfs_file *fd );
-static sint32_t myfatfs_tell( const struct vfs_file *fd );
-static sint32_t myfatfs_flush( const struct vfs_file *fd );
+static int32_t myfatfs_close( const struct vfs_file *fd );
+static int32_t myfatfs_read( const struct vfs_file *fd, void *ptr, size_t len );
+static int32_t myfatfs_write( const struct vfs_file *fd, const void *ptr, size_t len );
+static int32_t myfatfs_lseek( const struct vfs_file *fd, int32_t off, int whence );
+static int32_t myfatfs_eof( const struct vfs_file *fd );
+static int32_t myfatfs_tell( const struct vfs_file *fd );
+static int32_t myfatfs_flush( const struct vfs_file *fd );
 static uint32_t myfatfs_fsize( const struct vfs_file *fd );
-static sint32_t myfatfs_ferrno( const struct vfs_file *fd );
+static int32_t myfatfs_ferrno( const struct vfs_file *fd );
 
-static sint32_t  myfatfs_closedir( const struct vfs_dir *dd );
-static sint32_t  myfatfs_readdir( const struct vfs_dir *dd, struct vfs_stat *buf );
+static int32_t  myfatfs_closedir( const struct vfs_dir *dd );
+static int32_t  myfatfs_readdir( const struct vfs_dir *dd, struct vfs_stat *buf );
 
 static vfs_vol  *myfatfs_mount( const char *name, int num );
 static vfs_file *myfatfs_open( const char *name, const char *mode );
 static vfs_dir  *myfatfs_opendir( const char *name );
-static sint32_t  myfatfs_stat( const char *name, struct vfs_stat *buf );
-static sint32_t  myfatfs_remove( const char *name );
-static sint32_t  myfatfs_rename( const char *oldname, const char *newname );
-static sint32_t  myfatfs_mkdir( const char *name );
-static sint32_t  myfatfs_fsinfo( uint32_t *total, uint32_t *used );
-static sint32_t  myfatfs_chdrive( const char *name );
-static sint32_t  myfatfs_chdir( const char *name );
-static sint32_t  myfatfs_errno( void );
+static int32_t  myfatfs_stat( const char *name, struct vfs_stat *buf );
+static int32_t  myfatfs_remove( const char *name );
+static int32_t  myfatfs_rename( const char *oldname, const char *newname );
+static int32_t  myfatfs_mkdir( const char *name );
+static int32_t  myfatfs_fsinfo( uint32_t *total, uint32_t *used );
+static int32_t  myfatfs_chdrive( const char *name );
+static int32_t  myfatfs_chdir( const char *name );
+static int32_t  myfatfs_errno( void );
 static void      myfatfs_clearerr( void );
 
-static sint32_t myfatfs_umount( const struct vfs_vol *vol );
+static int32_t myfatfs_umount( const struct vfs_vol *vol );
 
 
 // ---------------------------------------------------------------------------
@@ -112,12 +113,12 @@ struct myvfs_dir {
 //
 void *ff_memalloc( UINT size )
 {
-  return c_malloc( size );
+  return malloc( size );
 }
 
 void ff_memfree( void *mblock )
 {
-  c_free( mblock );
+  free( mblock );
 }
 
 // TODO
@@ -153,14 +154,14 @@ DWORD get_fattime( void )
   const struct myvfs_vol *myvol = (const struct myvfs_vol *)descr; \
   FATFS *fs = (FATFS *)&(myvol->fs);
 
-static sint32_t myfatfs_umount( const struct vfs_vol *vol )
+static int32_t myfatfs_umount( const struct vfs_vol *vol )
 {
   GET_FATFS_FS(vol);
 
   last_result = f_mount( NULL, myvol->ldrname, 0 );
 
-  c_free( myvol->ldrname );
-  c_free( (void *)vol );
+  free( myvol->ldrname );
+  free( (void *)vol );
 
   return last_result == FR_OK ? VFS_RES_OK : VFS_RES_ERR;
 }
@@ -173,19 +174,19 @@ static sint32_t myfatfs_umount( const struct vfs_vol *vol )
   const struct myvfs_file *myfd = (const struct myvfs_file *)descr; \
   FIL *fp = (FIL *)&(myfd->fp);
 
-static sint32_t myfatfs_close( const struct vfs_file *fd )
+static int32_t myfatfs_close( const struct vfs_file *fd )
 {
   GET_FIL_FP(fd)
 
   last_result = f_close( fp );
 
   // free descriptor memory
-  c_free( (void *)fd );
+  free( (void *)fd );
 
   return last_result == FR_OK ? VFS_RES_OK : VFS_RES_ERR;
 }
 
-static sint32_t myfatfs_read( const struct vfs_file *fd, void *ptr, size_t len )
+static int32_t myfatfs_read( const struct vfs_file *fd, void *ptr, size_t len )
 {
   GET_FIL_FP(fd);
   UINT act_read;
@@ -195,7 +196,7 @@ static sint32_t myfatfs_read( const struct vfs_file *fd, void *ptr, size_t len )
   return last_result == FR_OK ? act_read : VFS_RES_ERR;
 }
 
-static sint32_t myfatfs_write( const struct vfs_file *fd, const void *ptr, size_t len )
+static int32_t myfatfs_write( const struct vfs_file *fd, const void *ptr, size_t len )
 {
   GET_FIL_FP(fd);
   UINT act_written;
@@ -205,7 +206,7 @@ static sint32_t myfatfs_write( const struct vfs_file *fd, const void *ptr, size_
   return last_result == FR_OK ? act_written : VFS_RES_ERR;
 }
 
-static sint32_t myfatfs_lseek( const struct vfs_file *fd, sint32_t off, int whence )
+static int32_t myfatfs_lseek( const struct vfs_file *fd, int32_t off, int whence )
 {
   GET_FIL_FP(fd);
   FSIZE_t new_pos;
@@ -231,7 +232,7 @@ static sint32_t myfatfs_lseek( const struct vfs_file *fd, sint32_t off, int when
   return last_result == FR_OK ? new_pos : VFS_RES_ERR;
 }
 
-static sint32_t myfatfs_eof( const struct vfs_file *fd )
+static int32_t myfatfs_eof( const struct vfs_file *fd )
 {
   GET_FIL_FP(fd);
 
@@ -240,7 +241,7 @@ static sint32_t myfatfs_eof( const struct vfs_file *fd )
   return f_eof( fp );
 }
 
-static sint32_t myfatfs_tell( const struct vfs_file *fd )
+static int32_t myfatfs_tell( const struct vfs_file *fd )
 {
   GET_FIL_FP(fd);
 
@@ -249,7 +250,7 @@ static sint32_t myfatfs_tell( const struct vfs_file *fd )
   return f_tell( fp );
 }
 
-static sint32_t myfatfs_flush( const struct vfs_file *fd )
+static int32_t myfatfs_flush( const struct vfs_file *fd )
 {
   GET_FIL_FP(fd);
 
@@ -267,7 +268,7 @@ static uint32_t myfatfs_fsize( const struct vfs_file *fd )
   return f_size( fp );
 }
 
-static sint32_t myfatfs_ferrno( const struct vfs_file *fd )
+static int32_t myfatfs_ferrno( const struct vfs_file *fd )
 {
   return -last_result;
 }
@@ -280,24 +281,24 @@ static sint32_t myfatfs_ferrno( const struct vfs_file *fd )
   const struct myvfs_dir *mydd = (const struct myvfs_dir *)descr; \
   DIR *dp = (DIR *)&(mydd->dp);
 
-static sint32_t myfatfs_closedir( const struct vfs_dir *dd )
+static int32_t myfatfs_closedir( const struct vfs_dir *dd )
 {
   GET_DIR_DP(dd);
 
   last_result = f_closedir( dp );
 
   // free descriptor memory
-  c_free( (void *)dd );
+  free( (void *)dd );
 
   return last_result == FR_OK ? VFS_RES_OK : VFS_RES_ERR;
 }
 
 static void myfatfs_fill_stat( const FILINFO *fno, struct vfs_stat *buf )
 {
-  c_memset( buf, 0, sizeof( struct vfs_stat ) );
+  memset( buf, 0, sizeof( struct vfs_stat ) );
 
   // fill in supported stat entries
-  c_strncpy( buf->name, fno->fname, FS_OBJ_NAME_LEN+1 );
+  strncpy( buf->name, fno->fname, FS_OBJ_NAME_LEN+1 );
   buf->name[FS_OBJ_NAME_LEN] = '\0';
   buf->size = fno->fsize;
   buf->is_dir = fno->fattrib & AM_DIR ? 1 : 0;
@@ -316,7 +317,7 @@ static void myfatfs_fill_stat( const FILINFO *fno, struct vfs_stat *buf )
   buf->tm_valid = 1;
 }
 
-static sint32_t myfatfs_readdir( const struct vfs_dir *dd, struct vfs_stat *buf )
+static int32_t myfatfs_readdir( const struct vfs_dir *dd, struct vfs_stat *buf )
 {
   GET_DIR_DP(dd);
   FILINFO fno;
@@ -340,19 +341,19 @@ static sint32_t myfatfs_readdir( const struct vfs_dir *dd, struct vfs_stat *buf
 static vfs_vol *myfatfs_mount( const char *name, int num )
 {
   struct myvfs_vol *vol;
-  const size_t len = c_strlen( name );
+  const size_t len = strlen( name );
 
   // num argument specifies the physical driver = SS/CS pin number for this sd card
   if (num >= 0) {
     for (int i = 0; i < NUM_LOGICAL_DRIVES; i++) {
-      if (0 == c_strncmp( name, volstr[i], c_strlen( volstr[i] ) )) {
+      if (0 == strncmp( name, volstr[i], strlen( volstr[i] ) )) {
         VolToPart[i].pd = num;
       }
     }
   }
 
-  if (vol = c_malloc( sizeof( struct myvfs_vol ) )) {
-    if (vol->ldrname = c_strdup( name )) {
+  if (vol = malloc( sizeof( struct myvfs_vol ) )) {
+    if (vol->ldrname = strdup( name )) {
       if (FR_OK == (last_result = f_mount( &(vol->fs), name, 1 ))) {
 	vol->vfs_vol.fs_type = VFS_FS_FATFS;
 	vol->vfs_vol.fns     = &myfatfs_vol_fns;
@@ -362,29 +363,29 @@ static vfs_vol *myfatfs_mount( const char *name, int num )
   }
 
   if (vol) {
-    if (vol->ldrname) c_free( vol->ldrname );
-    c_free( vol );
+    if (vol->ldrname) free( vol->ldrname );
+    free( vol );
   }
   return NULL;
 }
 
 static BYTE myfatfs_mode2flag( const char *mode )
 {
-  if (c_strlen( mode ) == 1) {
-    if(c_strcmp( mode, "w" ) == 0)
+  if (strlen( mode ) == 1) {
+    if(strcmp( mode, "w" ) == 0)
       return FA_WRITE | FA_CREATE_ALWAYS;
-    else if (c_strcmp( mode, "r" ) == 0)
+    else if (strcmp( mode, "r" ) == 0)
       return FA_READ | FA_OPEN_EXISTING;
-    else if (c_strcmp( mode, "a" ) == 0)
+    else if (strcmp( mode, "a" ) == 0)
       return FA_WRITE | FA_OPEN_ALWAYS;
     else
       return FA_READ | FA_OPEN_EXISTING;
-  } else if (c_strlen( mode ) == 2) {
-    if (c_strcmp( mode, "r+" ) == 0)
+  } else if (strlen( mode ) == 2) {
+    if (strcmp( mode, "r+" ) == 0)
       return FA_READ | FA_WRITE | FA_OPEN_EXISTING;
-    else if (c_strcmp( mode, "w+" ) == 0)
+    else if (strcmp( mode, "w+" ) == 0)
       return FA_READ | FA_WRITE | FA_CREATE_ALWAYS;
-    else if (c_strcmp( mode, "a+" ) ==0 )
+    else if (strcmp( mode, "a+" ) ==0 )
       return FA_READ | FA_WRITE | FA_OPEN_ALWAYS;
     else
       return FA_READ | FA_OPEN_EXISTING;
@@ -398,7 +399,7 @@ static vfs_file *myfatfs_open( const char *name, const char *mode )
   struct myvfs_file *fd;
   const BYTE flags = myfatfs_mode2flag( mode );
 
-  if (fd = c_malloc( sizeof( struct myvfs_file ) )) {
+  if (fd = malloc( sizeof( struct myvfs_file ) )) {
     if (FR_OK == (last_result = f_open( &(fd->fp), name, flags ))) {
       // skip to end of file for append mode
       if (flags & FA_OPEN_ALWAYS)
@@ -408,7 +409,7 @@ static vfs_file *myfatfs_open( const char *name, const char *mode )
       fd->vfs_file.fns     = &myfatfs_file_fns;
       return (vfs_file *)fd;
     } else {
-      c_free( fd );
+      free( fd );
     }
   }
 
@@ -419,20 +420,20 @@ static vfs_dir *myfatfs_opendir( const char *name )
 {
   struct myvfs_dir *dd;
 
-  if (dd = c_malloc( sizeof( struct myvfs_dir ) )) {
+  if (dd = malloc( sizeof( struct myvfs_dir ) )) {
     if (FR_OK == (last_result = f_opendir( &(dd->dp), name ))) {
       dd->vfs_dir.fs_type = VFS_FS_FATFS;
       dd->vfs_dir.fns     = &myfatfs_dir_fns;
       return (vfs_dir *)dd;
     } else {
-      c_free( dd );
+      free( dd );
     }
   }
 
   return NULL;
 }
 
-static sint32_t myfatfs_stat( const char *name, struct vfs_stat *buf )
+static int32_t myfatfs_stat( const char *name, struct vfs_stat *buf )
 {
   FILINFO fno;
 
@@ -445,28 +446,28 @@ static sint32_t myfatfs_stat( const char *name, struct vfs_stat *buf )
   }
 }
 
-static sint32_t myfatfs_remove( const char *name )
+static int32_t myfatfs_remove( const char *name )
 {
   last_result = f_unlink( name );
 
   return last_result == FR_OK ? VFS_RES_OK : VFS_RES_ERR;
 }
 
-static sint32_t myfatfs_rename( const char *oldname, const char *newname )
+static int32_t myfatfs_rename( const char *oldname, const char *newname )
 {
   last_result = f_rename( oldname, newname );
 
   return last_result == FR_OK ? VFS_RES_OK : VFS_RES_ERR;
 }
 
-static sint32_t myfatfs_mkdir( const char *name )
+static int32_t myfatfs_mkdir( const char *name )
 {
   last_result = f_mkdir( name );
 
   return last_result == FR_OK ? VFS_RES_OK : VFS_RES_ERR;
 }
 
-static sint32_t  myfatfs_fsinfo( uint32_t *total, uint32_t *used )
+static int32_t  myfatfs_fsinfo( uint32_t *total, uint32_t *used )
 {
   DWORD free_clusters;
   FATFS *fatfs;
@@ -480,21 +481,21 @@ static sint32_t  myfatfs_fsinfo( uint32_t *total, uint32_t *used )
   return last_result == FR_OK ? VFS_RES_OK : VFS_RES_ERR;
 }
 
-static sint32_t myfatfs_chdrive( const char *name )
+static int32_t myfatfs_chdrive( const char *name )
 {
   last_result = f_chdrive( name );
 
   return last_result == FR_OK ? VFS_RES_OK : VFS_RES_ERR;
 }
 
-static sint32_t myfatfs_chdir( const char *name )
+static int32_t myfatfs_chdir( const char *name )
 {
   last_result = f_chdir( name );
 
   return last_result == FR_OK ? VFS_RES_OK : VFS_RES_ERR;
 }
 
-static sint32_t myfatfs_errno( void )
+static int32_t myfatfs_errno( void )
 {
   return -last_result;
 }
@@ -515,10 +516,10 @@ vfs_fs_fns *myfatfs_realm( const char *inname, char **outname, int set_current_d
 
     // logical drive is specified, check if it's one of ours
     for (int i = 0; i < FF_VOLUMES; i++) {
-      size_t volstr_len = c_strlen( volstr[i] );
-      if (0 == c_strncmp( &(inname[1]), volstr[i], volstr_len )) {
-        oname = c_strdup( inname );
-        c_strcpy( oname, volstr[i] );
+      size_t volstr_len = strlen( volstr[i] );
+      if (0 == strncmp( &(inname[1]), volstr[i], volstr_len )) {
+        oname = strdup( inname );
+        strcpy( oname, volstr[i] );
         oname[volstr_len] = ':';
         *outname = oname;
 
@@ -529,11 +530,11 @@ vfs_fs_fns *myfatfs_realm( const char *inname, char **outname, int set_current_d
   } else {
     // no logical drive in patchspec, are we current drive?
     if (is_current_drive) {
-      *outname = c_strdup( inname );
+      *outname = strdup( inname );
       return &myfatfs_fs_fns;
     }
   }
 
-  if (set_current_drive) is_current_drive = FALSE;
+  if (set_current_drive) is_current_drive = false;
   return NULL;
 }

+ 1 - 1
app/http/httpclient.c

@@ -13,7 +13,7 @@
  */
 
 #include "osapi.h"
-#include "../libc/c_stdio.h"
+#include <stdio.h>
 #include "user_interface.h"
 #include "espconn.h"
 #include "mem.h"

+ 1 - 1
app/include/pm/pmSleep.h

@@ -6,7 +6,7 @@
 #include "gpio.h"
 #include "platform.h"
 #include "task/task.h"
-#include "c_string.h"
+#include <string.h>
 
 #if defined(DEVELOP_VERSION)
 #define PMSLEEP_DEBUG

+ 5 - 0
app/include/user_config.h

@@ -255,6 +255,11 @@ extern void luaL_dbgbreak(void);
 #define COAP_DEBUG
 #endif /* DEVELOP_VERSION */
 
+
+#if !defined(LUA_CROSS_COMPILER) && !defined(dbg_printf)
+extern void dbg_printf(const char *fmt, ...);
+#endif
+
 #ifdef NODE_DEBUG
 #define NODE_DBG dbg_printf
 #else

+ 4 - 2
app/include/user_mbedtls.h

@@ -274,8 +274,10 @@
 //#define MBEDTLS_MEMORY_ALIGN_MULTIPLE      4 /**< Align on multiples of this value */
 
 //#define MBEDTLS_PLATFORM_STD_MEM_HDR   <stdlib.h> /**< Header to include if MBEDTLS_PLATFORM_NO_STD_FUNCTIONS is defined. Don't define if no header is needed. */
-#define MBEDTLS_PLATFORM_STD_CALLOC        pvPortCalloc /**< Default allocator to use, can be undefined */
-#define MBEDTLS_PLATFORM_STD_FREE            vPortFree /**< Default free to use, can be undefined */
+extern void *mbedtls_calloc_wrap(size_t n, size_t sz);
+#define MBEDTLS_PLATFORM_STD_CALLOC        mbedtls_calloc_wrap /**< Default allocator to use, can be undefined */
+extern void mbedtls_free_wrap(void *p);
+#define MBEDTLS_PLATFORM_STD_FREE            mbedtls_free_wrap /**< Default free to use, can be undefined */
 //#define MBEDTLS_PLATFORM_STD_EXIT            exit /**< Default exit to use, can be undefined */
 //#define MBEDTLS_PLATFORM_STD_TIME            time /**< Default time to use, can be undefined. MBEDTLS_HAVE_TIME must be enabled */
 //#define MBEDTLS_PLATFORM_STD_FPRINTF      fprintf /**< Default fprintf to use, can be undefined */

+ 0 - 16
app/libc/c_ctype.c

@@ -1,16 +0,0 @@
-#include "c_ctype.h"
-#include "c_types.h"
-
-// int isalnum(int c){}
-// int isalpha(int c){}
-// int iscntrl(int c){}
-// int isdigit(int c){}
-// // int isgraph(int c){}
-// int islower(int c){}
-// int isprint(int c){}
-// int ispunct(int c){}
-// int isspace(int c){}
-// int isupper(int c){}
-// int isxdigit(int c){}
-// int tolower(int c){}
-// int toupper(int c){}

+ 0 - 42
app/libc/c_ctype.h

@@ -1,42 +0,0 @@
-#ifndef _C_CTYPE_H_
-#define _C_CTYPE_H_
-
-#if 0
-int isalnum(int);
-int isalpha(int);
-int iscntrl(int);
-int isdigit(int);
-// int isgraph(int);
-int islower(int);
-int isprint(int);
-int ispunct(int);
-int isspace(int);
-int isupper(int);
-int isxdigit(int);
-int tolower(int);
-int toupper(int);
-
-#if !defined(__STRICT_ANSI__) || defined(__cplusplus) || __STDC_VERSION__ >= 199901L
-// int isblank(int);
-#endif
-
-#ifndef __STRICT_ANSI__
-// int isascii(int);
-// int toascii(int);
-#define _tolower(__c) ((unsigned char)(__c) - 'A' + 'a')
-#define _toupper(__c) ((unsigned char)(__c) - 'a' + 'A')
-#endif
-
-#define	_U	01
-#define	_L	02
-#define	_N	04
-#define	_S	010
-#define _P	020
-#define _C	040
-#define _X	0100
-#define	_B	0200
-
-/* For C++ backward-compatibility only.  */
-// extern	char	_ctype_[];
-#endif
-#endif /* _C_CTYPE_H_ */

+ 0 - 19
app/libc/c_errno.h

@@ -1,19 +0,0 @@
-#ifndef __c_errno_h
-#define __c_errno_h
-
-#include <errno.h>
-// #ifndef errno
-// extern int errno;
-// #endif
-
-// #define EDOM    1
-// #define ERANGE 	2
-// #define EILSEQ  4
-// #define ESIGNUM 3
-// #define EINVAL  5
-// #define ENOMEM  6
-
-#endif
-
-/* end of c_errno.h */
-

+ 0 - 9
app/libc/c_fcntl.h

@@ -1,9 +0,0 @@
-#ifndef __c_fcntl_h
-#define __c_fcntl_h
-
-#include <fcntl.h>
-
-#endif
-
-/* end of c_fcntl.h */
-

+ 0 - 58
app/libc/c_limits.h

@@ -1,58 +0,0 @@
-#ifndef __c_limits_h
-#define __c_limits_h
-
-#include <limits.h>
-#if 0
-#define CHAR_BIT 8
-    /* max number of bits for smallest object that is not a bit-field (byte) */
-#define SCHAR_MIN (-128)
-    /* mimimum value for an object of type signed char */
-#define SCHAR_MAX 127
-    /* maximum value for an object of type signed char */
-#define UCHAR_MAX 255
-    /* maximum value for an object of type unsigned char */
-#ifdef __FEATURE_SIGNED_CHAR
-  #define CHAR_MIN (-128)
-      /* minimum value for an object of type char */
-  #define CHAR_MAX 127
-      /* maximum value for an object of type char */
-#else
-  #define CHAR_MIN 0
-      /* minimum value for an object of type char */
-  #define CHAR_MAX 255
-      /* maximum value for an object of type char */
-#endif
-
-#define SHRT_MIN  (-0x8000)
-    /* minimum value for an object of type short int */
-#define SHRT_MAX  0x7fff
-    /* maximum value for an object of type short int */
-#define USHRT_MAX 65535
-    /* maximum value for an object of type unsigned short int */
-#define INT_MIN   (~0x7fffffff)  /* -2147483648 and 0x80000000 are unsigned */
-    /* minimum value for an object of type int */
-#define INT_MAX   0x7fffffff
-    /* maximum value for an object of type int */
-#define UINT_MAX  0xffffffffU
-    /* maximum value for an object of type unsigned int */
-#define LONG_MIN  (~0x7fffffffL)
-    /* minimum value for an object of type long int */
-#define LONG_MAX  0x7fffffffL
-    /* maximum value for an object of type long int */
-#define ULONG_MAX 0xffffffffUL
-    /* maximum value for an object of type unsigned long int */
-#if !defined(__STRICT_ANSI__) || (defined(__STDC_VERSION__) && 199901L <= __STDC_VERSION__)
-  #define LLONG_MIN  (~0x7fffffffffffffffLL)
-      /* minimum value for an object of type long long int */
-  #define LLONG_MAX    0x7fffffffffffffffLL
-      /* maximum value for an object of type long long int */
-  #define ULLONG_MAX   0xffffffffffffffffULL
-      /* maximum value for an object of type unsigned long int */
-#endif
-
-#endif
-
-#endif
-
-/* end of c_limits.h */
-

+ 0 - 62
app/libc/c_locale.h

@@ -1,62 +0,0 @@
-/*
-	c_locale.h
-	Values appropriate for the formatting of monetary and other
-	numberic quantities.
-*/
-
-#ifndef _C_LOCALE_H_
-#define _C_LOCALE_H_
-
-#include <locale.h>
-
-#if 0
-#ifndef NULL
-#define NULL    0
-#endif
-
-#define LC_ALL	    0
-#define LC_COLLATE  1
-#define LC_CTYPE    2
-#define LC_MONETARY 3
-#define LC_NUMERIC  4
-#define LC_TIME     5
-#define LC_MESSAGES 6
-
-struct lconv
-{
-  char *decimal_point;
-  char *thousands_sep;
-  char *grouping;
-  char *int_curr_symbol;
-  char *currency_symbol;
-  char *mon_decimal_point;
-  char *mon_thousands_sep;
-  char *mon_grouping;
-  char *positive_sign;
-  char *negative_sign;
-  char int_frac_digits;
-  char frac_digits;
-  char p_cs_precedes;
-  char p_sep_by_space;
-  char n_cs_precedes;
-  char n_sep_by_space;
-  char p_sign_posn;
-  char n_sign_posn;
-  char int_n_cs_precedes;
-  char int_n_sep_by_space;
-  char int_n_sign_posn;
-  char int_p_cs_precedes;
-  char int_p_sep_by_space;
-  char int_p_sign_posn;
-};
-
-#ifndef _REENT_ONLY
-// char *setlocale(int category, const char *locale);
-struct lconv *localeconv(void);
-#endif
-
-// struct _reent;
-// char *_setlocale_r(struct _reent *, int category, const char *locale);
-// struct lconv *_localeconv_r(struct _reent *);
-#endif
-#endif /* _C_LOCALE_H_ */

+ 0 - 62
app/libc/c_math.h

@@ -1,62 +0,0 @@
-#ifndef  _C_MATH_H_
-#define  _C_MATH_H_
-#include <math.h>
-
-double floor(double);
-double pow(double, double);
-
-#if 0
-#ifndef HUGE_VAL
-  #define HUGE_VAL (1.0e99)
- #endif
-
- #ifndef HUGE_VALF
-  #define HUGE_VALF (1.0e999999999F)
- #endif
-
- #if !defined(HUGE_VALL)  &&  defined(_HAVE_LONG_DOUBLE)
-  #define HUGE_VALL (1.0e999999999L)
- #endif
-
- #if !defined(INFINITY)
-  #define INFINITY (HUGE_VALF)
- #endif
-
-
-/* Reentrant ANSI C functions.  */
-
-#ifndef __math_68881
-// double atan(double);
-// double cos(double);
-// double sin(double);
-// double tan(double);
-// double tanh(double);
-// double frexp(double, int *);
-// double modf(double, double *);
-// double ceil(double);
-// double fabs(double);
-// double floor(double);
-#endif /* ! defined (__math_68881) */
-
-/* Non reentrant ANSI C functions.  */
-
-#ifndef _REENT_ONLY
-#ifndef __math_68881
-// double acos(double);
-// double asin(double);
-// double atan2(double, double);
-// double cosh(double);
-// double sinh(double);
-// double exp(double);
-// double ldexp(double, int);
-// double log(double);
-// double log10(double);
-// double pow(double, double);
-// double sqrt(double);
-// double fmod(double, double);
-#endif /* ! defined (__math_68881) */
-#endif /* ! defined (_REENT_ONLY) */
-
-#endif
-
-#endif /* _MATH_H_ */

+ 0 - 6
app/libc/c_signal.h

@@ -1,6 +0,0 @@
-#ifndef _C_SIGNAL_H_
-#define _C_SIGNAL_H_
-
-#include <signal.h>
-
-#endif /* _C_SIGNAL_H_ */

+ 0 - 22
app/libc/c_stdarg.h

@@ -1,22 +0,0 @@
-#ifndef __c_stdarg_h
-#define __c_stdarg_h
-
-#if defined(__GNUC__)
-
-#include <stdarg.h>
-
-#else
-
-typedef char * va_list;
-
-#define _INTSIZEOF(n)   ((sizeof(n) + sizeof(int) - 1) & ~(sizeof(int) - 1))
-
-#define va_start(ap,v)  (ap = (va_list)&v + _INTSIZEOF(v))
-#define va_arg(ap,t)    (*(t *)((ap += _INTSIZEOF(t)) - _INTSIZEOF(t)))
-#define va_end(ap)      (ap = (va_list)0)
-
-#endif
-
-#endif
-
-/* end of c_stdarg.h */

+ 0 - 23
app/libc/c_stddef.h

@@ -1,23 +0,0 @@
-#ifndef __c_stddef_h
-#define __c_stddef_h
-
-typedef signed int ptrdiff_t;
-
-#if !defined(offsetof)
-#define offsetof(s, m)   (size_t)&(((s *)0)->m)
-#endif
-
-#if !defined(__size_t)
-  #define __size_t 1
-  typedef unsigned int size_t;   /* others (e.g. <stdio.h>) also define */
-   /* the unsigned integral type of the result of the sizeof operator. */
-#endif
-
-#undef NULL  /* others (e.g. <stdio.h>) also define */
-#define NULL 0
-   /* null pointer constant. */
-
-#endif
-
-/* end of c_stddef.h */
-

+ 0 - 273
app/libc/c_stdint.h

@@ -1,273 +0,0 @@
-#ifndef __c_stdint_h
-#define __c_stdint_h
-
-#include "c_types.h"
-#if 0
-/*
- * Depending on compiler version __int64 or __INT64_TYPE__ should be defined.
- */
-#ifndef __int64
-  #ifdef __INT64_TYPE__
-    #define __int64 __INT64_TYPE__
-  #else
-    #define __int64 long long
-  #endif
-  /* On some architectures neither of these may be defined - if so, fall
-     through and error out if used. */
-#endif
-
-  #ifndef __STDINT_DECLS
-  #define __STDINT_DECLS
-
-    #undef __CLIBNS
-
-    #ifdef __cplusplus
-      namespace std {
-          #define __CLIBNS std::
-          extern "C" {
-    #else
-      #define __CLIBNS
-    #endif  /* __cplusplus */
-
-
-/*
- * 'signed' is redundant below, except for 'signed char' and if
- * the typedef is used to declare a bitfield.
- * '__int64' is used instead of 'long long' so that this header
- * can be used in --strict mode.
- */
-
-    /* 7.18.1.1 */
-
-    /* exact-width signed integer types */
-typedef   signed          char int8_t;
-typedef   signed short     int int16_t;
-typedef   signed           int int32_t;
-typedef   signed       __int64 int64_t;
-
-    /* exact-width unsigned integer types */
-typedef unsigned          char uint8_t;
-typedef unsigned short     int uint16_t;
-typedef unsigned           int uint32_t;
-typedef unsigned       __int64 uint64_t;
-
-    /* 7.18.1.2 */
-
-    /* smallest type of at least n bits */
-    /* minimum-width signed integer types */
-typedef   signed          char int_least8_t;
-typedef   signed short     int int_least16_t;
-typedef   signed           int int_least32_t;
-typedef   signed       __int64 int_least64_t;
-
-    /* minimum-width unsigned integer types */
-typedef unsigned          char uint_least8_t;
-typedef unsigned short     int uint_least16_t;
-typedef unsigned           int uint_least32_t;
-typedef unsigned       __int64 uint_least64_t;
-
-    /* 7.18.1.3 */
-
-    /* fastest minimum-width signed integer types */
-typedef   signed           int int_fast8_t;
-typedef   signed           int int_fast16_t;
-typedef   signed           int int_fast32_t;
-typedef   signed       __int64 int_fast64_t;
-
-    /* fastest minimum-width unsigned integer types */
-typedef unsigned           int uint_fast8_t;
-typedef unsigned           int uint_fast16_t;
-typedef unsigned           int uint_fast32_t;
-typedef unsigned       __int64 uint_fast64_t;
-
-    /* 7.18.1.4 integer types capable of holding object pointers */
-typedef   signed           int intptr_t;
-typedef unsigned           int uintptr_t;
-
-    /* 7.18.1.5 greatest-width integer types */
-typedef   signed       __int64 intmax_t;
-typedef unsigned       __int64 uintmax_t;
-
-
-#if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS)
-
-    /* 7.18.2.1 */
-
-    /* minimum values of exact-width signed integer types */
-#define INT8_MIN                   -128
-#define INT16_MIN                -32768
-#define INT32_MIN          (~0x7fffffff)   /* -2147483648 is unsigned */
-#define INT64_MIN  __ESCAPE__(~0x7fffffffffffffffll) /* -9223372036854775808 is unsigned */
-
-    /* maximum values of exact-width signed integer types */
-#define INT8_MAX                    127
-#define INT16_MAX                 32767
-#define INT32_MAX            2147483647
-#define INT64_MAX  __ESCAPE__(9223372036854775807ll)
-
-    /* maximum values of exact-width unsigned integer types */
-#define UINT8_MAX                   255
-#define UINT16_MAX                65535
-#define UINT32_MAX           4294967295u
-#define UINT64_MAX __ESCAPE__(18446744073709551615ull)
-
-    /* 7.18.2.2 */
-
-    /* minimum values of minimum-width signed integer types */
-#define INT_LEAST8_MIN                   -128
-#define INT_LEAST16_MIN                -32768
-#define INT_LEAST32_MIN          (~0x7fffffff)
-#define INT_LEAST64_MIN  __ESCAPE__(~0x7fffffffffffffffll)
-
-    /* maximum values of minimum-width signed integer types */
-#define INT_LEAST8_MAX                    127
-#define INT_LEAST16_MAX                 32767
-#define INT_LEAST32_MAX            2147483647
-#define INT_LEAST64_MAX  __ESCAPE__(9223372036854775807ll)
-
-    /* maximum values of minimum-width unsigned integer types */
-#define UINT_LEAST8_MAX                   255
-#define UINT_LEAST16_MAX                65535
-#define UINT_LEAST32_MAX           4294967295u
-#define UINT_LEAST64_MAX __ESCAPE__(18446744073709551615ull)
-
-    /* 7.18.2.3 */
-
-    /* minimum values of fastest minimum-width signed integer types */
-#define INT_FAST8_MIN           (~0x7fffffff)
-#define INT_FAST16_MIN          (~0x7fffffff)
-#define INT_FAST32_MIN          (~0x7fffffff)
-#define INT_FAST64_MIN  __ESCAPE__(~0x7fffffffffffffffll)
-
-    /* maximum values of fastest minimum-width signed integer types */
-#define INT_FAST8_MAX             2147483647
-#define INT_FAST16_MAX            2147483647
-#define INT_FAST32_MAX            2147483647
-#define INT_FAST64_MAX  __ESCAPE__(9223372036854775807ll)
-
-    /* maximum values of fastest minimum-width unsigned integer types */
-#define UINT_FAST8_MAX            4294967295u
-#define UINT_FAST16_MAX           4294967295u
-#define UINT_FAST32_MAX           4294967295u
-#define UINT_FAST64_MAX __ESCAPE__(18446744073709551615ull)
-
-    /* 7.18.2.4 */
-
-    /* minimum value of pointer-holding signed integer type */
-#define INTPTR_MIN (~0x7fffffff)
-
-    /* maximum value of pointer-holding signed integer type */
-#define INTPTR_MAX   2147483647
-
-    /* maximum value of pointer-holding unsigned integer type */
-#define UINTPTR_MAX  4294967295u
-
-    /* 7.18.2.5 */
-
-    /* minimum value of greatest-width signed integer type */
-#define INTMAX_MIN  __ESCAPE__(~0x7fffffffffffffffll)
-
-    /* maximum value of greatest-width signed integer type */
-#define INTMAX_MAX  __ESCAPE__(9223372036854775807ll)
-
-    /* maximum value of greatest-width unsigned integer type */
-#define UINTMAX_MAX __ESCAPE__(18446744073709551615ull)
-
-    /* 7.18.3 */
-
-    /* limits of ptrdiff_t */
-#define PTRDIFF_MIN (~0x7fffffff)
-#define PTRDIFF_MAX   2147483647
-
-    /* limits of sig_atomic_t */
-#define SIG_ATOMIC_MIN (~0x7fffffff)
-#define SIG_ATOMIC_MAX   2147483647
-
-    /* limit of size_t */
-#define SIZE_MAX 4294967295u
-
-    /* limits of wchar_t */
-    /* NB we have to undef and redef because they're defined in both
-     * stdint.h and wchar.h */
-#undef WCHAR_MIN
-#undef WCHAR_MAX
-
-#if defined(__WCHAR32) || (defined(__ARM_SIZEOF_WCHAR_T) && __ARM_SIZEOF_WCHAR_T == 4)
-  #define WCHAR_MIN   0
-  #define WCHAR_MAX   0xffffffffU
-#else
-  #define WCHAR_MIN   0
-  #define WCHAR_MAX   65535
-#endif
-
-    /* limits of wint_t */
-#define WINT_MIN (~0x7fffffff)
-#define WINT_MAX 2147483647
-
-#endif /* __STDC_LIMIT_MACROS */
-
-#if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS)
-
-    /* 7.18.4.1 macros for minimum-width integer constants */
-#define INT8_C(x)   (x)
-#define INT16_C(x)  (x)
-#define INT32_C(x)  (x)
-#define INT64_C(x)  __ESCAPE__(x ## ll)
-
-#define UINT8_C(x)  (x ## u)
-#define UINT16_C(x) (x ## u)
-#define UINT32_C(x) (x ## u)
-#define UINT64_C(x) __ESCAPE__(x ## ull)
-
-    /* 7.18.4.2 macros for greatest-width integer constants */
-#define INTMAX_C(x)  __ESCAPE__(x ## ll)
-#define UINTMAX_C(x) __ESCAPE__(x ## ull)
-
-#endif /* __STDC_CONSTANT_MACROS */
-
-    #ifdef __cplusplus
-         }  /* extern "C" */
-      }  /* namespace std */
-    #endif /* __cplusplus */
-  #endif /* __STDINT_DECLS */
-
-  #ifdef __cplusplus
-    #ifndef __STDINT_NO_EXPORTS
-      using ::std::int8_t;
-      using ::std::int16_t;
-      using ::std::int32_t;
-      using ::std::int64_t;
-      using ::std::uint8_t;
-      using ::std::uint16_t;
-      using ::std::uint32_t;
-      using ::std::uint64_t;
-      using ::std::int_least8_t;
-      using ::std::int_least16_t;
-      using ::std::int_least32_t;
-      using ::std::int_least64_t;
-      using ::std::uint_least8_t;
-      using ::std::uint_least16_t;
-      using ::std::uint_least32_t;
-      using ::std::uint_least64_t;
-      using ::std::int_fast8_t;
-      using ::std::int_fast16_t;
-      using ::std::int_fast32_t;
-      using ::std::int_fast64_t;
-      using ::std::uint_fast8_t;
-      using ::std::uint_fast16_t;
-      using ::std::uint_fast32_t;
-      using ::std::uint_fast64_t;
-      using ::std::intptr_t;
-      using ::std::uintptr_t;
-      using ::std::intmax_t;
-      using ::std::uintmax_t;
-    #endif
-  #endif /* __cplusplus */
-#endif
-
-#endif /* __c_stdint_h */
-
-/* end of c_stdint.h */
-
-
-

+ 0 - 105
app/libc/c_stdio.h

@@ -1,105 +0,0 @@
-#ifndef _C_STDIO_H_
-#define _C_STDIO_H_
-
-#define __need_size_t
-
-#include "c_stddef.h"
-#include "osapi.h"
-// #include "driver/uart.h"
-
-// #define __need___va_list
-//#include "c_stdarg.h"
-
-//struct __sFILE{
-//  int	_r;		/* read space left for getc() */
-//  int	_w;		/* write space left for putc() */
-//};
-// typedef struct __sFILE   __FILE;
-// typedef __FILE FILE;
-
-extern int c_stdin;
-extern int c_stdout;
-extern int c_stderr;
-
-// #define	_IOFBF	0		/* setvbuf should set fully buffered */
-// #define	_IOLBF	1		/* setvbuf should set line buffered */
-// #define	_IONBF	2		/* setvbuf should set unbuffered */
-
-// #ifndef NULL
-// #define	NULL	0
-// #endif
-
-#define	EOF	(-1)
-
-#ifdef __BUFSIZ__
-#define   BUFSIZ         __BUFSIZ__
-#else
-#define   BUFSIZ         1024
-#endif
-
-#ifndef SEEK_SET
-#define	SEEK_SET	0	/* set file offset to offset */
-#endif
-#ifndef SEEK_CUR
-#define	SEEK_CUR	1	/* set file offset to current plus offset */
-#endif
-#ifndef SEEK_END
-#define	SEEK_END	2	/* set file offset to EOF plus offset */
-#endif
-
-// #define c_malloc os_malloc
-// #define c_zalloc os_zalloc
-// #define c_free os_free
-
-extern void output_redirect(const char *str);
-#define c_puts output_redirect
-
-// #define c_printf os_printf
-// int	c_printf(const char *c, ...);
-#if defined( LUA_NUMBER_INTEGRAL )
-#define c_sprintf os_sprintf
-#else
-#include "c_stdarg.h"
-int c_sprintf(char* s,const char *fmt, ...);
-#endif
-
-extern void dbg_printf(const char *fmt, ...) __attribute__ ((format (printf, 1, 2)));
-
-#define c_vsprintf ets_vsprintf
-#define c_printf(...) do {					\
-	unsigned char __print_buf[BUFSIZ];		\
-	c_sprintf(__print_buf, __VA_ARGS__);	\
-	c_puts(__print_buf);					\
-} while(0)
-
-// #define c_getc ets_getc
-// #define c_getchar ets_getc
-// note: contact esp to ensure the real getchar function..
-
-// FILE *c_fopen(const char *_name, const char *_type);
-// FILE *c_freopen(const char *, const char *, FILE *);
-// FILE *c_tmpfile(void);
-
-// int	c_putchar(int);
-// int	c_printf(const char *, ...);
-// int  c_sprintf(char *, const char *, ...);
-// int	c_getc(FILE *);
-
-// int	c_ungetc(int, FILE *);
-
-// int	c_fprintf(FILE *, const char *, ...);
-// int	c_fscanf(FILE *, const char *, ...);
-// int	c_fclose(FILE *);
-// int	c_fflush(FILE *);
-// int	c_setvbuf(FILE *, char *, int, size_t);
-// void c_clearerr(FILE *);
-// int	c_fseek(FILE *, long, int);
-// long c_ftell( FILE *);
-// int	c_fputs(const char *, FILE *);
-// char *c_fgets(char *, int, FILE *);
-// size_t c_fread(void *, size_t _size, size_t _n, FILE *);
-// size_t c_fwrite(const void * , size_t _size, size_t _n, FILE *);
-// int	c_feof(FILE *);
-// int	c_ferror(FILE *);
-
-#endif /* _C_STDIO_H_ */

+ 0 - 64
app/libc/c_stdlib.h

@@ -1,64 +0,0 @@
-/*
- * c_stdlib.h
- *
- * Definitions for common types, variables, and functions.
- */
-
-#ifndef _C_STDLIB_H_
-#define _C_STDLIB_H_
-
-#include "c_stddef.h"
-#include "mem.h"
-
-#include <stdlib.h>
-
-#define EXIT_FAILURE 1
-#define EXIT_SUCCESS 0
-
-#define __INT_MAX__ 2147483647
-#undef __RAND_MAX
-#if __INT_MAX__ == 32767
-#define __RAND_MAX 32767
-#else
-#define __RAND_MAX 0x7fffffff
-#endif
-#define RAND_MAX __RAND_MAX
-
-#ifndef mem_realloc
-#define mem_realloc pvPortRealloc
-#endif
-#ifndef os_realloc
-#define os_realloc(p, s) mem_realloc((p), (s))
-#endif
-
-#define c_free os_free
-#define c_malloc os_malloc
-#define c_zalloc os_zalloc
-#define c_realloc os_realloc
-
-#define c_abs	abs
-#define c_atoi	atoi
-//#define c_strtod	strtod
-#define c_strtol	strtol
-#define c_strtoul	strtoul
-
-// int c_abs(int);
-
-// void c_exit(int);
-
-//const char *c_getenv(const char *__string);
-
-// void *c_malloc(size_t __size);
-// void *c_zalloc(size_t __size);
-// void c_free(void *);
-
-// int	c_rand(void);
-// void c_srand(unsigned int __seed);
-
-// int	c_atoi(const char *__nptr);
-double	c_strtod(const char *__n, char **__end_PTR);
-// // long	c_strtol(const char *__n, char **__end_PTR, int __base);
-// unsigned long c_strtoul(const char *__n, char **__end_PTR, int __base);
-// // long long c_strtoll(const char *__n, char **__end_PTR, int __base);
-
-#endif /* _C_STDLIB_H_ */

+ 0 - 129
app/libc/c_string.c

@@ -1,129 +0,0 @@
-#include "c_string.h"
-#include "c_stdlib.h"
-
-// const char *c_strstr(const char * __s1, const char * __s2){
-// }
-
-// char *c_strncat(char * s1, const char * s2, size_t n){
-// }
-
-// size_t c_strcspn(const char * s1, const char * s2){
-// }
-
-// const char *c_strpbrk(const char * s1, const char * s2){
-// }
-
-// int c_strcoll(const char * s1, const char * s2){
-// }
-//
-char *c_strdup(const char *c) {
-  int len = os_strlen(c) + 1;
-  char *ret = os_malloc(len);
-  if (ret) {
-    memcpy(ret, c, len);
-  }
-  return ret;
-}
-
-/*	$OpenBSD: strlcpy.c,v 1.8 2003/06/17 21:56:24 millert Exp $	*/
-
-/*
- * Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-/*
- * Copy src to string dst of size siz.  At most siz-1 characters
- * will be copied.  Always NUL terminates (unless siz == 0).
- * Returns strlen(src); if retval >= siz, truncation occurred.
- */
-size_t
-c_strlcpy(char *dst, const char *src, size_t siz)
-{
-	register char *d = dst;
-	register const char *s = src;
-	register size_t n = siz;
-
-	/* Copy as many bytes as will fit */
-	if (n != 0 && --n != 0) {
-		do {
-			if ((*d++ = *s++) == 0)
-				break;
-		} while (--n != 0);
-	}
-
-	/* Not enough room in dst, add NUL and traverse rest of src */
-	if (n == 0) {
-		if (siz != 0)
-			*d = '\0';		/* NUL-terminate dst */
-		while (*s++)
-			;
-	}
-
-	return(s - src - 1);	/* count does not include NUL */
-}
-
-/*	$OpenBSD: strlcat.c,v 1.11 2003/06/17 21:56:24 millert Exp $	*/
-
-/*
- * Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-/*
- * Appends src to string dst of size siz (unlike strncat, siz is the
- * full size of dst, not space left).  At most siz-1 characters
- * will be copied.  Always NUL terminates (unless siz <= strlen(dst)).
- * Returns strlen(src) + MIN(siz, strlen(initial dst)).
- * If retval >= siz, truncation occurred.
- */
-size_t
-c_strlcat(char *dst, const char *src, size_t siz)
-{
-	register char *d = dst;
-	register const char *s = src;
-	register size_t n = siz;
-	size_t dlen;
-
-	/* Find the end of dst and adjust bytes left but don't go past end */
-	while (n-- != 0 && *d != '\0')
-		d++;
-	dlen = d - dst;
-	n = siz - dlen;
-
-	if (n == 0)
-		return(dlen + strlen(s));
-	while (*s != '\0') {
-		if (n != 1) {
-			*d++ = *s;
-			n--;
-		}
-		s++;
-	}
-	*d = '\0';
-
-	return(dlen + (s - src));	/* count does not include NUL */
-}
-

+ 0 - 50
app/libc/c_string.h

@@ -1,50 +0,0 @@
-/*
- * c_string.h
- *
- * Definitions for memory and string functions.
- */
-
-#ifndef _C_STRING_H_
-#define	_C_STRING_H_
-#include "c_stddef.h"
-#include "osapi.h"
-
-#ifndef NULL
-#define NULL 0
-#endif
-
-#define c_memcmp os_memcmp
-#define c_memcpy os_memcpy
-#define c_memmove os_memmove
-#define c_memset os_memset
-
-#define c_strcat os_strcat
-#define c_strchr os_strchr
-#define c_strcmp os_strcmp
-#define c_strcpy os_strcpy
-#define c_strlen os_strlen
-#define c_strncmp os_strncmp
-#define c_strncpy os_strncpy
-// #define c_strstr os_strstr
-#define c_strncasecmp c_strncmp
-
-#define c_strstr strstr
-#define c_strncat strncat
-#define c_strcspn strcspn
-#define c_strpbrk strpbrk
-#define c_strcoll strcoll
-#define c_strrchr strrchr
-
-// const char *c_strstr(const char * __s1, const char * __s2);
-// char *c_strncat(char * __restrict /*s1*/, const char * __restrict /*s2*/, size_t n);
-// size_t c_strcspn(const char * s1, const char * s2);
-// const char *c_strpbrk(const char * /*s1*/, const char * /*s2*/);
-// int c_strcoll(const char * /*s1*/, const char * /*s2*/);
-//
-
-extern size_t c_strlcpy(char *dst, const char *src, size_t siz);
-extern size_t c_strlcat(char *dst, const char *src, size_t siz);
-extern char *c_strdup(const char *src);
-
-
-#endif /* _C_STRING_H_ */

+ 2 - 103
app/libc/c_math.c → app/libc/math.c

@@ -1,6 +1,5 @@
-#include "c_math.h"
-#include "c_types.h"
-#include "user_config.h"
+#include <math.h>
+#include <stdbool.h>
 
 double floor(double x)
 {
@@ -135,103 +134,3 @@ double pow(double x, double y)
     double res = ldexp(z, m);
     return flipsignal ? -res : res;
 }
-
-#if 0
-#ifndef __math_68881
-double atan(double x)
-{
-    return x;
-}
-double cos(double x)
-{
-    return x;
-}
-double sin(double x)
-{
-    return x;
-}
-double tan(double x)
-{
-    return x;
-}
-double tanh(double x)
-{
-    return x;
-}
-double frexp(double x, int *y)
-{
-    return x;
-}
-double modf(double x, double *y)
-{
-    return x;
-}
-double ceil(double x)
-{
-    return x;
-}
-double fabs(double x)
-{
-    return x;
-}
-double floor(double x)
-{
-    return x;
-}
-#endif /* ! defined (__math_68881) */
-
-/* Non reentrant ANSI C functions.  */
-
-#ifndef _REENT_ONLY
-#ifndef __math_68881
-double acos(double x)
-{
-    return x;
-}
-double asin(double x)
-{
-    return x;
-}
-double atan2(double x, double y)
-{
-    return x;
-}
-double cosh(double x)
-{
-    return x;
-}
-double sinh(double x)
-{
-    return x;
-}
-double exp(double x)
-{
-    return x;
-}
-double ldexp(double x, int y)
-{
-    return x;
-}
-double log(double x)
-{
-    return x;
-}
-double log10(double x)
-{
-    return x;
-}
-double pow(double x, double y)
-{
-    return x;
-}
-double sqrt(double x)
-{
-    return x;
-}
-double fmod(double x, double y)
-{
-    return x;
-}
-#endif /* ! defined (__math_68881) */
-#endif /* ! defined (_REENT_ONLY) */
-#endif

+ 31 - 71
app/libc/c_stdio.c → app/libc/stdio.c

@@ -1,61 +1,28 @@
-#include "c_stdio.h"
-// #include "driver/uart.h"
+#include <stdio.h>
 
 int c_stdin = 999;
 int c_stdout = 1000;
 int c_stderr = 1001;
 
-// FILE *c_fopen(const char *_name, const char *_type){
-// }
-// FILE *c_freopen(const char *_name, const char *_type, FILE *_f){
-// }
-// FILE *c_tmpfile(void){
-// }
-
-// int    c_putchar(int c){
-// }
-
-// int    c_printf(const char *c, ...){
-// }
-
-// int c_sprintf(char *c, const char *s, ...){
-// }
-
-// int    c_fprintf(FILE *f, const char *s, ...){
-// }
-// int    c_fscanf(FILE *f, const char *s, ...){
-// }
-// int    c_fclose(FILE *f){
-// }
-// int    c_fflush(FILE *f){
-// }
-// int    c_setvbuf(FILE *f, char *c, int d, size_t t){
-// }
-// void c_clearerr(FILE *f){
-// }
-// int    c_fseek(FILE *f, long l, int d){
-// }
-// long c_ftell( FILE *f){
-// }
-// int    c_fputs(const char *c, FILE *f){
-// }
-// char *c_fgets(char *c, int d, FILE *f){
-// }
-// int    c_ungetc(int d, FILE *f){
-// }
-// size_t c_fread(void *p, size_t _size, size_t _n, FILE *f){
-// }
-// size_t c_fwrite(const void *p, size_t _size, size_t _n, FILE *f){
-// }
-// int    c_feof(FILE *f){
-// }
-// int    c_ferror(FILE *f){
-// }
-// int    c_getc(FILE *f){
-// }
-
 #if defined( LUA_NUMBER_INTEGRAL )
 
+#include <stdarg.h>
+
+int sprintf(char *s, const char *fmt, ...)
+{
+    int n;
+    va_list arg;
+    va_start(arg, fmt);
+    n = ets_vsprintf(s, fmt, arg);
+    va_end(arg);
+    return n;
+}
+
+int vsprintf (char *d, const char *s, va_list ap)
+{
+  return ets_vsprintf(d, s, ap);
+}
+
 #else
 
 #define FLOATINGPT 1
@@ -97,8 +64,7 @@ int c_stderr = 1001;
  * SUCH DAMAGE.
  *
  */
-//#include <string.h>
-#include "c_string.h"
+#include <string.h>
 
 char *
 strichr(char *p, int c)
@@ -147,8 +113,7 @@ strichr(char *p, int c)
  * SUCH DAMAGE.
  *
  */
-//#include <string.h>
-#include "c_string.h"
+#include <string.h>
 
 #define FMT_RJUST 0
 #define FMT_LJUST 1
@@ -221,10 +186,8 @@ str_fmt(char *p, int size, int fmt)
  * SUCH DAMAGE.
  *
  */
-//#include <string.h>
-//#include <ctype.h>
-#include "c_string.h"
-#include "c_ctype.h"
+#include <string.h>
+#include <ctype.h>
 
 void
 strtoupper(char *p)
@@ -269,10 +232,9 @@ strtoupper(char *p)
  */
 
 //#include <sys/types.h>
-//#include <string.h>
+#include <string.h>
+#include <stdint.h>
 //#include <pmon.h>
-#include "c_string.h"
-typedef unsigned int u_int32_t;
 typedef unsigned int u_int;
 typedef unsigned long u_long;
 typedef int32_t register_t;
@@ -371,7 +333,7 @@ _atob (u_quad_t *vp, char *p, int base)
  *      converts p to binary result in vp, rtn 1 on success
  */
 int
-atob(u_int32_t *vp, char *p, int base)
+atob(uint32_t *vp, char *p, int base)
 {
     u_quad_t v;
 
@@ -554,13 +516,10 @@ gethex(int32_t *vp, char *p, int n)
  *
  */
 //#include <stdio.h>
-//#include <stdarg.h>
-//#include <string.h>
-//#include <ctype.h>
 //#include <pmon.h>
-#include "c_stdarg.h"
-#include "c_string.h"
-#include "c_ctype.h"
+#include <stdarg.h>
+#include <string.h>
+#include <ctype.h>
 
 /*
  *  int vsprintf(d,s,ap)
@@ -1091,10 +1050,9 @@ exponent(char *p, int exp, int fmtch)
     }
     return (p);
 }
-#endif /* FLOATINGPT */
 
 
-int c_sprintf(char *s, const char *fmt, ...)
+int sprintf(char *s, const char *fmt, ...)
 {
     int n;
     va_list arg;
@@ -1104,4 +1062,6 @@ int c_sprintf(char *s, const char *fmt, ...)
     return n;
 }
 
+#endif /* FLOATINGPT */
+
 #endif

+ 3 - 20
app/libc/c_stdlib.c → app/libc/stdlib.c

@@ -1,23 +1,13 @@
-//#include "user_interface.h"
 #include "user_config.h"
 
-#ifdef LUA_CROSS_COMPILER
-
 #include <stdlib.h>
 #include <ctype.h>
 #include <string.h>
+
+#ifdef LUA_CROSS_COMPILER
 #define ICACHE_RODATA_ATTR
 #define TRUE  1
 #define FALSE 0
-
-#else
-
-#include "c_stdlib.h"
-#include "c_types.h"
-#include "c_string.h"
-#include <_ansi.h>
-//#include <reent.h>
-//#include "mprec.h"
 #endif
 double powersOf10[] ICACHE_STORE_ATTR ICACHE_RODATA_ATTR =   /* Table giving binary powers of 10.  Entry */
 {
@@ -32,7 +22,7 @@ double powersOf10[] ICACHE_STORE_ATTR ICACHE_RODATA_ATTR =   /* Table giving bin
     1.0e256
 };
 
-double c_strtod(const char *string, char **endPtr)
+double strtod(const char *string, char **endPtr)
 {
     int maxExponent = 511;  /* Largest possible base 10 exponent.  Any
                  * exponent larger than this will already
@@ -256,10 +246,3 @@ done:
     }
     return fraction;
 }
-
-// long c_strtol(const char *__n, char **__end_PTR, int __base){
-// }
-// unsigned long c_strtoul(const char *__n, char **__end_PTR, int __base){
-// }
-// long long c_strtoll(const char *__n, char **__end_PTR, int __base){
-// }

+ 3 - 4
app/lua/lapi.c

@@ -10,9 +10,8 @@
 
 #include "lua.h"
 
-//#include C_HEADER_ASSERT
-#include C_HEADER_MATH
-#include C_HEADER_STRING
+#include <math.h>
+#include <string.h>
 #include "lapi.h"
 #include "ldebug.h"
 #include "ldo.h"
@@ -463,7 +462,7 @@ LUA_API void lua_pushstring (lua_State *L, const char *s) {
   if (s == NULL)
     lua_pushnil(L);
   else
-    lua_pushlstring(L, s, c_strlen(s));
+    lua_pushlstring(L, s, strlen(s));
 }
 
 

+ 34 - 35
app/lua/lauxlib.c

@@ -7,18 +7,19 @@
 #define LUAC_CROSS_FILE
 
 #include "lua.h"
-#include C_HEADER_CTYPE
+#include <ctype.h>
 #ifdef __MINGW__
 #include <errno.h>
 #else
 #ifdef _MSC_VER	//msvc #defines errno, which interferes with our #include macro
 #undef errno
 #endif
-#include C_HEADER_ERRNO
+#include <errno.h>
 #endif
-#include C_HEADER_STDIO
-#include C_HEADER_STDLIB
-#include C_HEADER_STRING
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <fcntl.h>
 #ifndef LUA_CROSS_COMPILER
 #include "vfs.h"
 #include "user_interface.h"
@@ -100,7 +101,7 @@ static void scanBlocks (void) {
   for (i=0; p ;i++) {
     s = memcmp(p->mark, marker, MARKSIZE) ? '<' : ' ';
     e = memcmp(cast(char *, p+1) + p->size, marker, MARKSIZE) ? '>' : ' ';
-    c_printf("%4u %p %8lu %c %c\n", i, p, p->size, s, e);
+    printf("%4u %p %8lu %c %c\n", i, p, p->size, s, e);
     ASSERT(p->next);
     p = p->next;
   }
@@ -136,7 +137,7 @@ static void freeblock (MemHeader *block) {
       p->next = next;
     }
     fillmem(block, sizeof(MemHeader) + size + MARKSIZE);  /* erase block */
-    c_free(block);  /* actually free block */
+    free(block);  /* actually free block */
     mc.numblocks--;  /* update counts */
     mc.total -= size;
   }
@@ -163,7 +164,7 @@ void *debug_realloc (void *b, size_t oldsize, size_t size) {
     MemHeader *newblock;
     size_t commonsize = (oldsize < size) ? oldsize : size;
     size_t realsize = sizeof(MemHeader) + size + MARKSIZE;
-    newblock = cast(MemHeader *, c_malloc(realsize));  /* alloc a new block */
+    newblock = cast(MemHeader *, malloc(realsize));  /* alloc a new block */
     if (newblock == NULL)
       return NULL;  /* really out of memory? */
     if (block) {
@@ -190,7 +191,7 @@ void *debug_realloc (void *b, size_t oldsize, size_t size) {
 
 /* }====================================================================== */
 #else
-#define this_realloc(p,os,s) c_realloc(p,s)
+#define this_realloc(p,os,s) realloc(p,s)
 #endif /* DEBUG_ALLOCATOR */
 
 /*
@@ -205,7 +206,7 @@ LUALIB_API int luaL_argerror (lua_State *L, int narg, const char *extramsg) {
   if (!lua_getstack(L, 0, &ar))  /* no stack frame? */
     return luaL_error(L, "bad argument #%d (%s)", narg, extramsg);
   lua_getinfo(L, "n", &ar);
-  if (c_strcmp(ar.namewhat, "method") == 0) {
+  if (strcmp(ar.namewhat, "method") == 0) {
     narg--;  /* do not count `self' */
     if (narg == 0)  /* error is in the self argument itself? */
       return luaL_error(L, "calling " LUA_QS " on bad self (%s)",
@@ -262,7 +263,7 @@ LUALIB_API int luaL_checkoption (lua_State *L, int narg, const char *def,
                              luaL_checkstring(L, narg);
   int i;
   for (i=0; lst[i]; i++)
-    if (c_strcmp(lst[i], name) == 0)
+    if (strcmp(lst[i], name) == 0)
       return i;
   return luaL_argerror(L, narg,
                        lua_pushfstring(L, "invalid option " LUA_QS, name));
@@ -352,7 +353,7 @@ LUALIB_API const char *luaL_optlstring (lua_State *L, int narg,
                                         const char *def, size_t *len) {
   if (lua_isnoneornil(L, narg)) {
     if (len)
-      *len = (def ? c_strlen(def) : 0);
+      *len = (def ? strlen(def) : 0);
     return def;
   }
   else return luaL_checklstring(L, narg, len);
@@ -533,10 +534,10 @@ LUALIB_API int luaL_getn (lua_State *L, int t) {
 LUALIB_API const char *luaL_gsub (lua_State *L, const char *s, const char *p,
                                                                const char *r) {
   const char *wild;
-  size_t l = c_strlen(p);
+  size_t l = strlen(p);
   luaL_Buffer b;
   luaL_buffinit(L, &b);
-  while ((wild = c_strstr(s, p)) != NULL) {
+  while ((wild = strstr(s, p)) != NULL) {
     luaL_addlstring(&b, s, wild - s);  /* push prefix */
     luaL_addstring(&b, r);  /* push replacement in place of pattern */
     s = wild + l;  /* continue after `p' */
@@ -552,8 +553,8 @@ LUALIB_API const char *luaL_findtable (lua_State *L, int idx,
   const char *e;
   lua_pushvalue(L, idx);
   do {
-    e = c_strchr(fname, '.');
-    if (e == NULL) e = fname + c_strlen(fname);
+    e = strchr(fname, '.');
+    if (e == NULL) e = fname + strlen(fname);
     lua_pushlstring(L, fname, e - fname);
     lua_rawget(L, -2);
 
@@ -634,7 +635,7 @@ LUALIB_API void luaL_addlstring (luaL_Buffer *B, const char *s, size_t l) {
 
 
 LUALIB_API void luaL_addstring (luaL_Buffer *B, const char *s) {
-  luaL_addlstring(B, s, c_strlen(s));
+  luaL_addlstring(B, s, strlen(s));
 }
 
 
@@ -650,7 +651,7 @@ LUALIB_API void luaL_addvalue (luaL_Buffer *B) {
   size_t vl;
   const char *s = lua_tolstring(L, -1, &vl);
   if (vl <= bufffree(B)) {  /* fit into buffer? */
-    c_memcpy(B->p, s, vl);  /* put it there */
+    memcpy(B->p, s, vl);  /* put it there */
     B->p += vl;
     lua_pop(L, 1);  /* remove from stack */
   }
@@ -730,14 +731,14 @@ static const char *getF (lua_State *L, void *ud, size_t *size) {
     *size = 1;
     return "\n";
   }
-  if (c_feof(lf->f)) return NULL;
-  *size = c_fread(lf->buff, 1, sizeof(lf->buff), lf->f);
+  if (feof(lf->f)) return NULL;
+  *size = fread(lf->buff, 1, sizeof(lf->buff), lf->f);
   return (*size > 0) ? lf->buff : NULL;
 }
 
 
 static int errfile (lua_State *L, const char *what, int fnameindex) {
-  const char *serr = c_strerror(errno);
+  const char *serr = strerror(errno);
   const char *filename = lua_tostring(L, fnameindex) + 1;
   lua_pushfstring(L, "cannot %s %s: %s", what, filename, serr);
   lua_remove(L, fnameindex);
@@ -757,27 +758,27 @@ LUALIB_API int luaL_loadfile (lua_State *L, const char *filename) {
   }
   else {
     lua_pushfstring(L, "@%s", filename);
-    lf.f = c_fopen(filename, "r");
+    lf.f = fopen(filename, "r");
     if (lf.f == NULL) return errfile(L, "open", fnameindex);
   }
-  c = c_getc(lf.f);
+  c = getc(lf.f);
   if (c == '#') {  /* Unix exec. file? */
     lf.extraline = 1;
-    while ((c = c_getc(lf.f)) != EOF && c != '\n') ;  /* skip first line */
-    if (c == '\n') c = c_getc(lf.f);
+    while ((c = getc(lf.f)) != EOF && c != '\n') ;  /* skip first line */
+    if (c == '\n') c = getc(lf.f);
   }
   if (c == LUA_SIGNATURE[0] && filename) {  /* binary file? */
-    lf.f = c_freopen(filename, "rb", lf.f);  /* reopen in binary mode */
+    lf.f = freopen(filename, "rb", lf.f);  /* reopen in binary mode */
     if (lf.f == NULL) return errfile(L, "reopen", fnameindex);
     /* skip eventual `#!...' */
-   while ((c = c_getc(lf.f)) != EOF && c != LUA_SIGNATURE[0]) {}
+   while ((c = getc(lf.f)) != EOF && c != LUA_SIGNATURE[0]) {}
 
    lf.extraline = 0;
   }
-  c_ungetc(c, lf.f);
+  ungetc(c, lf.f);
   status = lua_load(L, getF, &lf, lua_tostring(L, -1));
-  readstatus = c_ferror(lf.f);
-  if (filename) c_fclose(lf.f);  /* close file (even in case of errors) */
+  readstatus = ferror(lf.f);
+  if (filename) fclose(lf.f);  /* close file (even in case of errors) */
   if (readstatus) {
     lua_settop(L, fnameindex);  /* ignore results from `lua_load' */
     return errfile(L, "read", fnameindex);
@@ -788,8 +789,6 @@ LUALIB_API int luaL_loadfile (lua_State *L, const char *filename) {
 
 #else
 
-#include C_HEADER_FCNTL
-
 typedef struct LoadFSF {
   int extraline;
   int f;
@@ -893,7 +892,7 @@ LUALIB_API int luaL_loadbuffer (lua_State *L, const char *buff, size_t size,
 
 
 LUALIB_API int (luaL_loadstring) (lua_State *L, const char *s) {
-  return luaL_loadbuffer(L, s, c_strlen(s), s);
+  return luaL_loadbuffer(L, s, strlen(s), s);
 }
 
 
@@ -928,7 +927,7 @@ static void *l_alloc (void *ud, void *ptr, size_t osize, size_t nsize) {
 #ifdef DEBUG_ALLOCATOR
     return (void *)this_realloc(ptr, osize, nsize);
 #else
-    c_free(ptr);
+    free(ptr);
     return NULL;
 #endif
   }
@@ -988,7 +987,7 @@ LUALIB_API void luaL_dbgbreak(void) {
 static int panic (lua_State *L) {
   (void)L;  /* to avoid warnings */
 #if defined(LUA_USE_STDIO)
-  c_fprintf(c_stderr, "PANIC: unprotected error in call to Lua API (%s)\n",
+  fprintf(c_stderr, "PANIC: unprotected error in call to Lua API (%s)\n",
                    lua_tostring(L, -1));
 #else
   luai_writestringerror("PANIC: unprotected error in call to Lua API (%s)\n",

+ 0 - 6
app/lua/lauxlib.h

@@ -8,15 +8,9 @@
 #ifndef lauxlib_h
 #define lauxlib_h
 
-
 #include "lua.h"
 
-#ifdef LUA_CROSS_COMPILER
 #include <stdio.h>
-#else
-#include "c_stdio.h"
-#endif
-
 
 #if defined(LUA_COMPAT_GETN)
 LUALIB_API int (luaL_getn) (lua_State *L, int t);

+ 8 - 8
app/lua/lbaselib.c

@@ -11,9 +11,9 @@
 #define LUAC_CROSS_FILE
 
 #include "lua.h"
-#include C_HEADER_STDIO
-#include C_HEADER_STRING
-#include C_HEADER_STDLIB
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
 #include "lauxlib.h"
 #include "lualib.h"
 #include "lrotable.h"
@@ -41,16 +41,16 @@ static int luaB_print (lua_State *L) {
       return luaL_error(L, LUA_QL("tostring") " must return a string to "
                            LUA_QL("print"));
 #if defined(LUA_USE_STDIO)
-    if (i>1) c_fputs("\t", c_stdout);
-    c_fputs(s, c_stdout);
+    if (i>1) fputs("\t", c_stdout);
+    fputs(s, c_stdout);
 #else
     if (i>1)  luai_writestring("\t", 1);
-    luai_writestring(s, c_strlen(s));
+    luai_writestring(s, strlen(s));
 #endif
     lua_pop(L, 1);  /* pop result */
   }
 #if defined(LUA_USE_STDIO)
-  c_fputs("\n", c_stdout);
+  fputs("\n", c_stdout);
 #else
   luai_writeline();
 #endif
@@ -72,7 +72,7 @@ static int luaB_tonumber (lua_State *L) {
     char *s2;
     unsigned long n;
     luaL_argcheck(L, 2 <= base && base <= 36, 2, "base out of range");
-    n = c_strtoul(s1, &s2, base);
+    n = strtoul(s1, &s2, base);
     if (s1 != s2) {  /* at least one valid digit? */
       while (isspace((unsigned char)(*s2))) s2++;  /* skip trailing spaces */
       if (*s2 == '\0') {  /* no invalid trailing characters? */

+ 2 - 2
app/lua/lcode.c

@@ -10,7 +10,7 @@
 #define LUAC_CROSS_FILE
 
 #include "lua.h"
-#include C_HEADER_STDLIB
+#include <stdlib.h>
 
 #include "lcode.h"
 #include "ldebug.h"
@@ -81,7 +81,7 @@ static void fixjump (FuncState *fs, int pc, int dest) {
   Instruction *jmp = &fs->f->code[pc];
   int offset = dest-(pc+1);
   lua_assert(dest != NO_JUMP);
-  if (c_abs(offset) > MAXARG_sBx)
+  if (abs(offset) > MAXARG_sBx)
     luaX_syntaxerror(fs->ls, "control structure too long");
   SETARG_sBx(*jmp, offset);
 }

+ 19 - 19
app/lua/ldblib.c

@@ -10,9 +10,9 @@
 #define LUAC_CROSS_FILE
 
 #include "lua.h"
-#include C_HEADER_STDIO
-#include C_HEADER_STDLIB
-#include C_HEADER_STRING
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
 
 #include "lauxlib.h"
 #include "lualib.h"
@@ -33,7 +33,7 @@ static int db_getstrings (lua_State *L) {
   GCObject *o;
 #ifndef LUA_CROSS_COMPILER
   const char *opt = lua_tolstring (L, 1, &n);
-  if (n==3 && c_memcmp(opt, "ROM", 4) == 0) {
+  if (n==3 && memcmp(opt, "ROM", 4) == 0) {
     if (G(L)->ROstrt.hash == NULL)
       return 0;
     tb = &G(L)->ROstrt;
@@ -155,24 +155,24 @@ static int db_getinfo (lua_State *L) {
   if (!lua_getinfo(L1, options, &ar))
     return luaL_argerror(L, arg+2, "invalid option");
   lua_createtable(L, 0, 2);
-  if (c_strchr(options, 'S')) {
+  if (strchr(options, 'S')) {
     settabss(L, "source", ar.source);
     settabss(L, "short_src", ar.short_src);
     settabsi(L, "linedefined", ar.linedefined);
     settabsi(L, "lastlinedefined", ar.lastlinedefined);
     settabss(L, "what", ar.what);
   }
-  if (c_strchr(options, 'l'))
+  if (strchr(options, 'l'))
     settabsi(L, "currentline", ar.currentline);
-  if (c_strchr(options, 'u'))
+  if (strchr(options, 'u'))
     settabsi(L, "nups", ar.nups);
-  if (c_strchr(options, 'n')) {
+  if (strchr(options, 'n')) {
     settabss(L, "name", ar.name);
     settabss(L, "namewhat", ar.namewhat);
   }
-  if (c_strchr(options, 'L'))
+  if (strchr(options, 'L'))
     treatstackoption(L, L1, "activelines");
-  if (c_strchr(options, 'f'))
+  if (strchr(options, 'f'))
     treatstackoption(L, L1, "func");
   return 1;  /* return table */
 }
@@ -261,9 +261,9 @@ static void hookf (lua_State *L, lua_Debug *ar) {
 
 static int makemask (const char *smask, int count) {
   int mask = 0;
-  if (c_strchr(smask, 'c')) mask |= LUA_MASKCALL;
-  if (c_strchr(smask, 'r')) mask |= LUA_MASKRET;
-  if (c_strchr(smask, 'l')) mask |= LUA_MASKLINE;
+  if (strchr(smask, 'c')) mask |= LUA_MASKCALL;
+  if (strchr(smask, 'r')) mask |= LUA_MASKRET;
+  if (strchr(smask, 'l')) mask |= LUA_MASKLINE;
   if (count > 0) mask |= LUA_MASKCOUNT;
   return mask;
 }
@@ -340,19 +340,19 @@ static int db_debug (lua_State *L) {
   for (;;) {
     char buffer[LUA_MAXINPUT];
 #if defined(LUA_USE_STDIO)
-    c_fputs("lua_debug> ", c_stderr);
-    if (c_fgets(buffer, sizeof(buffer), c_stdin) == 0 ||
+    fputs("lua_debug> ", c_stderr);
+    if (fgets(buffer, sizeof(buffer), c_stdin) == 0 ||
 #else
 //    luai_writestringerror("%s", "lua_debug>");
     if (lua_readline(L, buffer, "lua_debug>") == 0 ||
 #endif
-        c_strcmp(buffer, "cont\n") == 0)
+        strcmp(buffer, "cont\n") == 0)
       return 0;
-    if (luaL_loadbuffer(L, buffer, c_strlen(buffer), "=(debug command)") ||
+    if (luaL_loadbuffer(L, buffer, strlen(buffer), "=(debug command)") ||
         lua_pcall(L, 0, 0, 0)) {
 #if defined(LUA_USE_STDIO)
-      c_fputs(lua_tostring(L, -1), c_stderr);
-      c_fputs("\n", c_stderr);
+      fputs(lua_tostring(L, -1), c_stderr);
+      fputs("\n", c_stderr);
 #else
       luai_writestringerror("%s\n", lua_tostring(L, -1));
 #endif

+ 4 - 4
app/lua/ldebug.c

@@ -10,7 +10,7 @@
 #define LUAC_CROSS_FILE
 
 #include "lua.h"
-#include C_HEADER_STRING
+#include <string.h>
 
 #include "lapi.h"
 #include "lcode.h"
@@ -253,7 +253,7 @@ static int stripdebug (lua_State *L, Proto *f, int level) {
   TString* dummy;
   switch (level) {
     case 3:
-      sizepackedlineinfo = c_strlen(cast(char *, f->packedlineinfo))+1;
+      sizepackedlineinfo = strlen(cast(char *, f->packedlineinfo))+1;
       f->packedlineinfo = luaM_freearray(L, f->packedlineinfo, sizepackedlineinfo, unsigned char);
       len += sizepackedlineinfo;
     case 2:
@@ -344,7 +344,7 @@ LUA_API int lua_getinfo (lua_State *L, const char *what, lua_Debug *ar) {
       plight = fvalue(ci->func);
   }
   status = auxgetinfo(L, what, ar, f, plight, ci);
-  if (c_strchr(what, 'f')) {
+  if (strchr(what, 'f')) {
     if (f != NULL)
       setclvalue(L, L->top, f)
     else if (plight != NULL)
@@ -353,7 +353,7 @@ LUA_API int lua_getinfo (lua_State *L, const char *what, lua_Debug *ar) {
       setnilvalue(L->top);
     incr_top(L);
   }
-  if (c_strchr(what, 'L'))
+  if (strchr(what, 'L'))
     collectvalidlines(L, f);
   lua_unlock(L);
   return status;

+ 1 - 1
app/lua/ldo.c

@@ -11,7 +11,7 @@
 #define LUAC_CROSS_FILE
 
 #include "lua.h"
-#include C_HEADER_STRING
+#include <string.h>
 
 #include "ldebug.h"
 #include "ldo.h"

+ 7 - 7
app/lua/ldump.c

@@ -9,7 +9,7 @@
 #define LUAC_CROSS_FILE
 
 #include "lua.h"
-#include C_HEADER_STRING
+#include <string.h>
 
 #include "lobject.h"
 #include "lstate.h"
@@ -150,9 +150,9 @@ static void DumpNumber(lua_Number x, DumpState* D)
     if(D->target.is_arm_fpa)
     {
       char *pnum=(char*)&y, temp[4];
-      c_memcpy(temp,pnum,4);
-      c_memcpy(pnum,pnum+4,4);
-      c_memcpy(pnum+4,temp,4);
+      memcpy(temp,pnum,4);
+      memcpy(pnum,pnum+4,4);
+      memcpy(pnum+4,temp,4);
     }
     MaybeByteSwap((char*)&y,8,D);
     DumpVar(y,D);
@@ -171,7 +171,7 @@ static void DumpCode(const Proto *f, DumpState* D)
  Align4(D);
  for (i=0; i<f->sizecode; i++)
  {
-  c_memcpy(buf,&f->code[i],sizeof(Instruction));
+  memcpy(buf,&f->code[i],sizeof(Instruction));
   MaybeByteSwap(buf,sizeof(Instruction),D);
   DumpBlock(buf,sizeof(Instruction),D);
  }
@@ -230,7 +230,7 @@ static void DumpDebug(const Proto* f, DumpState* D)
  int i,n;
 
 #ifdef LUA_OPTIMIZE_DEBUG
- n = (D->strip || f->packedlineinfo == NULL) ? 0: c_strlen(cast(char *,f->packedlineinfo))+1;
+ n = (D->strip || f->packedlineinfo == NULL) ? 0: strlen(cast(char *,f->packedlineinfo))+1;
  DumpInt(n,D);
  Align4(D);
  if (n)
@@ -281,7 +281,7 @@ static void DumpHeader(DumpState* D)
  char *h=buf;
 
  /* This code must be kept in sync wiht luaU_header */
- c_memcpy(h,LUA_SIGNATURE,sizeof(LUA_SIGNATURE)-1);
+ memcpy(h,LUA_SIGNATURE,sizeof(LUA_SIGNATURE)-1);
  h+=sizeof(LUA_SIGNATURE)-1;
  *h++=(char)LUAC_VERSION;
  *h++=(char)LUAC_FORMAT;

+ 10 - 10
app/lua/lflash.c

@@ -17,10 +17,10 @@
 #include "vfs.h"
 #include "uzlib.h"
 
-#include "c_fcntl.h"
-#include "c_stdio.h"
-#include "c_stdlib.h"
-#include "c_string.h"
+#include <fcntl.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
 
 /*
  * Flash memory is a fixed memory addressable block that is serially allocated by the
@@ -388,13 +388,13 @@ static void put_byte (uint8_t value) {
 }
 
 
-static uint8_t recall_byte (uint offset) {
+static uint8_t recall_byte (unsigned offset) {
   if(offset > DICTIONARY_WINDOW || offset >= out->ndx)
     flash_error("invalid dictionary offset on inflate");
   /* ndx starts at 1. Need relative to 0 */
-  uint n   = out->ndx - offset;
-  uint pos = n % WRITE_BLOCKSIZE;
-  uint blockNo = out->ndx / WRITE_BLOCKSIZE - n  / WRITE_BLOCKSIZE;
+  unsigned n   = out->ndx - offset;
+  unsigned pos = n % WRITE_BLOCKSIZE;
+  unsigned blockNo = out->ndx / WRITE_BLOCKSIZE - n  / WRITE_BLOCKSIZE;
   return out->block[blockNo]->byte[pos];
 }
 
@@ -429,7 +429,7 @@ int procFirstPass (void) {
          fh->flash_size > flashSize ||
          out->flagsLen != 1 + (out->flashLen/WORDSIZE - 1) / BITS_PER_WORD)
       flash_error("LFS length mismatch");
-    out->flags = luaM_newvector(out->L, out->flagsLen, uint);
+    out->flags = luaM_newvector(out->L, out->flagsLen, unsigned);
   }
 
   /* update running CRC */
@@ -512,7 +512,7 @@ static int loadLFS (lua_State *L) {
   in->len = vfs_size(in->fd);
   if (in->len <= 200 ||        /* size of an empty luac output */
       vfs_lseek(in->fd, in->len-4, VFS_SEEK_SET) != in->len-4 ||
-      vfs_read(in->fd, &out->len, sizeof(uint)) != sizeof(uint))
+      vfs_read(in->fd, &out->len, sizeof(unsigned)) != sizeof(unsigned))
     flash_error("read error on LFS image file");
   vfs_lseek(in->fd, 0, VFS_SEEK_SET);
 

+ 2 - 2
app/lua/lfunc.c

@@ -9,7 +9,7 @@
 #define LUAC_CROSS_FILE
 
 #include "lua.h"
-#include C_HEADER_STRING
+#include <string.h>
 
 #include "lfunc.h"
 #include "lgc.h"
@@ -150,7 +150,7 @@ void luaF_freeproto (lua_State *L, Proto *f) {
     luaM_freearray(L, f->code, f->sizecode, Instruction);
 #ifdef LUA_OPTIMIZE_DEBUG
     if (f->packedlineinfo) {
-      luaM_freearray(L, f->packedlineinfo, c_strlen(cast(char *, f->packedlineinfo))+1, unsigned char);
+      luaM_freearray(L, f->packedlineinfo, strlen(cast(char *, f->packedlineinfo))+1, unsigned char);
     }
 #else
     luaM_freearray(L, f->lineinfo, f->sizelineinfo, int);

+ 4 - 4
app/lua/lgc.c

@@ -9,7 +9,7 @@
 #define LUAC_CROSS_FILE
 
 #include "lua.h"
-#include C_HEADER_STRING
+#include <string.h>
 
 #include "ldebug.h"
 #include "ldo.h"
@@ -173,8 +173,8 @@ static int traversetable (global_State *g, Table *h) {
   }
 
   if (mode && ttisstring(mode)) {  /* is there a weak mode? */
-    weakkey = (c_strchr(svalue(mode), 'k') != NULL);
-    weakvalue = (c_strchr(svalue(mode), 'v') != NULL);
+    weakkey = (strchr(svalue(mode), 'k') != NULL);
+    weakvalue = (strchr(svalue(mode), 'v') != NULL);
     if (weakkey || weakvalue) {  /* is really weak? */
       h->marked &= ~(KEYWEAK | VALUEWEAK);  /* clear bits */
       h->marked |= cast_byte((weakkey << KEYWEAKBIT) |
@@ -333,7 +333,7 @@ static l_mem propagatemark (global_State *g) {
                              (proto_isreadonly(p) ? 0 : sizeof(Instruction) * p->sizecode +
 #ifdef LUA_OPTIMIZE_DEBUG
                                                          (p->packedlineinfo ?
-                                                            c_strlen(cast(char *, p->packedlineinfo))+1 :
+                                                            strlen(cast(char *, p->packedlineinfo))+1 :
                                                             0));
 #else
                                                          sizeof(int) * p->sizelineinfo);

+ 5 - 5
app/lua/llex.c

@@ -10,9 +10,9 @@
 #define LUAC_CROSS_FILE
 
 #include "lua.h"
-#include C_HEADER_CTYPE
-#include C_HEADER_LOCALE
-#include C_HEADER_STRING
+#include <ctype.h>
+#include <locale.h>
+#include <string.h>
 
 #include "ldo.h"
 #include "llex.h"
@@ -154,7 +154,7 @@ void luaX_setinput (lua_State *L, LexState *ls, ZIO *z, TString *source) {
 
 
 static int check_next (LexState *ls, const char *set) {
-  if (!c_strchr(set, ls->current))
+  if (!strchr(set, ls->current))
     return 0;
   save_and_next(ls);
   return 1;
@@ -422,7 +422,7 @@ static int llex (LexState *ls, SemInfo *seminfo) {
           /* look for reserved word */
           save(ls, '\0');
           for (i = 0; i < NUM_RESERVED; i++)
-            if (!c_strcmp(luaX_tokens[i], luaZ_buffer(ls->buff)))
+            if (!strcmp(luaX_tokens[i], luaZ_buffer(ls->buff)))
               return i + FIRST_RESERVED;
           ts = luaX_newstring(ls, luaZ_buffer(ls->buff),
                                   luaZ_bufflen(ls->buff) - 1);

+ 0 - 2
app/lua/llimits.h

@@ -8,8 +8,6 @@
 #define llimits_h
 
 
-//#include "c_limits.h"
-
 #include "lua.h"
 
 typedef LUAI_UINT32 lu_int32;

+ 2 - 2
app/lua/lmathlib.c

@@ -10,8 +10,8 @@
 #define LUAC_CROSS_FILE
 
 #include "lua.h"
-#include C_HEADER_STDLIB
-#include C_HEADER_MATH
+#include <stdlib.h>
+#include <math.h>
 
 #include "lauxlib.h"
 #include "lualib.h"

+ 0 - 6
app/lua/lmem.h

@@ -8,12 +8,6 @@
 #define lmem_h
 
 
-//#ifdef LUA_CROSS_COMPILER
-//#include <stddef.h>
-//#else
-//#include "c_stddef.h"
-//#endif
-
 #include "llimits.h"
 #include "lua.h"
 

+ 11 - 11
app/lua/loadlib.c

@@ -14,9 +14,9 @@
 #define LUAC_CROSS_FILE
 
 #include "lua.h"
-#include C_HEADER_STDLIB
-#include C_HEADER_STRING
-#include C_HEADER_FCNTL
+#include <stdlib.h>
+#include <string.h>
+#include <fcntl.h>
 
 #ifndef LUA_CROSS_COMPILER
 #include "vfs.h"
@@ -103,7 +103,7 @@ static void setprogdir (lua_State *L) {
   char *lb;
   DWORD nsize = sizeof(buff)/sizeof(char);
   DWORD n = GetModuleFileNameA(NULL, buff, nsize);
-  if (n == 0 || n == nsize || (lb = c_strrchr(buff, '\\')) == NULL)
+  if (n == 0 || n == nsize || (lb = strrchr(buff, '\\')) == NULL)
     luaL_error(L, "unable to get ModuleFileName");
   else {
     *lb = '\0';
@@ -333,9 +333,9 @@ static int ll_loadlib (lua_State *L) {
 */
 #ifdef LUA_CROSS_COMPILER
 static int readable (const char *filename) {
-  FILE *f = c_fopen(filename, "r");  /* try to open file */
+  FILE *f = fopen(filename, "r");  /* try to open file */
   if (f == NULL) return 0;  /* open failed */
-  c_fclose(f);
+  fclose(f);
   return 1;
 }
 #else
@@ -351,8 +351,8 @@ static const char * pushnexttemplate (lua_State *L, const char *path) {
   const char *l;
   while (*path == *LUA_PATHSEP) path++;  /* skip separators */
   if (*path == '\0') return NULL;  /* no more templates */
-  l = c_strchr(path, *LUA_PATHSEP);  /* find next separator */
-  if (l == NULL) l = path + c_strlen(path);
+  l = strchr(path, *LUA_PATHSEP);  /* find next separator */
+  if (l == NULL) l = path + strlen(path);
   lua_pushlstring(L, path, l - path);  /* template */
   return l;
 }
@@ -406,7 +406,7 @@ static int loader_Lua (lua_State *L) {
 
 static const char *mkfuncname (lua_State *L, const char *modname) {
   const char *funcname;
-  const char *mark = c_strchr(modname, *LUA_IGMARK);
+  const char *mark = strchr(modname, *LUA_IGMARK);
   if (mark) modname = mark + 1;
   funcname = luaL_gsub(L, modname, ".", LUA_OFSEP);
   funcname = lua_pushfstring(L, POF"%s", funcname);
@@ -431,7 +431,7 @@ static int loader_Croot (lua_State *L) {
   const char *funcname;
   const char *filename;
   const char *name = luaL_checkstring(L, 1);
-  const char *p = c_strchr(name, '.');
+  const char *p = strchr(name, '.');
   int stat;
   if (p == NULL) return 0;  /* is root */
   lua_pushlstring(L, name, p - name);
@@ -559,7 +559,7 @@ static void modinit (lua_State *L, const char *modname) {
   lua_setfield(L, -2, "_M");  /* module._M = module */
   lua_pushstring(L, modname);
   lua_setfield(L, -2, "_NAME");
-  dot = c_strrchr(modname, '.');  /* look for last dot in module name */
+  dot = strrchr(modname, '.');  /* look for last dot in module name */
   if (dot == NULL) dot = modname;
   else dot++;
   /* set _PACKAGE as package name (full module name minus last part) */

+ 17 - 17
app/lua/lobject.c

@@ -10,9 +10,9 @@
 #define LUAC_CROSS_FILE
 
 #include "lua.h"
-#include C_HEADER_STDIO
-#include C_HEADER_STRING
-#include C_HEADER_STDLIB
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
 
 #include "ldo.h"
 #include "lmem.h"
@@ -116,7 +116,7 @@ int luaO_str2d (const char *s, lua_Number *result) {
       *result = cast_num(lres);
     }
 #else
-    *result = cast_num(c_strtoul(s, &endptr, 16));
+    *result = cast_num(strtoul(s, &endptr, 16));
 #endif
   if (*endptr == '\0') return 1;  /* most common case */
   while (isspace(cast(unsigned char, *endptr))) endptr++;
@@ -137,7 +137,7 @@ const char *luaO_pushvfstring (lua_State *L, const char *fmt, va_list argp) {
   int n = 1;
   pushstr(L, "");
   for (;;) {
-    const char *e = c_strchr(fmt, '%');
+    const char *e = strchr(fmt, '%');
     if (e == NULL) break;
     setsvalue2s(L, L->top, luaS_newlstr(L, fmt, e-fmt));
     incr_top(L);
@@ -167,7 +167,7 @@ const char *luaO_pushvfstring (lua_State *L, const char *fmt, va_list argp) {
       }
       case 'p': {
         char buff[4*sizeof(void *) + 8]; /* should be enough space for a `%p' */
-        c_sprintf(buff, "%p", va_arg(argp, void *));
+        sprintf(buff, "%p", va_arg(argp, void *));
         pushstr(L, buff);
         break;
       }
@@ -206,7 +206,7 @@ const char *luaO_pushfstring (lua_State *L, const char *fmt, ...) {
 
 void luaO_chunkid (char *out, const char *source, size_t bufflen) {
   if (*source == '=') {
-    c_strncpy(out, source+1, bufflen);  /* remove first char */
+    strncpy(out, source+1, bufflen);  /* remove first char */
     out[bufflen-1] = '\0';  /* ensures null termination */
   }
   else {  /* out = "source", or "...source" */
@@ -214,26 +214,26 @@ void luaO_chunkid (char *out, const char *source, size_t bufflen) {
       size_t l;
       source++;  /* skip the `@' */
       bufflen -= sizeof(" '...' ");
-      l = c_strlen(source);
-      c_strcpy(out, "");
+      l = strlen(source);
+      strcpy(out, "");
       if (l > bufflen) {
         source += (l-bufflen);  /* get last part of file name */
-        c_strcat(out, "...");
+        strcat(out, "...");
       }
-      c_strcat(out, source);
+      strcat(out, source);
     }
     else {  /* out = [string "string"] */
-      size_t len = c_strcspn(source, "\n\r");  /* stop at first newline */
+      size_t len = strcspn(source, "\n\r");  /* stop at first newline */
       bufflen -= sizeof(" [string \"...\"] ");
       if (len > bufflen) len = bufflen;
-      c_strcpy(out, "[string \"");
+      strcpy(out, "[string \"");
       if (source[len] != '\0') {  /* must truncate? */
-        c_strncat(out, source, len);
-        c_strcat(out, "...");
+        strncat(out, source, len);
+        strcat(out, "...");
       }
       else
-        c_strcat(out, source);
-      c_strcat(out, "\"]");
+        strcat(out, source);
+      strcat(out, "\"]");
     }
   }
 }

+ 0 - 4
app/lua/lobject.h

@@ -8,11 +8,7 @@
 #ifndef lobject_h
 #define lobject_h
 
-#ifdef LUA_CROSS_COMPILER
 #include <stdarg.h>
-#else
-#include "c_stdarg.h"
-#endif
 
 #include "llimits.h"
 #include "lua.h"

+ 1 - 1
app/lua/lparser.c

@@ -10,7 +10,7 @@
 #define LUAC_CROSS_FILE
 
 #include "lua.h"
-#include C_HEADER_STRING
+#include <string.h>
 
 #include "lcode.h"
 #include "ldebug.h"

+ 4 - 4
app/lua/lrotable.c

@@ -2,7 +2,7 @@
 #define LUAC_CROSS_FILE
 
 #include "lua.h"
-#include C_HEADER_STRING
+#include <string.h>
 #include "lrotable.h"
 #include "lauxlib.h"
 #include "lstring.h"
@@ -100,7 +100,7 @@ const TValue* luaR_findentry(ROTable *rotable, TString *key, unsigned *ppos) {
   unsigned    l      = key ? key->tsv.len : sizeof("__metatable")-1;
 
   if (pentry) {
-    if (j >= 0 && !c_strcmp(pentry[j].key, strkey)) {
+    if (j >= 0 && !strcmp(pentry[j].key, strkey)) {
       if (ppos)
         *ppos = j;
 //dbg_printf("%3d hit  %p %s\n", (hash>>2) & (LA_LINES-1), rotable, strkey);
@@ -112,11 +112,11 @@ const TValue* luaR_findentry(ROTable *rotable, TString *key, unsigned *ppos) {
      * is included so a "on\0" has a mask of 0xFFFFFF and "a\0" has 0xFFFF.
      */
     unsigned name4, mask4 = l > 2 ? (~0u) : (~0u)>>((3-l)*8);
-    c_memcpy(&name4, strkey, sizeof(name4));
+    memcpy(&name4, strkey, sizeof(name4));
 
     for(;pentry->key != NULL; i++, pentry++) {
       if (((*(unsigned *)pentry->key ^ name4) & mask4) == 0 &&
-          !c_strcmp(pentry->key, strkey)) {
+          !strcmp(pentry->key, strkey)) {
 //dbg_printf("%p %s hit after %d probes \n", rotable, strkey, (int)(rotable-pentry));
         if (ppos)
           *ppos = i;

+ 4 - 4
app/lua/lstring.c

@@ -11,7 +11,7 @@
 #define LUAC_CROSS_FILE
 
 #include "lua.h"
-#include C_HEADER_STRING
+#include <string.h>
 
 #include "lmem.h"
 #include "lobject.h"
@@ -67,7 +67,7 @@ static TString *newlstr (lua_State *L, const char *str, size_t l,
   ts->tsv.marked = luaC_white(G(L));
   ts->tsv.tt = LUA_TSTRING;
   if (!readonly) {
-    c_memcpy(ts+1, str, l*sizeof(char));
+    memcpy(ts+1, str, l*sizeof(char));
     ((char *)(ts+1))[l] = '\0';  /* ending 0 */
   } else {
     *(char **)(ts+1) = (char *)str;
@@ -106,7 +106,7 @@ LUAI_FUNC TString *luaS_newlstr (lua_State *L, const char *str, size_t l) {
        o != NULL;
        o = o->gch.next) {
     TString *ts = rawgco2ts(o);
-    if (ts->tsv.len == l && (c_memcmp(str, getstr(ts), l) == 0)) {
+    if (ts->tsv.len == l && (memcmp(str, getstr(ts), l) == 0)) {
       /* string may be dead */
       if (isdead(G(L), o)) changewhite(o);
       return ts;
@@ -131,7 +131,7 @@ LUAI_FUNC TString *luaS_newlstr (lua_State *L, const char *str, size_t l) {
   /* New additions to the RAM strt are tagged as readonly if the string address
    * is in the CTEXT segment (target only, not luac.cross) */
   int readonly = (lua_is_ptr_in_ro_area(str) && l+1 > sizeof(char**) &&
-                  l == c_strlen(str) ? LUAS_READONLY_STRING : LUAS_REGULAR_STRING);
+                  l == strlen(str) ? LUAS_READONLY_STRING : LUAS_REGULAR_STRING);
   return newlstr(L, str, l, h, readonly);  /* not found */
 }
 

+ 1 - 1
app/lua/lstring.h

@@ -17,7 +17,7 @@
 
 #define sizeudata(u)	(sizeof(union Udata)+(u)->len)
 
-#define luaS_new(L, s)	(luaS_newlstr(L, s, c_strlen(s)))
+#define luaS_new(L, s)	(luaS_newlstr(L, s, strlen(s)))
 #define luaS_newliteral(L, s)  (luaS_newlstr(L, "" s, \
                                   (sizeof(s)/sizeof(char))-1))
 

+ 16 - 16
app/lua/lstrlib.c

@@ -10,8 +10,8 @@
 #define LUAC_CROSS_FILE
 
 #include "lua.h"
-#include C_HEADER_STDIO
-#include C_HEADER_STRING
+#include <stdio.h>
+#include <string.h>
 
 #include "lauxlib.h"
 #include "lualib.h"
@@ -352,7 +352,7 @@ static const char *match_capture (MatchState *ms, const char *s, int l) {
   l = check_capture(ms, l);
   len = ms->capture[l].len;
   if ((size_t)(ms->src_end-s) >= len &&
-      c_memcmp(ms->capture[l].init, s, len) == 0)
+      memcmp(ms->capture[l].init, s, len) == 0)
     return s+len;
   else return NULL;
 }
@@ -447,7 +447,7 @@ static const char *lmemfind (const char *s1, size_t l1,
     l1 = l1-l2;  /* `s2' cannot be found after that */
     while (l1 > 0 && (init = (const char *)memchr(s1, *s2, l1)) != NULL) {
       init++;   /* 1st char is already checked */
-      if (c_memcmp(init, s2+1, l2) == 0)
+      if (memcmp(init, s2+1, l2) == 0)
         return init-1;
       else {  /* correct `l1' and `s1' to try again */
         l1 -= init-s1;
@@ -496,7 +496,7 @@ static int str_find_aux (lua_State *L, int find) {
   if (init < 0) init = 0;
   else if ((size_t)(init) > l1) init = (ptrdiff_t)l1;
   if (find && (lua_toboolean(L, 4) ||  /* explicit request? */
-      c_strpbrk(p, SPECIALS) == NULL)) {  /* or no special characters? */
+      strpbrk(p, SPECIALS) == NULL)) {  /* or no special characters? */
     /* do a plain search */
     const char *s2 = lmemfind(s+init, l1-init, p, l2);
     if (s2) {
@@ -723,7 +723,7 @@ static void addquoted (lua_State *L, luaL_Buffer *b, int arg) {
 
 static const char *scanformat (lua_State *L, const char *strfrmt, char *form) {
   const char *p = strfrmt;
-  while (*p != '\0' && c_strchr(FLAGS, *p) != NULL) p++;  /* skip flags */
+  while (*p != '\0' && strchr(FLAGS, *p) != NULL) p++;  /* skip flags */
   if ((size_t)(p - strfrmt) >= sizeof(FLAGS))
     luaL_error(L, "invalid format (repeated flags)");
   if (isdigit(uchar(*p))) p++;  /* skip width */
@@ -736,7 +736,7 @@ static const char *scanformat (lua_State *L, const char *strfrmt, char *form) {
   if (isdigit(uchar(*p)))
     luaL_error(L, "invalid format (width or precision too long)");
   *(form++) = '%';
-  c_strncpy(form, strfrmt, p - strfrmt + 1);
+  strncpy(form, strfrmt, p - strfrmt + 1);
   form += p - strfrmt + 1;
   *form = '\0';
   return p;
@@ -744,9 +744,9 @@ static const char *scanformat (lua_State *L, const char *strfrmt, char *form) {
 
 
 static void addintlen (char *form) {
-  size_t l = c_strlen(form);
+  size_t l = strlen(form);
   char spec = form[l - 1];
-  c_strcpy(form + l - 1, LUA_INTFRMLEN);
+  strcpy(form + l - 1, LUA_INTFRMLEN);
   form[l + sizeof(LUA_INTFRMLEN) - 2] = spec;
   form[l + sizeof(LUA_INTFRMLEN) - 1] = '\0';
 }
@@ -773,23 +773,23 @@ static int str_format (lua_State *L) {
       strfrmt = scanformat(L, strfrmt, form);
       switch (*strfrmt++) {
         case 'c': {
-          c_sprintf(buff, form, (int)luaL_checknumber(L, arg));
+          sprintf(buff, form, (int)luaL_checknumber(L, arg));
           break;
         }
         case 'd':  case 'i': {
           addintlen(form);
-          c_sprintf(buff, form, (LUA_INTFRM_T)luaL_checknumber(L, arg));
+          sprintf(buff, form, (LUA_INTFRM_T)luaL_checknumber(L, arg));
           break;
         }
         case 'o':  case 'u':  case 'x':  case 'X': {
           addintlen(form);
-          c_sprintf(buff, form, (unsigned LUA_INTFRM_T)luaL_checknumber(L, arg));
+          sprintf(buff, form, (unsigned LUA_INTFRM_T)luaL_checknumber(L, arg));
           break;
         }
 #if !defined LUA_NUMBER_INTEGRAL
         case 'e':  case 'E': case 'f':
         case 'g': case 'G': {
-          c_sprintf(buff, form, (double)luaL_checknumber(L, arg));
+          sprintf(buff, form, (double)luaL_checknumber(L, arg));
           break;
         }
 #endif
@@ -800,7 +800,7 @@ static int str_format (lua_State *L) {
         case 's': {
           size_t l;
           const char *s = luaL_checklstring(L, arg, &l);
-          if (!c_strchr(form, '.') && l >= 100) {
+          if (!strchr(form, '.') && l >= 100) {
             /* no precision and string is too long to be formatted;
                keep original string */
             lua_pushvalue(L, arg);
@@ -808,7 +808,7 @@ static int str_format (lua_State *L) {
             continue;  /* skip the `addsize' at the end */
           }
           else {
-            c_sprintf(buff, form, s);
+            sprintf(buff, form, s);
             break;
           }
         }
@@ -817,7 +817,7 @@ static int str_format (lua_State *L) {
                                LUA_QL("format"), *(strfrmt - 1));
         }
       }
-      luaL_addlstring(&b, buff, c_strlen(buff));
+      luaL_addlstring(&b, buff, strlen(buff));
     }
   }
   luaL_pushresult(&b);

+ 3 - 3
app/lua/ltable.c

@@ -23,8 +23,8 @@
 #define LUAC_CROSS_FILE
 
 #include "lua.h"
-#include C_HEADER_MATH
-#include C_HEADER_STRING
+#include <math.h>
+#include <string.h>
 
 #include "ldebug.h"
 #include "ldo.h"
@@ -86,7 +86,7 @@ static Node *hashnum (const Table *t, lua_Number n) {
   int i;
   if (luai_numeq(n, 0))  /* avoid problems with -0 */
     return gnode(t, 0);
-  c_memcpy(a, &n, sizeof(a));
+  memcpy(a, &n, sizeof(a));
   for (i = 1; i < numints; i++) a[0] += a[i];
   return hashmod(t, a[0]);
 }

+ 1 - 1
app/lua/ltm.c

@@ -10,7 +10,7 @@
 #define LUAC_CROSS_FILE
 
 #include "lua.h"
-#include C_HEADER_STRING
+#include <string.h>
 
 #include "lobject.h"
 #include "lstate.h"

+ 16 - 17
app/lua/lua.c

@@ -5,10 +5,9 @@
 */
 
 
-// #include "c_signal.h"
-#include "c_stdio.h"
-#include "c_stdlib.h"
-#include "c_string.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
 #include "user_interface.h"
 #include "user_version.h"
 #include "driver/readline.h"
@@ -32,9 +31,9 @@ static const char *progname = LUA_PROGNAME;
 
 static void l_message (const char *pname, const char *msg) {
 #if defined(LUA_USE_STDIO)
-  if (pname) c_fprintf(c_stderr, "%s: ", pname);
-  c_fprintf(c_stderr, "%s\n", msg);
-  c_fflush(c_stderr);
+  if (pname) fprintf(c_stderr, "%s: ", pname);
+  fprintf(c_stderr, "%s\n", msg);
+  fflush(c_stderr);
 #else
   if (pname) luai_writestringerror("%s: ", pname);
   luai_writestringerror("%s\n", msg);
@@ -122,7 +121,7 @@ static int dofsfile (lua_State *L, const char *name) {
 
 
 static int dostring (lua_State *L, const char *s, const char *name) {
-  int status = luaL_loadbuffer(L, s, c_strlen(s), name) || docall(L, 0, 1);
+  int status = luaL_loadbuffer(L, s, strlen(s), name) || docall(L, 0, 1);
   return report(L, status);
 }
 
@@ -148,7 +147,7 @@ static int incomplete (lua_State *L, int status) {
     size_t lmsg;
     const char *msg = lua_tolstring(L, -1, &lmsg);
     const char *tp = msg + lmsg - (sizeof(LUA_QL("<eof>")) - 1);
-    if (c_strstr(msg, LUA_QL("<eof>")) == tp) {
+    if (strstr(msg, LUA_QL("<eof>")) == tp) {
       lua_pop(L, 1);
       return 1;
     }
@@ -214,7 +213,7 @@ static int runargs (lua_State *L, char **argv, int n) {
         int memlimit=0;
         if (*limit == '\0') limit = argv[++i];
         lua_assert(limit != NULL);
-        memlimit = c_atoi(limit);
+        memlimit = atoi(limit);
         lua_gc(L, LUA_GCSETMEMLIMIT, memlimit);
         break;
       }
@@ -307,7 +306,7 @@ int lua_main (int argc, char **argv) {
   gLoad.L = L;
   gLoad.firstline = 1;
   gLoad.done = 0;
-  gLoad.line = c_malloc(LUA_MAXINPUT);
+  gLoad.line = malloc(LUA_MAXINPUT);
   gLoad.len = LUA_MAXINPUT;
   gLoad.line_position = 0;
   gLoad.prmt = get_prompt(L, 1);
@@ -324,7 +323,7 @@ int lua_main (int argc, char **argv) {
 int lua_put_line(const char *s, size_t l) {
   if (s == NULL || ++l > LUA_MAXINPUT || gLoad.line_position > 0)
     return 0;
-  c_memcpy(gLoad.line, s, l);
+  memcpy(gLoad.line, s, l);
   gLoad.line[l] = '\0';
   gLoad.line_position = l;
   gLoad.done = 1;
@@ -336,7 +335,7 @@ void lua_handle_input (bool force)
 {
   while (gLoad.L && (force || readline (&gLoad))) {
     NODE_DBG("Handle Input: first=%u, pos=%u, len=%u, actual=%u, line=%s\n", gLoad.firstline,
-              gLoad.line_position, gLoad.len, c_strlen(gLoad.line), gLoad.line);
+              gLoad.line_position, gLoad.len, strlen(gLoad.line), gLoad.line);
     dojob (&gLoad);
     force = false;
   }
@@ -357,7 +356,7 @@ static void dojob(lua_Load *load){
 
   do{
     if(load->done == 1){
-      l = c_strlen(b);
+      l = strlen(b);
       if (l > 0 && b[l-1] == '\n')  /* line ends with newline? */
         b[l-1] = '\0';  /* remove it */
       if (load->firstline && b[0] == '=')  /* first line starts with `=' ? */
@@ -401,8 +400,8 @@ static void dojob(lua_Load *load){
 
   load->done = 0;
   load->line_position = 0;
-  c_memset(load->line, 0, load->len);
-  c_puts(load->prmt);
+  memset(load->line, 0, load->len);
+  puts(load->prmt);
 }
 
 #ifndef uart_putc
@@ -468,7 +467,7 @@ static bool readline(lua_Load *load){
         if (load->line_position == 0)
         {
           /* Get a empty line, then go to get a new line */
-          c_puts(load->prmt);
+          puts(load->prmt);
           continue;
         } else {
           load->done = 1;

+ 4 - 10
app/lua/lua.h

@@ -11,16 +11,10 @@
 #ifdef LUAC_CROSS_FILE
 #include "luac_cross.h"
 #endif
-#ifdef LUA_CROSS_COMPILER
-#include <stdarg.h>
-#include <stddef.h>
-#include <ctype.h>
-#else
-#include "c_stdarg.h"
-#include "c_stddef.h"
-#include "c_types.h"
-#include <ctype.h>
-#endif
+#include <stdint.h>
+#include "stdarg.h"
+#include "stddef.h"
+#include "ctype.h"
 
 #include "luaconf.h"
 

+ 2 - 3
app/lua/luac_cross/Makefile

@@ -8,7 +8,7 @@
 
 summary ?= @true
 
-CCFLAGS:= -I.. -I../../include -I../../libc -I../../uzlib
+CCFLAGS:= -I.. -I../../include -I../../uzlib
 LDFLAGS:= -L$(SDK_DIR)/lib -L$(SDK_DIR)/ld -lm -ldl -Wl,-Map=mapfile
 
 CCFLAGS += -Wall
@@ -33,13 +33,12 @@ LUASRC  := lapi.c      lauxlib.c   lbaselib.c  lcode.c     ldblib.c    ldebug.c
            lmathlib.c  lmem.c      loadlib.c   lobject.c   lopcodes.c  lparser.c \
            lrotable.c  lstate.c    lstring.c   lstrlib.c   ltable.c    ltablib.c \
            ltm.c       lundump.c   lvm.c       lzio.c
-LIBCSRC := c_stdlib.c
 UZSRC   := uzlib_deflate.c crc32.c
 
 #
 # This relies on the files being unique on the vpath
 #
-SRC      := $(LUACSRC) $(LUASRC) $(LIBCSRC) $(UZSRC)
+SRC      := $(LUACSRC) $(LUASRC) $(UZSRC)
 vpath %.c .:..:../../libc:../../uzlib
 
 ODIR   := .output/$(TARGET)/$(FLAVOR)/obj

+ 1 - 2
app/lua/luac_cross/mingw32-Makefile.mak

@@ -38,12 +38,11 @@ LUASRC  := lapi.c      lauxlib.c   lbaselib.c  lcode.c     ldblib.c    ldebug.c
            lmathlib.c  lmem.c      loadlib.c   lobject.c   lopcodes.c  lparser.c \
            lrotable.c  lstate.c    lstring.c   lstrlib.c   ltable.c    ltablib.c \
            ltm.c       lundump.c   lvm.c       lzio.c
-LIBCSRC := c_stdlib.c
 UZSRC   := uzlib_deflate.c crc32.c
 #
 # This relies on the files being unique on the vpath
 #
-SRC      := $(LUACSRC) $(LUASRC) $(LIBCSRC) $(UZSRC)
+SRC      := $(LUACSRC) $(LUASRC) $(UZSRC)
 
 vpath %.c .:..:../../libc:../../uzlib
 

+ 11 - 27
app/lua/luaconf.h

@@ -8,13 +8,9 @@
 #ifndef lconfig_h
 #define lconfig_h
 
-#ifdef LUA_CROSS_COMPILER
 #include <limits.h>
 #include <stddef.h>
-#else
-#include "c_limits.h"
-#include "c_stddef.h"
-#endif
+#include <stdbool.h>
 #include "user_config.h"
 
 /*
@@ -262,11 +258,7 @@
 #define lua_stdin_is_tty()	isatty(0)
 #elif defined(LUA_WIN)
 #include <io.h>
-#ifdef LUA_CROSS_COMPILER
 #include <stdio.h>
-#else
-#include "c_stdio.h"
-#endif
 
 #define lua_stdin_is_tty()	_isatty(_fileno(stdin))
 #else
@@ -317,11 +309,11 @@
 #define lua_saveline(L,idx) \
 	if (lua_strlen(L,idx) > 0)  /* non-empty line? */ \
 	  add_history(lua_tostring(L, idx));  /* add it to history */
-#define lua_freeline(L,b)	((void)L, c_free(b))
+#define lua_freeline(L,b)	((void)L, free(b))
 #else // #if defined(LUA_CROSS_COMPILER) && defined(LUA_USE_READLINE)
 #define lua_readline(L,b,p)	\
-	((void)L, c_fputs(p, c_stdout), c_fflush(c_stdout),  /* show prompt */ \
-	c_fgets(b, LUA_MAXINPUT, c_stdin) != NULL)  /* get line */
+	((void)L, fputs(p, c_stdout), fflush(c_stdout),  /* show prompt */ \
+	fgets(b, LUA_MAXINPUT, c_stdin) != NULL)  /* get line */
 #define lua_saveline(L,idx)	{ (void)L; (void)idx; }
 #define lua_freeline(L,b)	{ (void)L; (void)b; }
 #endif // #if defined(LUA_USE_READLINE)
@@ -342,8 +334,8 @@ extern int readline4lua(const char *prompt, char *buffer, int length);
 ** avoids including 'stdio.h' everywhere.)
 */
 #if !defined(LUA_USE_STDIO)
-#define luai_writestring(s, l)  c_puts(s)
-#define luai_writeline()        c_puts("\n")
+#define luai_writestring(s, l)  puts(s)
+#define luai_writeline()        puts("\n")
 #endif // defined(LUA_USE_STDIO)
 
 /*
@@ -622,31 +614,23 @@ extern int readline4lua(const char *prompt, char *buffer, int length);
 #define LUA_NUMBER_SCAN		"%lf"
 #define LUA_NUMBER_FMT		"%.14g"
 #endif // #if defined LUA_NUMBER_INTEGRAL
-#define lua_number2str(s,n)	c_sprintf((s), LUA_NUMBER_FMT, (n))
+#define lua_number2str(s,n)	sprintf((s), LUA_NUMBER_FMT, (n))
 #define LUAI_MAXNUMBER2STR	32 /* 16 digits, sign, point, and \0 */
 #if defined LUA_NUMBER_INTEGRAL
   #if !defined LUA_INTEGRAL_LONGLONG
-  #define lua_str2number(s,p)	c_strtol((s), (p), 10)
+  #define lua_str2number(s,p)	strtol((s), (p), 10)
   #else
-  #define lua_str2number(s,p) c_strtoll((s), (p), 10)
+  #define lua_str2number(s,p) strtoll((s), (p), 10)
   #endif // #if !defined LUA_INTEGRAL_LONGLONG
 #else
-#ifdef _MSC_VER	//what's wrong with stdlib strtod?
 #define lua_str2number(s,p)	strtod((s), (p))
-#else
-#define lua_str2number(s,p)	c_strtod((s), (p))
-#endif
 #endif // #if defined LUA_NUMBER_INTEGRAL
 
 /*
 @@ The luai_num* macros define the primitive operations over numbers.
 */
 #if defined(LUA_CORE) || defined(LUA_LIB)
-#ifdef LUA_CROSS_COMPILER
 #include <math.h>
-#else
-#include "c_math.h"
-#endif
 #define luai_numadd(a,b)	((a)+(b))
 #define luai_numsub(a,b)	((a)-(b))
 #define luai_nummul(a,b)	((a)*(b))
@@ -801,7 +785,7 @@ union luai_Cast { double l_d; long l_l; };
 #include <unistd.h>
 #define LUA_TMPNAMBUFSIZE	32
 #define lua_tmpnam(b,e)	{ \
-	c_strcpy(b, "/tmp/lua_XXXXXX"); \
+	strcpy(b, "/tmp/lua_XXXXXX"); \
 	e = mkstemp(b); \
 	if (e != -1) close(e); \
 	e = (e == -1); }
@@ -821,7 +805,7 @@ union luai_Cast { double l_d; long l_l; };
 */
 #if defined(LUA_USE_POPEN)
 
-#define lua_popen(L,c,m)	((void)L, c_fflush(NULL), popen(c,m))
+#define lua_popen(L,c,m)	((void)L, fflush(NULL), popen(c,m))
 #define lua_pclose(L,file)	((void)L, (pclose(file) != -1))
 
 #elif defined(LUA_WIN)

+ 3 - 3
app/lua/lundump.c

@@ -9,7 +9,7 @@
 #define LUAC_CROSS_FILE
 
 #include "lua.h"
-#include C_HEADER_STRING
+#include <string.h>
 
 #include "ldebug.h"
 #include "ldo.h"
@@ -309,7 +309,7 @@ static void LoadHeader(LoadState* S)
  S->numsize=h[10]=s[10]; /* length of lua_Number */
  S->toflt=(s[11]>intck); /* check if conversion from int lua_Number to flt is needed */
  if(S->toflt) s[11]=h[11];
- IF (c_memcmp(h,s,LUAC_HEADERSIZE)!=0, "bad header");
+ IF (memcmp(h,s,LUAC_HEADERSIZE)!=0, "bad header");
 }
 
 /*
@@ -338,7 +338,7 @@ Proto* luaU_undump (lua_State* L, ZIO* Z, Mbuffer* buff, const char* name)
 void luaU_header (char* h)
 {
  int x=1;
- c_memcpy(h,LUA_SIGNATURE,sizeof(LUA_SIGNATURE)-1);
+ memcpy(h,LUA_SIGNATURE,sizeof(LUA_SIGNATURE)-1);
  h+=sizeof(LUA_SIGNATURE)-1;
  *h++=(char)LUAC_VERSION;
  *h++=(char)LUAC_FORMAT;

+ 0 - 4
app/lua/lundump.h

@@ -7,11 +7,7 @@
 #ifndef lundump_h
 #define lundump_h
 
-#ifdef LUA_CROSS_COMPILER
 #include <stdint.h>
-#else
-#include "c_stdint.h"
-#endif
 
 #include "lobject.h"
 #include "lzio.h"

+ 6 - 6
app/lua/lvm.c

@@ -10,9 +10,9 @@
 #define LUAC_CROSS_FILE
 
 #include "lua.h"
-#include C_HEADER_STDIO
-#include C_HEADER_STRING
-#include C_HEADER_MATH
+#include <stdio.h>
+#include <string.h>
+#include <math.h>
 
 #include "ldebug.h"
 #include "ldo.h"
@@ -252,10 +252,10 @@ static int l_strcmp (const TString *ls, const TString *rs) {
   const char *r = getstr(rs);
   size_t lr = rs->tsv.len;
   for (;;) {
-    int temp = c_strcoll(l, r);
+    int temp = strcoll(l, r);
     if (temp != 0) return temp;
     else {  /* strings are equal up to a `\0' */
-      size_t len = c_strlen(l);  /* index of first `\0' in both strings */
+      size_t len = strlen(l);  /* index of first `\0' in both strings */
       if (len == lr)  /* r is finished? */
         return (len == ll) ? 0 : 1;
       else if (len == ll)  /* l is finished? */
@@ -363,7 +363,7 @@ void luaV_concat (lua_State *L, int total, int last) {
       tl = 0;
       for (i=n; i>0; i--) {  /* concat all strings */
         size_t l = tsvalue(top-i)->len;
-        c_memcpy(buffer+tl, svalue(top-i), l);
+        memcpy(buffer+tl, svalue(top-i), l);
         tl += l;
       }
       setsvalue2s(L, top-n, luaS_newlstr(L, buffer, tl));

+ 2 - 2
app/lua/lzio.c

@@ -10,7 +10,7 @@
 #define LUAC_CROSS_FILE
 
 #include "lua.h"
-#include C_HEADER_STRING
+#include <string.h>
 
 #include "llimits.h"
 #include "lmem.h"
@@ -62,7 +62,7 @@ size_t luaZ_read (ZIO *z, void *b, size_t n) {
       return n;  /* return number of missing bytes */
     m = (n <= z->n) ? n : z->n;  /* min. between n and z->n */
     if (b)
-      c_memcpy(b, z->p, m);
+      memcpy(b, z->p, m);
     z->n -= m;
     z->i += m;
     z->p += m;

+ 0 - 9
app/mbedtls/library/platform.c

@@ -25,15 +25,6 @@
 #include MBEDTLS_CONFIG_FILE
 #endif
 
-// XXX Espressif are hacks sometimes.  This is BS, but is taken from
-// the mbedtls platform.c from their SDK.  Really, this should go
-// somewhere else.  Note that the prototype here for vPortFree differs (!)
-// from the one in sdk-overrides.h.  That's above my pay grade.
-// --nwf;  2018 Feb 18
-extern void *pvPortCalloc(unsigned int count, unsigned int size);
-extern void vPortFree( void *pv );
-
-
 #if defined(MBEDTLS_PLATFORM_C)
 
 #include "mbedtls/platform.h"

+ 4 - 0
app/mbedtls/platform/mbedtls_mem.c

@@ -0,0 +1,4 @@
+#include <stdlib.h>
+
+void *mbedtls_calloc(size_t n, size_t sz) { return calloc(n, sz); }
+void mbedtls_free(void *p) { free(p); }

+ 3 - 0
app/mbedtls/platform/memcompat.c

@@ -0,0 +1,3 @@
+#include <stdlib.h>
+void *mbedtls_calloc_wrap(size_t n, size_t sz) { return calloc(n, sz); }
+void mbedtls_free_wrap(void *p) { free(p); }

+ 1 - 1
app/modules/ads1115.c

@@ -8,7 +8,7 @@
 #include "lauxlib.h"
 #include "platform.h"
 #include "osapi.h"
-#include "c_stdlib.h"
+#include <stdlib.h>
 
 
 //***************************************************************************

+ 2 - 2
app/modules/adxl345.c

@@ -6,8 +6,8 @@
 #include "module.h"
 #include "lauxlib.h"
 #include "platform.h"
-#include "c_stdlib.h"
-#include "c_string.h"
+#include <stdlib.h>
+#include <string.h>
 
 static const uint32_t adxl345_i2c_id = 0;
 static const uint8_t adxl345_i2c_addr = 0x53;

+ 2 - 2
app/modules/apa102.c

@@ -1,5 +1,5 @@
-#include "c_stdlib.h"
-#include "c_string.h"
+#include <stdlib.h>
+#include <string.h>
 #include "lualib.h"
 #include "lauxlib.h"
 #include "lrotable.h"

+ 1 - 1
app/modules/bit.c

@@ -6,7 +6,7 @@
 
 
 #include "module.h"
-#include "c_limits.h"
+#include <limits.h>
 
 #include "lauxlib.h"
 

+ 1 - 0
app/modules/bloom.c

@@ -6,6 +6,7 @@
 
 #include "module.h"
 #include "lauxlib.h"
+#include <string.h>
 #include "c_types.h"
 #include "../crypto/sha2.h"
 

+ 1 - 1
app/modules/bme280.c

@@ -11,7 +11,7 @@
 #include "module.h"
 #include "lauxlib.h"
 #include "platform.h"
-#include "c_math.h"
+#include <math.h>
 
 /****************************************************/
 /**\name	registers definition  */

+ 1 - 1
app/modules/bme680.c

@@ -9,7 +9,7 @@
 #include "module.h"
 #include "lauxlib.h"
 #include "platform.h"
-#include "c_math.h"
+#include <math.h>
 
 #include "bme680_defs.h"
 

+ 2 - 2
app/modules/bmp085.c

@@ -1,8 +1,8 @@
 #include "module.h"
 #include "lauxlib.h"
 #include "platform.h"
-#include "c_stdlib.h"
-#include "c_string.h"
+#include <stdlib.h>
+#include <string.h>
 
 static const uint32_t bmp085_i2c_id = 0;
 static const uint8_t bmp085_i2c_addr = 0x77;

+ 23 - 23
app/modules/coap.c

@@ -4,8 +4,8 @@
 #include "lauxlib.h"
 #include "platform.h"
 
-#include "c_string.h"
-#include "c_stdlib.h"
+#include <string.h>
+#include <stdlib.h>
 
 #include "c_types.h"
 #include "mem.h"
@@ -36,13 +36,13 @@ static void coap_received(void *arg, char *pdata, unsigned short len)
 
   // static uint8_t buf[MAX_MESSAGE_SIZE+1] = {0}; // +1 for string '\0'
   uint8_t buf[MAX_MESSAGE_SIZE+1] = {0}; // +1 for string '\0'
-  c_memset(buf, 0, sizeof(buf)); // wipe prev data
+  memset(buf, 0, sizeof(buf)); // wipe prev data
 
   if (len > MAX_MESSAGE_SIZE) {
     NODE_DBG("Request Entity Too Large.\n"); // NOTE: should response 4.13 to client...
     return;
   }
-  // c_memcpy(buf, pdata, len);
+  // memcpy(buf, pdata, len);
 
   size_t rsplen = coap_server_respond(pdata, len, buf, MAX_MESSAGE_SIZE+1);
 
@@ -52,11 +52,11 @@ static void coap_received(void *arg, char *pdata, unsigned short len)
     return;
   pesp_conn->proto.udp->remote_port = pr->remote_port;
   os_memmove (pesp_conn->proto.udp->remote_ip, pr->remote_ip, 4);
-  // The remot_info apparently should *not* be os_free()d, fyi
+  // The remot_info apparently should *not* be free()d, fyi
 
   espconn_sent(pesp_conn, (unsigned char *)buf, rsplen);
 
-  // c_memset(buf, 0, sizeof(buf));
+  // memset(buf, 0, sizeof(buf));
 }
 
 static void coap_sent(void *arg)
@@ -83,7 +83,7 @@ static int coap_create( lua_State* L, const char* mt )
   lua_setmetatable(L, -2);
 
   // create the espconn struct
-  pesp_conn = (struct espconn *)c_zalloc(sizeof(struct espconn));
+  pesp_conn = (struct espconn *)calloc(1,sizeof(struct espconn));
   if(!pesp_conn)
     return luaL_error(L, "not enough memory");
 
@@ -93,9 +93,9 @@ static int coap_create( lua_State* L, const char* mt )
   pesp_conn->proto.tcp = NULL;
   pesp_conn->proto.udp = NULL;
 
-  pesp_conn->proto.udp = (esp_udp *)c_zalloc(sizeof(esp_udp));
+  pesp_conn->proto.udp = (esp_udp *)calloc(1,sizeof(esp_udp));
   if(!pesp_conn->proto.udp){
-    c_free(pesp_conn);
+    free(pesp_conn);
     cud->pesp_conn = pesp_conn = NULL;
     return luaL_error(L, "not enough memory");
   }
@@ -131,9 +131,9 @@ static int coap_delete( lua_State* L, const char* mt )
   {
     if(cud->pesp_conn->proto.udp->remote_port || cud->pesp_conn->proto.udp->local_port)
       espconn_delete(cud->pesp_conn);
-    c_free(cud->pesp_conn->proto.udp);
+    free(cud->pesp_conn->proto.udp);
     cud->pesp_conn->proto.udp = NULL;
-    c_free(cud->pesp_conn);
+    free(cud->pesp_conn);
     cud->pesp_conn = NULL;
   }
 
@@ -170,7 +170,7 @@ static int coap_start( lua_State* L, const char* mt )
       ip = "0.0.0.0";
     }
     ipaddr.addr = ipaddr_addr(ip);
-    c_memcpy(pesp_conn->proto.udp->local_ip, &ipaddr.addr, 4);
+    memcpy(pesp_conn->proto.udp->local_ip, &ipaddr.addr, 4);
     NODE_DBG("UDP ip is set: ");
     NODE_DBG(IPSTR, IP2STR(&ipaddr.addr));
     NODE_DBG("\n");
@@ -235,7 +235,7 @@ static void coap_response_handler(void *arg, char *pdata, unsigned short len)
   pkt.content.len = 0;
   // static uint8_t buf[MAX_MESSAGE_SIZE+1] = {0}; // +1 for string '\0'
   uint8_t buf[MAX_MESSAGE_SIZE+1] = {0}; // +1 for string '\0'
-  c_memset(buf, 0, sizeof(buf)); // wipe prev data
+  memset(buf, 0, sizeof(buf)); // wipe prev data
 
   int rc;
   if( len > MAX_MESSAGE_SIZE )
@@ -243,7 +243,7 @@ static void coap_response_handler(void *arg, char *pdata, unsigned short len)
     NODE_DBG("Request Entity Too Large.\n"); // NOTE: should response 4.13 to client...
     return;
   }
-  c_memcpy(buf, pdata, len);
+  memcpy(buf, pdata, len);
 
   if (0 != (rc = coap_parse(&pkt, buf, len))){
     NODE_DBG("Bad packet rc=%d\n", rc);
@@ -271,7 +271,7 @@ static void coap_response_handler(void *arg, char *pdata, unsigned short len)
     uint32_t ip = 0, port = 0;
     coap_tid_t id = COAP_INVALID_TID;
 
-    c_memcpy(&ip, pesp_conn->proto.udp->remote_ip, sizeof(ip));
+    memcpy(&ip, pesp_conn->proto.udp->remote_ip, sizeof(ip));
     port = pesp_conn->proto.udp->remote_port;
 
     coap_transaction_id(ip, port, &pkt, &id);
@@ -303,7 +303,7 @@ end:
     if(pesp_conn->proto.udp->remote_port || pesp_conn->proto.udp->local_port)
       espconn_delete(pesp_conn);
   }
-  // c_memset(buf, 0, sizeof(buf));
+  // memset(buf, 0, sizeof(buf));
 }
 
 // Lua: client:request( [CON], uri, [payload] )
@@ -354,7 +354,7 @@ static int coap_request( lua_State* L, coap_method_t m )
   pesp_conn->proto.udp->local_port = espconn_port();
 
   if(uri->host.length){
-    c_memcpy(host, uri->host.s, uri->host.length);
+    memcpy(host, uri->host.s, uri->host.length);
     host[uri->host.length] = '\0';
 
     ipaddr.addr = ipaddr_addr(host);
@@ -362,7 +362,7 @@ static int coap_request( lua_State* L, coap_method_t m )
     NODE_DBG(host);
     NODE_DBG("\n");
 
-    c_memcpy(pesp_conn->proto.udp->remote_ip, &ipaddr.addr, 4);
+    memcpy(pesp_conn->proto.udp->remote_ip, &ipaddr.addr, 4);
     NODE_DBG("UDP ip is set: ");
     NODE_DBG(IPSTR, IP2STR(&ipaddr.addr));
     NODE_DBG("\n");
@@ -371,7 +371,7 @@ static int coap_request( lua_State* L, coap_method_t m )
   coap_pdu_t *pdu = coap_new_pdu();   // should call coap_delete_pdu() somewhere
   if(!pdu){
     if(uri)
-      c_free(uri);
+      free(uri);
     return luaL_error (L, "alloc fail");
   }
 
@@ -422,7 +422,7 @@ static int coap_request( lua_State* L, coap_method_t m )
   }
 
   if(uri)
-    c_free((void *)uri);
+    free((void *)uri);
 
   NODE_DBG("coap_request is called.\n");
   return 0;
@@ -447,13 +447,13 @@ static int coap_regist( lua_State* L, const char* mt, int isvar )
     h = function_entry;
 
   while(NULL!=h->next){  // goto the end of the list
-    if(h->name!= NULL && c_strcmp(h->name, name)==0)  // key exist, override it
+    if(h->name!= NULL && strcmp(h->name, name)==0)  // key exist, override it
       break;
     h = h->next;
   }
 
-  if(h->name==NULL || c_strcmp(h->name, name)!=0){   // not exists. make a new one.
-    h->next = (coap_luser_entry *)c_zalloc(sizeof(coap_luser_entry));
+  if(h->name==NULL || strcmp(h->name, name)!=0){   // not exists. make a new one.
+    h->next = (coap_luser_entry *)calloc(1,sizeof(coap_luser_entry));
     h = h->next;
     if(h == NULL)
       return luaL_error(L, "not enough memory");

+ 3 - 3
app/modules/color_utils.c

@@ -2,9 +2,9 @@
 #include "lauxlib.h"
 #include "lmem.h"
 #include "platform.h"
-#include "c_stdlib.h"
-#include "c_math.h"
-#include "c_string.h"
+#include <stdlib.h>
+#include <math.h>
+#include <string.h>
 #include "user_interface.h"
 #include "osapi.h"
 

+ 3 - 3
app/modules/color_utils.h

@@ -5,9 +5,9 @@
 #include "lauxlib.h"
 #include "lmem.h"
 #include "platform.h"
-#include "c_stdlib.h"
-#include "c_math.h"
-#include "c_string.h"
+#include <stdlib.h>
+#include <math.h>
+#include <string.h>
 #include "user_interface.h"
 #include "osapi.h"
 

+ 2 - 2
app/modules/cron.c

@@ -5,7 +5,7 @@
 #include "lmem.h"
 #include "user_interface.h"
 #include "c_types.h"
-#include "c_string.h"
+#include <string.h>
 #include "ets_sys.h"
 #include "time.h"
 #include "rtc/rtctime.h"
@@ -176,7 +176,7 @@ static int lcron_reset(lua_State *L) {
     luaL_unref(L, LUA_REGISTRYINDEX, cronent_list[i]);
   }
   cronent_count = 0;
-  os_free(cronent_list);
+  free(cronent_list);
   cronent_list = 0;
   return 0;
 }

+ 2 - 2
app/modules/crypto.c

@@ -1,11 +1,11 @@
 // Module for cryptography
 
-#include <c_errno.h>
+#include <errno.h>
 #include "module.h"
 #include "lauxlib.h"
 #include "platform.h"
 #include "c_types.h"
-#include "c_stdlib.h"
+#include <stdlib.h>
 #include "vfs.h"
 #include "../crypto/digests.h"
 #include "../crypto/mech.h"

+ 3 - 3
app/modules/encoder.c

@@ -3,7 +3,7 @@
 #include "module.h"
 #include "lauxlib.h"
 #include "lmem.h"
-#include "c_string.h"
+#include <string.h>
 #define BASE64_INVALID '\xff'
 #define BASE64_PADDING '='
 #define ISBASE64(c) (unbytes64[c] != BASE64_INVALID)
@@ -19,7 +19,7 @@ static uint8 *toBase64 ( lua_State* L, const uint8 *msg, size_t *len){
   int buf_size = (n + 2) / 3 * 4; // estimated encoded size
   uint8 * q, *out = (uint8 *)luaM_malloc(L, buf_size);
   uint8 bytes64[sizeof(b64)];
-  c_memcpy(bytes64, b64, sizeof(b64));   //Avoid lots of flash unaligned fetches
+  memcpy(bytes64, b64, sizeof(b64));   //Avoid lots of flash unaligned fetches
 
   for (i = 0, q = out; i < n; i += 3) {
     int a = msg[i];
@@ -46,7 +46,7 @@ static uint8 *fromBase64 ( lua_State* L, const uint8 *enc_msg, size_t *len){
   if (n & 3)
     luaL_error (L, "Invalid base64 string");
 
-  c_memset(unbytes64, BASE64_INVALID, sizeof(unbytes64));
+  memset(unbytes64, BASE64_INVALID, sizeof(unbytes64));
   for (i = 0; i < sizeof(b64)-1; i++) unbytes64[b64[i]] = i;  // sequential so no exceptions
 
   if (enc_msg[n-1] == BASE64_PADDING) {

+ 101 - 101
app/modules/enduser_setup.c

@@ -38,9 +38,9 @@
 #include "lauxlib.h"
 #include "lmem.h"
 #include "platform.h"
-#include "c_stdlib.h"
-#include "c_stdio.h"
-#include "c_string.h"
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
 #include "ctype.h"
 #include "user_interface.h"
 #include "espconn.h"
@@ -248,7 +248,7 @@ static void enduser_setup_check_station(void *p)
 
   (void)p;
   struct ip_info ip;
-  c_memset(&ip, 0, sizeof(struct ip_info));
+  memset(&ip, 0, sizeof(struct ip_info));
 
   wifi_get_ip_info(STATION_IF, &ip);
 
@@ -266,7 +266,7 @@ static void enduser_setup_check_station(void *p)
     /* No IP Address yet, so check the reported status */
     uint8_t curr_status = wifi_station_get_connect_status();
     char buf[20];
-    c_sprintf(buf, "status=%d,chan=%d", curr_status, currChan);
+    sprintf(buf, "status=%d,chan=%d", curr_status, currChan);
     ENDUSER_SETUP_DEBUG(buf);
 
     if (curr_status == 2 || curr_status == 3 || curr_status == 4)
@@ -290,7 +290,7 @@ static void enduser_setup_check_station(void *p)
    return;
   }
 
-  c_sprintf (ipaddr, "%d.%d.%d.%d", IP2STR(&ip.ip.addr));
+  sprintf (ipaddr, "%d.%d.%d.%d", IP2STR(&ip.ip.addr));
 
   state->success = 1;
   state->lastStationStatus = 5; /*  We have an IP Address, so the status is 5 (as of SDK 1.5.1) */
@@ -298,7 +298,7 @@ static void enduser_setup_check_station(void *p)
 
 #if ENDUSER_SETUP_DEBUG_ENABLE
   char debuginfo[100];
-  c_sprintf(debuginfo, "AP_CHAN: %d, STA_CHAN: %d", state->softAPchannel, currChan);
+  sprintf(debuginfo, "AP_CHAN: %d, STA_CHAN: %d", state->softAPchannel, currChan);
   ENDUSER_SETUP_DEBUG(debuginfo);
 #endif
 
@@ -462,27 +462,27 @@ static int enduser_setup_http_load_payload(void)
   char cl_hdr[30];
   size_t ce_len = 0;
 
-  c_sprintf(cl_hdr, http_header_content_len_fmt, file_len);
-  size_t cl_len = c_strlen(cl_hdr);
+  sprintf(cl_hdr, http_header_content_len_fmt, file_len);
+  size_t cl_len = strlen(cl_hdr);
 
   if (!f || err == VFS_RES_ERR || err2 == VFS_RES_ERR)
   {
     ENDUSER_SETUP_DEBUG("Unable to load file enduser_setup.html, loading default HTML...");
 
-    c_sprintf(cl_hdr, http_header_content_len_fmt, sizeof(enduser_setup_html_default));
-    cl_len = c_strlen(cl_hdr);
+    sprintf(cl_hdr, http_header_content_len_fmt, sizeof(enduser_setup_html_default));
+    cl_len = strlen(cl_hdr);
     int html_len = LITLEN(enduser_setup_html_default);
 
     if (enduser_setup_html_default[0] == 0x1f && enduser_setup_html_default[1] == 0x8b)
     {
-        ce_len = c_strlen(http_html_gzip_contentencoding);
+        ce_len = strlen(http_html_gzip_contentencoding);
         html_len = enduser_setup_html_default_len; /* Defined in enduser_setup/enduser_setup.html.gz.def.h by xxd -i */
         ENDUSER_SETUP_DEBUG("Content is gzipped");
     }
 
     int payload_len = LITLEN(http_header_200) + cl_len + ce_len + html_len;
     state->http_payload_len = payload_len;
-    state->http_payload_data = (char *) c_malloc(payload_len);
+    state->http_payload_data = (char *) malloc(payload_len);
 
     if (state->http_payload_data == NULL)
     {
@@ -490,17 +490,17 @@ static int enduser_setup_http_load_payload(void)
     }
 
     int offset = 0;
-    c_memcpy(&(state->http_payload_data[offset]), &(http_header_200), LITLEN(http_header_200));
+    memcpy(&(state->http_payload_data[offset]), &(http_header_200), LITLEN(http_header_200));
     offset += LITLEN(http_header_200);
 
     if (ce_len > 0)
     {
-        offset += c_sprintf(state->http_payload_data + offset, http_html_gzip_contentencoding, ce_len);
+        offset += sprintf(state->http_payload_data + offset, http_html_gzip_contentencoding, ce_len);
     }
 
-    c_memcpy(&(state->http_payload_data[offset]), &(cl_hdr), cl_len);
+    memcpy(&(state->http_payload_data[offset]), &(cl_hdr), cl_len);
     offset += cl_len;
-    c_memcpy(&(state->http_payload_data[offset]), &(enduser_setup_html_default), sizeof(enduser_setup_html_default));
+    memcpy(&(state->http_payload_data[offset]), &(enduser_setup_html_default), sizeof(enduser_setup_html_default));
 
     return 1;
   }
@@ -510,13 +510,13 @@ static int enduser_setup_http_load_payload(void)
 
   if (magic[0] == 0x1f && magic[1] == 0x8b)
   {
-    ce_len = c_strlen(http_html_gzip_contentencoding);
+    ce_len = strlen(http_html_gzip_contentencoding);
     ENDUSER_SETUP_DEBUG("Content is gzipped");
   }
 
   int payload_len = LITLEN(http_header_200) + cl_len + ce_len + file_len;
   state->http_payload_len = payload_len;
-  state->http_payload_data = (char *) c_malloc(payload_len);
+  state->http_payload_data = (char *) malloc(payload_len);
 
   if (state->http_payload_data == NULL)
   {
@@ -527,15 +527,15 @@ static int enduser_setup_http_load_payload(void)
 
   int offset = 0;
 
-  c_memcpy(&(state->http_payload_data[offset]), &(http_header_200), LITLEN(http_header_200));
+  memcpy(&(state->http_payload_data[offset]), &(http_header_200), LITLEN(http_header_200));
   offset += LITLEN(http_header_200);
 
   if (ce_len > 0)
   {
-    offset += c_sprintf(state->http_payload_data + offset, http_html_gzip_contentencoding, ce_len);
+    offset += sprintf(state->http_payload_data + offset, http_html_gzip_contentencoding, ce_len);
   }
 
-  c_memcpy(&(state->http_payload_data[offset]), &(cl_hdr), cl_len);
+  memcpy(&(state->http_payload_data[offset]), &(cl_hdr), cl_len);
   offset += cl_len;
   vfs_read(f, &(state->http_payload_data[offset]), file_len);
   vfs_close(f);
@@ -658,18 +658,18 @@ static void enduser_setup_free_keypairs(struct keypairs_t *kp) {
   
     if (kp->keypairs != NULL) {
         for (int i = 0; i < kp->keypairs_nb * 2; i++) {
-      os_free(kp->keypairs[i]);
+      free(kp->keypairs[i]);
     }
   }
-  os_free(kp->keypairs);
-  os_free(kp);
+  free(kp->keypairs);
+  free(kp);
 }
 
 static struct keypairs_t * enduser_setup_alloc_keypairs(int kp_number ){
-    struct keypairs_t *kp = os_malloc(sizeof(struct keypairs_t));
+    struct keypairs_t *kp = malloc(sizeof(struct keypairs_t));
     os_memset(kp, 0, sizeof(struct keypairs_t));
 
-    kp->keypairs = os_malloc(kp_number * 2 * sizeof(char *));
+    kp->keypairs = malloc(kp_number * 2 * sizeof(char *));
     kp->keypairs_nb = kp_number;
     return kp;
 }
@@ -691,7 +691,7 @@ static struct keypairs_t *enduser_setup_get_keypairs_from_form(char *form_body,
   int current_idx = 0;
   int err;
 
-  char *body_copy = os_malloc(form_length+1);
+  char *body_copy = malloc(form_length+1);
   os_bzero(body_copy, form_length+1);
   os_memcpy(body_copy, form_body, form_length);
   char *tok = strtok(body_copy, "=");
@@ -699,12 +699,12 @@ static struct keypairs_t *enduser_setup_get_keypairs_from_form(char *form_body,
   char last_tok = '=';
   while (tok) {
     size_t len = strlen(tok);
-    kp->keypairs[current_idx] = os_malloc(len + 1);
+    kp->keypairs[current_idx] = malloc(len + 1);
     err = enduser_setup_http_urldecode(kp->keypairs[current_idx], tok, len, len + 1);
     if (err) {
       ENDUSER_SETUP_DEBUG("Unable to decode parameter");
       enduser_setup_free_keypairs(kp);
-      os_free(body_copy);
+      free(body_copy);
       return NULL;
     }
 
@@ -712,7 +712,7 @@ static struct keypairs_t *enduser_setup_get_keypairs_from_form(char *form_body,
     if (current_idx > keypair_nb*2) {
       ENDUSER_SETUP_DEBUG("Too many keypairs!");
       enduser_setup_free_keypairs(kp);
-      os_free(body_copy);
+      free(body_copy);
       return NULL;
     }
 
@@ -724,7 +724,7 @@ static struct keypairs_t *enduser_setup_get_keypairs_from_form(char *form_body,
       last_tok='=';
     }
   }
-  os_free(body_copy);
+  free(body_copy);
   return kp;
 }
 
@@ -765,7 +765,7 @@ static int enduser_setup_write_file_with_extra_configuration_data(char *form_bod
   int idx = 0;
   for( idx = 0; idx < kp->keypairs_nb*2; idx=idx+2){
     char* to_write = kp->keypairs[idx];
-    size_t length = c_strlen(to_write);
+    size_t length = strlen(to_write);
     
     vfs_write(p_file, "p.", 2);
 
@@ -774,7 +774,7 @@ static int enduser_setup_write_file_with_extra_configuration_data(char *form_bod
     vfs_write(p_file, "=\"", 2);
     
     to_write = kp->keypairs[idx+1];
-    length = c_strlen(to_write);
+    length = strlen(to_write);
     vfs_write(p_file, to_write, length);
 
     vfs_write(p_file, "\"\n", 2);
@@ -824,14 +824,14 @@ static int enduser_setup_http_handle_credentials(char *data, unsigned short data
 
 
   struct station_config *cnf = luaM_malloc(lua_getstate(), sizeof(struct station_config));
-  c_memset(cnf, 0, sizeof(struct station_config));
+  memset(cnf, 0, sizeof(struct station_config));
   cnf->threshold.rssi = -127;
   cnf->threshold.authmode = AUTH_OPEN;
 
   int err;
   err  = enduser_setup_http_urldecode(cnf->ssid, name_str_start, name_str_len, sizeof(cnf->ssid));
   err |= enduser_setup_http_urldecode(cnf->password, pwd_str_start, pwd_str_len, sizeof(cnf->password));
-  if (err != 0 || c_strlen(cnf->ssid) == 0)
+  if (err != 0 || strlen(cnf->ssid) == 0)
   {
     ENDUSER_SETUP_DEBUG("Unable to decode HTTP parameter to valid password or SSID");
     return 1;
@@ -990,21 +990,21 @@ static void enduser_setup_serve_status(struct tcp_pcb *conn)
         ip_addr[0] = '\0';
         if (curr_state == STATION_GOT_IP)
         {
-          c_sprintf (ip_addr, "%d.%d.%d.%d", IP2STR(&ip_info.ip.addr));
+          sprintf (ip_addr, "%d.%d.%d.%d", IP2STR(&ip_info.ip.addr));
         }
 
-        int state_len = c_strlen(s);
-        int ip_len = c_strlen(ip_addr);
-        int ssid_len = c_strlen(config.ssid);
+        int state_len = strlen(s);
+        int ip_len = strlen(ip_addr);
+        int ssid_len = strlen(config.ssid);
         int status_len = state_len + ssid_len + ip_len + 1;
         char status_buf[status_len];
         memset(status_buf, 0, status_len);
-        status_len = c_sprintf(status_buf, s, config.ssid, ip_addr);
+        status_len = sprintf(status_buf, s, config.ssid, ip_addr);
 
         int buf_len = sizeof(fmt) + status_len + 10; /* 10 = (9+1), 1 byte is '\0' and 9 are reserved for length field */
         char buf[buf_len];
         memset(buf, 0, buf_len);
-        int output_len = c_sprintf(buf, fmt, status_len, status_buf);
+        int output_len = sprintf(buf, fmt, status_len, status_buf);
 
         enduser_setup_http_serve_header(conn, buf, output_len);
       }
@@ -1014,11 +1014,11 @@ static void enduser_setup_serve_status(struct tcp_pcb *conn)
       default:
       {
         const char *s = states[curr_state];
-        int status_len = c_strlen(s);
+        int status_len = strlen(s);
         int buf_len = sizeof(fmt) + status_len + 10; /* 10 = (9+1), 1 byte is '\0' and 9 are reserved for length field */
         char buf[buf_len];
         memset(buf, 0, buf_len);
-        int output_len = c_sprintf(buf, fmt, status_len, s);
+        int output_len = sprintf(buf, fmt, status_len, s);
 
         enduser_setup_http_serve_header(conn, buf, output_len);
       }
@@ -1048,13 +1048,13 @@ static void enduser_setup_serve_status_as_json (struct tcp_pcb *http_client)
     /* If IP address not yet available, get now */
     if (strlen(ipaddr) == 0)
     {
-      c_sprintf(ipaddr, "%d.%d.%d.%d", IP2STR(&ip_info.ip.addr));
+      sprintf(ipaddr, "%d.%d.%d.%d", IP2STR(&ip_info.ip.addr));
     }
-    c_sprintf(json_payload, "{\"deviceid\":\"%s\", \"status\":%d}", ipaddr, curr_status);
+    sprintf(json_payload, "{\"deviceid\":\"%s\", \"status\":%d}", ipaddr, curr_status);
   }
   else
   {
-    c_sprintf(json_payload, "{\"deviceid\":\"%06X\", \"status\":%d}", system_get_chip_id(), curr_status);
+    sprintf(json_payload, "{\"deviceid\":\"%06X\", \"status\":%d}", system_get_chip_id(), curr_status);
   }
 
   const char fmt[] =
@@ -1067,9 +1067,9 @@ static void enduser_setup_serve_status_as_json (struct tcp_pcb *http_client)
     "\r\n"
     "%s";
 
-  int len = c_strlen(json_payload);
-  char buf[c_strlen(fmt) + NUMLEN(len) + len - 4];
-  len = c_sprintf (buf, fmt, len, json_payload);
+  int len = strlen(json_payload);
+  char buf[strlen(fmt) + NUMLEN(len) + len - 4];
+  len = sprintf (buf, fmt, len, json_payload);
   enduser_setup_http_serve_header (http_client, buf, len);
 }
 
@@ -1098,15 +1098,15 @@ static void enduser_setup_handle_OPTIONS (struct tcp_pcb *http_client, char *dat
 
   int type = 0;
 
-  if (c_strncmp(data, "GET ", 4) == 0)
+  if (strncmp(data, "GET ", 4) == 0)
   {
-    if (c_strncmp(data + 4, "/aplist", 7) == 0 || c_strncmp(data + 4, "/setwifi?", 9) == 0 || c_strncmp(data + 4, "/status.json", 12) == 0)
+    if (strncmp(data + 4, "/aplist", 7) == 0 || strncmp(data + 4, "/setwifi?", 9) == 0 || strncmp(data + 4, "/status.json", 12) == 0)
     {
-      enduser_setup_http_serve_header (http_client, json, c_strlen(json));
+      enduser_setup_http_serve_header (http_client, json, strlen(json));
       return;
    }
   }
-  enduser_setup_http_serve_header (http_client, others, c_strlen(others));
+  enduser_setup_http_serve_header (http_client, others, strlen(others));
   return;
 }
 
@@ -1114,7 +1114,7 @@ static void enduser_setup_handle_OPTIONS (struct tcp_pcb *http_client, char *dat
 static err_t enduser_setup_handle_POST(struct tcp_pcb *http_client, char* data, size_t data_len)
 {
     ENDUSER_SETUP_DEBUG("Handling POST");
-    if (c_strncmp(data + 5, "/setwifi ", 9) == 0) // User clicked the submit button
+    if (strncmp(data + 5, "/setwifi ", 9) == 0) // User clicked the submit button
     {
       switch (enduser_setup_http_handle_credentials(data, data_len))
       {
@@ -1123,7 +1123,7 @@ static err_t enduser_setup_handle_POST(struct tcp_pcb *http_client, char* data,
           char* body=strstr(data, "\r\n\r\n");
           char *content_length_str = strstr(data, "Content-Length: ");
           if( body != NULL && content_length_str != NULL){
-            int bodylength = c_atoi(content_length_str + 16);
+            int bodylength = atoi(content_length_str + 16);
             body += 4; // length of the double CRLF found above
             enduser_setup_write_file_with_extra_configuration_data(body, bodylength);
           }
@@ -1157,7 +1157,7 @@ static void free_scan_listeners (void)
   while (l)
   {
     next = l->next;
-    c_free (l);
+    free (l);
     l = next;
   }
   state->scan_listeners = 0;
@@ -1177,7 +1177,7 @@ static void remove_scan_listener (scan_listener_t *l)
       if (*sl == l)
       {
         *sl = l->next;
-        c_free (l);
+        free (l);
         /* No early exit to guard against multi-entry on list */
       }
       else
@@ -1256,7 +1256,7 @@ static void on_scan_done (void *arg, STATUS status)
     /* To be able to safely escape a pathological SSID, we need 2*32 bytes */
     const size_t max_entry_sz = 27 + 2*32 + 6; /* {"ssid":"","rssi":,"chan":} */
     const size_t alloc_sz = hdr_sz + num_nets * max_entry_sz + 3;
-    char *http = os_zalloc (alloc_sz);
+    char *http = calloc (1, alloc_sz);
     if (!http)
     {
       goto serve_500;
@@ -1282,26 +1282,26 @@ static void on_scan_done (void *arg, STATUS status)
       strcpy (p, entry_mid);
       p += sizeof (entry_mid) -1;
 
-      p += c_sprintf (p, "%d", wn->rssi);
+      p += sprintf (p, "%d", wn->rssi);
 
       const char entry_chan[] = ",\"chan\":";
       strcpy (p, entry_chan);
       p += sizeof (entry_chan) -1;
 
-      p += c_sprintf (p, "%d", wn->channel);
+      p += sprintf (p, "%d", wn->channel);
 
       *p++ = '}';
     }
     *p++ = ']';
 
     size_t body_sz = (p - http) - hdr_sz;
-    c_sprintf (http, header_fmt, body_sz);
+    sprintf (http, header_fmt, body_sz);
     http[hdr_sz] = '['; /* Rewrite the \0 with the correct start of body */
 
     notify_scan_listeners (http, hdr_sz + body_sz);
     ENDUSER_SETUP_DEBUG(http + hdr_sz);
 
-    c_free (http);
+    free (http);
     return;
   }
 
@@ -1334,7 +1334,7 @@ static err_t enduser_setup_http_recvcb(void *arg, struct tcp_pcb *http_client, s
     return ERR_OK;
   }
 
-  char *data = os_zalloc (p->tot_len + 1);
+  char *data = calloc (1, p->tot_len + 1);
   if (!data)
     return ERR_MEM;
 
@@ -1348,9 +1348,9 @@ static err_t enduser_setup_http_recvcb(void *arg, struct tcp_pcb *http_client, s
   ENDUSER_SETUP_DEBUG(data);
 #endif
 
-  if (c_strncmp(data, "GET ", 4) == 0)
+  if (strncmp(data, "GET ", 4) == 0)
   {
-    if (c_strncmp(data + 4, "/ ", 2) == 0 || c_strncmp(data + 4, "/?", 2) == 0)
+    if (strncmp(data + 4, "/ ", 2) == 0 || strncmp(data + 4, "/?", 2) == 0)
     {
       if (enduser_setup_http_serve_html(http_client) != 0)
       {
@@ -1361,12 +1361,12 @@ static err_t enduser_setup_http_recvcb(void *arg, struct tcp_pcb *http_client, s
         goto free_out; /* streaming now in progress */
       }
     }
-    else if (c_strncmp(data + 4, "/aplist", 7) == 0)
+    else if (strncmp(data + 4, "/aplist", 7) == 0)
     {
       /* Don't do an AP Scan while station is trying to connect to Wi-Fi */
       if (state->connecting == 0)
       {
-        scan_listener_t *l = os_malloc (sizeof (scan_listener_t));
+        scan_listener_t *l = malloc (sizeof (scan_listener_t));
         if (!l)
         {
           ENDUSER_SETUP_ERROR("out of memory", ENDUSER_SETUP_ERR_OUT_OF_MEMORY, ENDUSER_SETUP_ERR_NONFATAL);
@@ -1398,16 +1398,16 @@ static err_t enduser_setup_http_recvcb(void *arg, struct tcp_pcb *http_client, s
         enduser_setup_http_serve_header(http_client, http_header_204, LITLEN(http_header_204));
       }
     }
-    else if (c_strncmp(data + 4, "/status.json", 12) == 0)
+    else if (strncmp(data + 4, "/status.json", 12) == 0)
     {
     enduser_setup_serve_status_as_json(http_client);
     }
-    else if (c_strncmp(data + 4, "/status", 7) == 0)
+    else if (strncmp(data + 4, "/status", 7) == 0)
     {
       enduser_setup_serve_status(http_client);
     }
 
-    else if (c_strncmp(data + 4, "/update?", 8) == 0)
+    else if (strncmp(data + 4, "/update?", 8) == 0)
     {
       switch (enduser_setup_http_handle_credentials(data, data_len))
       {
@@ -1422,7 +1422,7 @@ static err_t enduser_setup_http_recvcb(void *arg, struct tcp_pcb *http_client, s
           break;
       }
     }
-    else if (c_strncmp(data + 4, "/generate_204", 13) == 0)
+    else if (strncmp(data + 4, "/generate_204", 13) == 0)
     {
       /* Convince Android devices that they have internet access to avoid pesky dialogues. */
       enduser_setup_http_serve_header(http_client, http_header_204, LITLEN(http_header_204));
@@ -1433,11 +1433,11 @@ static err_t enduser_setup_http_recvcb(void *arg, struct tcp_pcb *http_client, s
       enduser_setup_http_serve_header(http_client, http_header_404, LITLEN(http_header_404));
     }
   }
-  else if (c_strncmp(data, "OPTIONS ", 8) == 0)
+  else if (strncmp(data, "OPTIONS ", 8) == 0)
   {
      enduser_setup_handle_OPTIONS(http_client, data, data_len);
   }
-  else if (c_strncmp(data, "POST ", 5) == 0)
+  else if (strncmp(data, "POST ", 5) == 0)
   {
     enduser_setup_handle_POST(http_client, data, data_len);
   }
@@ -1449,7 +1449,7 @@ static err_t enduser_setup_http_recvcb(void *arg, struct tcp_pcb *http_client, s
   deferred_close (http_client);
 
 free_out:
-  os_free (data);
+  free (data);
   return ret;
 }
 
@@ -1542,20 +1542,20 @@ static void enduser_setup_ap_start(void)
   ENDUSER_SETUP_DEBUG("enduser_setup_ap_start");
 
   struct softap_config cnf;
-  c_memset(&(cnf), 0, sizeof(struct softap_config));
+  memset(&(cnf), 0, sizeof(struct softap_config));
 
 #ifndef ENDUSER_SETUP_AP_SSID
   #define ENDUSER_SETUP_AP_SSID "SetupGadget"
 #endif
 
   char ssid[] = ENDUSER_SETUP_AP_SSID;
-  int ssid_name_len = c_strlen(ssid);
-  c_memcpy(&(cnf.ssid), ssid, ssid_name_len);
+  int ssid_name_len = strlen(ssid);
+  memcpy(&(cnf.ssid), ssid, ssid_name_len);
 
   uint8_t mac[6];
   wifi_get_macaddr(SOFTAP_IF, mac);
   cnf.ssid[ssid_name_len] = '_';
-  c_sprintf(cnf.ssid + ssid_name_len + 1, "%02X%02X%02X", mac[3], mac[4], mac[5]);
+  sprintf(cnf.ssid + ssid_name_len + 1, "%02X%02X%02X", mac[3], mac[4], mac[5]);
   cnf.ssid_len = ssid_name_len + 7;
   cnf.channel = state == NULL? 1 : state->softAPchannel;
   cnf.authmode = AUTH_OPEN;
@@ -1567,7 +1567,7 @@ static void enduser_setup_ap_start(void)
 
 #if ENDUSER_SETUP_DEBUG_ENABLE
   char debuginfo[100];
-  c_sprintf(debuginfo, "SSID: %s, CHAN: %d", cnf.ssid, cnf.channel);
+  sprintf(debuginfo, "SSID: %s, CHAN: %d", cnf.ssid, cnf.channel);
   ENDUSER_SETUP_DEBUG(debuginfo);
 #endif
 }
@@ -1614,15 +1614,15 @@ static void enduser_setup_dns_recv_callback(void *arg, char *recv_data, unsigned
   struct espconn *callback_espconn = arg;
   struct ip_info ip_info;
 
-  uint32_t qname_len = c_strlen(&(recv_data[12])) + 1; /* \0=1byte */
+  uint32_t qname_len = strlen(&(recv_data[12])) + 1; /* \0=1byte */
   uint32_t dns_reply_static_len = (uint32_t) sizeof(dns_header) + (uint32_t) sizeof(dns_body) + 2 + 4; /* dns_id=2bytes, ip=4bytes */
   uint32_t dns_reply_len = dns_reply_static_len + qname_len;
 
 #if ENDUSER_SETUP_DEBUG_ENABLE
-  char *qname = c_malloc(qname_len + 12);
+  char *qname = malloc(qname_len + 12);
   if (qname != NULL)
   {
-    c_sprintf(qname, "DNS QUERY = %s", &(recv_data[12]));
+    sprintf(qname, "DNS QUERY = %s", &(recv_data[12]));
 
     uint32_t p;
     int i, j;
@@ -1639,7 +1639,7 @@ static void enduser_setup_dns_recv_callback(void *arg, char *recv_data, unsigned
     }
     qname[i-1]='\0';
     ENDUSER_SETUP_DEBUG(qname);
-    c_free(qname);
+    free(qname);
   }
 #endif
 
@@ -1656,22 +1656,22 @@ static void enduser_setup_dns_recv_callback(void *arg, char *recv_data, unsigned
   }
 
 
-  char *dns_reply = (char *) c_malloc(dns_reply_len);
+  char *dns_reply = (char *) malloc(dns_reply_len);
   if (dns_reply == NULL)
   {
     ENDUSER_SETUP_ERROR_VOID("dns_recv_callback failed. Failed to allocate memory.", ENDUSER_SETUP_ERR_OUT_OF_MEMORY, ENDUSER_SETUP_ERR_NONFATAL);
   }
 
   uint32_t insert_byte = 0;
-  c_memcpy(&(dns_reply[insert_byte]), recv_data, 2);
+  memcpy(&(dns_reply[insert_byte]), recv_data, 2);
   insert_byte += 2;
-  c_memcpy(&(dns_reply[insert_byte]), dns_header, sizeof(dns_header));
+  memcpy(&(dns_reply[insert_byte]), dns_header, sizeof(dns_header));
   insert_byte += (uint32_t) sizeof(dns_header);
-  c_memcpy(&(dns_reply[insert_byte]), &(recv_data[12]), qname_len);
+  memcpy(&(dns_reply[insert_byte]), &(recv_data[12]), qname_len);
   insert_byte += qname_len;
-  c_memcpy(&(dns_reply[insert_byte]), dns_body, sizeof(dns_body));
+  memcpy(&(dns_reply[insert_byte]), dns_body, sizeof(dns_body));
   insert_byte += (uint32_t) sizeof(dns_body);
-  c_memcpy(&(dns_reply[insert_byte]), &(ip_info.ip), 4);
+  memcpy(&(dns_reply[insert_byte]), &(ip_info.ip), 4);
 
   /* SDK 1.4.0 changed behaviour, for UDP server need to look up remote ip/port */
   remot_info *pr = 0;
@@ -1684,7 +1684,7 @@ static void enduser_setup_dns_recv_callback(void *arg, char *recv_data, unsigned
 
   int8_t err;
   err = espconn_send(callback_espconn, dns_reply, dns_reply_len);
-  c_free(dns_reply);
+  free(dns_reply);
   if (err == ESPCONN_MEM)
   {
     ENDUSER_SETUP_ERROR_VOID("dns_recv_callback failed. Failed to allocate memory for send.", ENDUSER_SETUP_ERR_OUT_OF_MEMORY, ENDUSER_SETUP_ERR_FATAL);
@@ -1725,16 +1725,16 @@ static void enduser_setup_free(void)
   {
     if (state->espconn_dns_udp->proto.udp != NULL)
     {
-      c_free(state->espconn_dns_udp->proto.udp);
+      free(state->espconn_dns_udp->proto.udp);
     }
-    c_free(state->espconn_dns_udp);
+    free(state->espconn_dns_udp);
   }
 
-  c_free(state->http_payload_data);
+  free(state->http_payload_data);
 
   free_scan_listeners ();
 
-  c_free(state);
+  free(state);
   state = NULL;
 }
 
@@ -1747,20 +1747,20 @@ static int enduser_setup_dns_start(void)
   {
     ENDUSER_SETUP_ERROR("dns_start failed. Appears to already be started (espconn_dns_udp != NULL).", ENDUSER_SETUP_ERR_ALREADY_INITIALIZED, ENDUSER_SETUP_ERR_FATAL);
   }
-  state->espconn_dns_udp = (struct espconn *) c_malloc(sizeof(struct espconn));
+  state->espconn_dns_udp = (struct espconn *) malloc(sizeof(struct espconn));
   if (state->espconn_dns_udp == NULL)
   {
     ENDUSER_SETUP_ERROR("dns_start failed. Memory allocation failed (espconn_dns_udp == NULL).", ENDUSER_SETUP_ERR_OUT_OF_MEMORY, ENDUSER_SETUP_ERR_FATAL);
   }
 
-  esp_udp *esp_udp_data = (esp_udp *) c_malloc(sizeof(esp_udp));
+  esp_udp *esp_udp_data = (esp_udp *) malloc(sizeof(esp_udp));
   if (esp_udp_data == NULL)
   {
     ENDUSER_SETUP_ERROR("dns_start failed. Memory allocation failed (esp_udp == NULL).", ENDUSER_SETUP_ERR_OUT_OF_MEMORY, ENDUSER_SETUP_ERR_FATAL);
   }
 
-  c_memset(state->espconn_dns_udp, 0, sizeof(struct espconn));
-  c_memset(esp_udp_data, 0, sizeof(esp_udp));
+  memset(state->espconn_dns_udp, 0, sizeof(struct espconn));
+  memset(esp_udp_data, 0, sizeof(esp_udp));
   state->espconn_dns_udp->proto.udp = esp_udp_data;
   state->espconn_dns_udp->type = ESPCONN_UDP;
   state->espconn_dns_udp->state = ESPCONN_NONE;
@@ -1816,7 +1816,7 @@ static int enduser_setup_init(lua_State *L)
   }
   else
   {
-    state = (enduser_setup_state_t *) os_zalloc(sizeof(enduser_setup_state_t));
+    state = (enduser_setup_state_t *) calloc(1, sizeof(enduser_setup_state_t));
 
     if (state == NULL)
     {
@@ -1824,7 +1824,7 @@ static int enduser_setup_init(lua_State *L)
     }
     else
     {
-      c_memset(state, 0, sizeof(enduser_setup_state_t));
+      memset(state, 0, sizeof(enduser_setup_state_t));
 
       state->lua_connected_cb_ref = LUA_NOREF;
       state->lua_err_cb_ref = LUA_NOREF;

+ 7 - 7
app/modules/file.c

@@ -7,7 +7,7 @@
 
 #include "c_types.h"
 #include "vfs.h"
-#include "c_string.h"
+#include <string.h>
 
 #include <alloca.h>
 
@@ -190,7 +190,7 @@ static int file_open( lua_State* L )
 
   const char *fname = luaL_checklstring( L, 1, &len );
   const char *basename = vfs_basename( fname );
-  luaL_argcheck(L, c_strlen(basename) <= FS_OBJ_NAME_LEN && c_strlen(fname) == len, 1, "filename invalid");
+  luaL_argcheck(L, strlen(basename) <= FS_OBJ_NAME_LEN && strlen(fname) == len, 1, "filename invalid");
 
   const char *mode = luaL_optstring(L, 2, "r");
 
@@ -303,7 +303,7 @@ static int file_exists( lua_State* L )
   size_t len;
   const char *fname = luaL_checklstring( L, 1, &len );
   const char *basename = vfs_basename( fname );
-  luaL_argcheck(L, c_strlen(basename) <= FS_OBJ_NAME_LEN && c_strlen(fname) == len, 1, "filename invalid");
+  luaL_argcheck(L, strlen(basename) <= FS_OBJ_NAME_LEN && strlen(fname) == len, 1, "filename invalid");
 
   struct vfs_stat stat;
   lua_pushboolean(L, vfs_stat((char *)fname, &stat) == VFS_RES_OK ? 1 : 0);
@@ -317,7 +317,7 @@ static int file_remove( lua_State* L )
   size_t len;
   const char *fname = luaL_checklstring( L, 1, &len );
   const char *basename = vfs_basename( fname );
-  luaL_argcheck(L, c_strlen(basename) <= FS_OBJ_NAME_LEN && c_strlen(fname) == len, 1, "filename invalid");
+  luaL_argcheck(L, strlen(basename) <= FS_OBJ_NAME_LEN && strlen(fname) == len, 1, "filename invalid");
   vfs_remove((char *)fname);
   return 0;
 }
@@ -343,11 +343,11 @@ static int file_rename( lua_State* L )
 
   const char *oldname = luaL_checklstring( L, 1, &len );
   const char *basename = vfs_basename( oldname );
-  luaL_argcheck(L, c_strlen(basename) <= FS_OBJ_NAME_LEN && c_strlen(oldname) == len, 1, "filename invalid");
+  luaL_argcheck(L, strlen(basename) <= FS_OBJ_NAME_LEN && strlen(oldname) == len, 1, "filename invalid");
 
   const char *newname = luaL_checklstring( L, 2, &len );
   basename = vfs_basename( newname );
-  luaL_argcheck(L, c_strlen(basename) <= FS_OBJ_NAME_LEN && c_strlen(newname) == len, 2, "filename invalid");
+  luaL_argcheck(L, strlen(basename) <= FS_OBJ_NAME_LEN && strlen(newname) == len, 2, "filename invalid");
 
   if(0 <= vfs_rename( oldname, newname )){
     lua_pushboolean(L, 1);
@@ -362,7 +362,7 @@ static int file_stat( lua_State* L )
 {
   size_t len;
   const char *fname = luaL_checklstring( L, 1, &len );
-  luaL_argcheck( L, c_strlen(fname) <= FS_OBJ_NAME_LEN && c_strlen(fname) == len, 1, "filename invalid" );
+  luaL_argcheck( L, strlen(fname) <= FS_OBJ_NAME_LEN && strlen(fname) == len, 1, "filename invalid" );
 
   struct vfs_stat stat;
   if (vfs_stat( (char *)fname, &stat ) != VFS_RES_OK) {

+ 1 - 1
app/modules/gpio.c

@@ -7,7 +7,7 @@
 #include "platform.h"
 #include "user_interface.h"
 #include "c_types.h"
-#include "c_string.h"
+#include <string.h>
 #include "gpio.h"
 #include "hw_timer.h"
 

+ 1 - 1
app/modules/gpio_pulse.c

@@ -4,7 +4,7 @@
 #include "platform.h"
 #include "user_interface.h"
 #include "c_types.h"
-#include "c_string.h"
+#include <string.h>
 #include "gpio.h"
 #include "hw_timer.h"
 #include "pin_map.h"

+ 3 - 3
app/modules/hdc1080.c

@@ -7,9 +7,9 @@
 #include "module.h"
 #include "lauxlib.h"
 #include "platform.h"
-#include "c_stdlib.h"
-#include "c_string.h"
-#include "c_math.h"
+#include <stdlib.h>
+#include <string.h>
+#include <math.h>
 
 static const uint32_t hdc1080_i2c_id = 0;
 static const uint8_t hdc1080_i2c_addr = 0x40;

+ 2 - 2
app/modules/hmc5883l.c

@@ -6,8 +6,8 @@
 #include "module.h"
 #include "lauxlib.h"
 #include "platform.h"
-#include "c_stdlib.h"
-#include "c_string.h"
+#include <stdlib.h>
+#include <string.h>
 
 static const uint32_t hmc5883_i2c_id = 0;
 static const uint8_t hmc5883_i2c_addr = 0x1E;

Some files were not shown because too many files changed in this diff