Commit 526d21da authored by Johny Mattsson's avatar Johny Mattsson Committed by Terry Ellison
Browse files

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.
parent 9f8b74de
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
#include_next "ets_sys.h" #include_next "ets_sys.h"
#include "../libc/c_stdarg.h" #include <stdarg.h>
int ets_sprintf(char *str, const char *format, ...) __attribute__ ((format (printf, 2, 3))); int ets_sprintf(char *str, const char *format, ...) __attribute__ ((format (printf, 2, 3)));
......
#include <stdlib.h>
#include_next "mem.h"
#ifndef _SDK_OVERRIDE_OSAPI_H_ #ifndef _SDK_OVERRIDE_OSAPI_H_
#define _SDK_OVERRIDE_OSAPI_H_ #define _SDK_OVERRIDE_OSAPI_H_
#include "rom.h" #include_next "osapi.h"
int atoi(const char *nptr); #include <stddef.h>
int os_printf(const char *format, ...) __attribute__ ((format (printf, 1, 2))); #include "rom.h"
int os_printf_plus(const char *format, ...) __attribute__ ((format (printf, 1, 2)));
unsigned int uart_baudrate_detect(unsigned int uart_no, unsigned int async); unsigned int uart_baudrate_detect(unsigned int uart_no, unsigned int async);
...@@ -13,6 +12,4 @@ void NmiTimSetFunc(void (*func)(void)); ...@@ -13,6 +12,4 @@ void NmiTimSetFunc(void (*func)(void));
void call_user_start(void); void call_user_start(void);
#include_next "osapi.h"
#endif #endif
#ifndef __stdbool_h__
#define __stdbool_h__
// For compatibility with SDK. Boo.
#include_next "c_types.h"
#endif
#ifndef _OVERRIDE_STDIO_H_
#define _OVERRIDE_STDIO_H_
#include_next "stdio.h"
#ifdef __BUFSIZ__
# define BUFSIZ __BUFSIZ__
#else
# define BUFSIZ 1024
#endif
#define printf(...) do { \
unsigned char __printf_buf[BUFSIZ]; \
sprintf(__printf_buf, __VA_ARGS__); \
puts(__printf_buf); \
} while(0)
extern void output_redirect(const char *str);
#define puts output_redirect
#endif
#ifndef _OVERRIDE_STDLIB_H_
#define _OVERRIDE_STDLIB_H_
#include_next "stdlib.h"
#include "mem.h"
#define free os_free
#define malloc os_malloc
#define calloc(n,sz) os_zalloc(n*sz)
#define realloc os_realloc
#endif
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment