made itoa and dbgln empty macros if no textIO is available to remove overhead

master
Anton Lydike 3 years ago
parent 5dccd2dc80
commit 828ea0c2e2

@ -2,10 +2,6 @@
#ifdef TEXT_IO_ADDR #ifdef TEXT_IO_ADDR
#ifndef TEXT_IO_BUFLEN
#error "When defining TEXT_IO_ADDR, please also provide TEXT_IO_BUFLEN, otherwise textIO won't work!"
#endif
void dbgln(char* text, int len) void dbgln(char* text, int len)
{ {
while (len > TEXT_IO_BUFLEN) { while (len > TEXT_IO_BUFLEN) {
@ -68,11 +64,7 @@ char* itoa (int value, char* str, int base)
#else #else
/* if no textIO module loaded, dbgln is a noop :( */ // this is included to prevent "error: ISO C forbids an empty translation unit [-Wpedantic]"
void dbgln(char* text, int len){} typedef int make_iso_compilers_happy;
char* itoa (int value, char* str, int base) {
return str;
}
#endif #endif

@ -1,10 +1,26 @@
#ifndef H_IO #ifndef H_IO
#define H_IO #define H_IO
// if we have a textIO module
#ifdef TEXT_IO_ADDR
#ifndef TEXT_IO_BUFLEN
#error "When defining TEXT_IO_ADDR, please also provide TEXT_IO_BUFLEN, otherwise textIO won't work!"
#endif
/* print a line to the debug textIO module */ /* print a line to the debug textIO module */
void dbgln(char* text, int len); void dbgln(char* text, int len);
/* alphabet for itoa */ /* alphabet for itoa */
char* itoa (int value, char* str, int base); char* itoa (int value, char* str, int base);
#else
// if we don't have textio, dbgln becomes an empty macro to save on cycles
#define dbgln(a,b)
// itoa just evaluates to the passes pointer
#define itoa(a,b,c) b
#endif
#endif #endif

Loading…
Cancel
Save