some more stack shrinking

sipo
Ondřej Hruška 6 years ago
parent 8a28395102
commit 69443613fc
Signed by: MightyPork
GPG Key ID: 2C5FD5035250423D
  1. 34
      debug.c
  2. 25
      debug.h
  3. 4
      framework/unit_registry.c
  4. 2
      gex.mk
  5. 17
      platform/debug_uart.c
  6. 2
      platform/debug_uart.h
  7. 12
      utils/ini_writer.c
  8. 9
      utils/ini_writer.h

@ -8,7 +8,7 @@
#if USE_DEBUG_UART
// debug printf
int _DO_PRINTF(const char *format, ...)
void _DO_PRINTF(const char *format, ...)
{
va_list args;
int len;
@ -25,8 +25,6 @@ int _DO_PRINTF(const char *format, ...)
_write_r(NULL, 2, dbg_buf, (size_t) len);
va_end(args);
return len;
}
/**
@ -34,19 +32,10 @@ int _DO_PRINTF(const char *format, ...)
* @param string - buffer to print
* @param len - number of bytes to print
*/
void PUTSN(const char *string, size_t len)
{
if (len == 0) len = strlen(string);
_write_r(NULL, 2, string, (size_t) len);
}
/**
* Puts a newline
*
*/
void PUTNL(void)
void PUTSN(const char *string, uint16_t len)
{
_write_r(NULL, 2, "\r\n", 2);
if (len == 0) len = (uint16_t) strlen(string);
debug_write(string, len);
}
/**
@ -54,22 +43,11 @@ void PUTNL(void)
* @param string - string to print, zero-terminated
* @return number of characters printed
*/
int PUTS(const char *string)
void PUTS(const char *string)
{
size_t len = strlen(string);
_write_r(NULL, 2, string, len);
return (int) len;
debug_write(string, (uint16_t) len);
}
/**
* Print one character to debug uart
* @param ch - character ASCII code
* @return the character code
*/
int PUTCHAR(int ch)
{
_write_r(NULL, 2, &ch, 1);
return ch; // or EOF
}
#endif

@ -11,11 +11,26 @@
#if USE_DEBUG_UART
int _DO_PRINTF(const char *format, ...) __attribute__((format(printf,1,2))) ;
void PUTSN(const char *string, size_t len);
int PUTS(const char *string);
void PUTNL(void);
int PUTCHAR(int ch);
extern void debug_write(const char *buf, uint16_t len);
void _DO_PRINTF(const char *format, ...) __attribute__((format(printf,1,2))) ;
void PUTSN(const char *string, uint16_t len);
void PUTS(const char *string);
static inline void PUTNL(void)
{
debug_write("\r\n", 2);
}
/**
* Print one character to debug uart
* @param ch - character ASCII code
* @return the character code
*/
static inline void PUTCHAR(char ch)
{
debug_write(&ch, 1);
}
#define PRINTF(format, ...) do { \
if (VA_ARG_COUNT(__VA_ARGS__) == 0) { \

@ -364,12 +364,12 @@ static void export_unit_do(UlistEntry *li, IniWriter *iw)
{
// special message for failed unit die to resource
if (pUnit->status == E_RESOURCE_NOT_AVAILABLE) {
iw_comment(iw, "!!! %s not available, already held by %s",
iw_commentf(iw, "!!! %s not available, already held by %s",
rsc_get_name(pUnit->failed_rsc),
rsc_get_owner_name(pUnit->failed_rsc));
}
else {
iw_comment(iw, "!!! %s", error_get_message(pUnit->status));
iw_commentf(iw, "!!! %s", error_get_message(pUnit->status));
}
iw_cmt_newline(iw);
}

@ -57,7 +57,7 @@ GEX_CFLAGS = \
-MD -Wno-redundant-decls -Wno-unused-parameter \
-Wno-unused-variable -Wno-inline \
-fmerge-constants -fmerge-all-constants -Wno-implicit-fallthrough \
-fno-exceptions -finline-small-functions -findirect-inlining -Wno-strict-aliasing -Wno-float-equal -Wno-discarded-qualifiers
-fno-exceptions -finline-small-functions -findirect-inlining -Wno-strict-aliasing -Wno-float-equal -Wno-discarded-qualifiers -fstack-usage
GEX_CDEFS_BASE = \
-D__weak="__attribute__((weak))" \

@ -106,18 +106,19 @@ void DebugUart_PreInit(void)
LL_USART_Enable(DEBUG_USART);
}
/** Debug print, used by debug / newlib */
ssize_t _write_r(struct _reent *rptr, int fd, const void *buf, size_t len)
void debug_write(const char *buf, uint16_t len)
{
(void)rptr;
uint8_t *buff = buf;
for (uint32_t i = 0; i < len; i++) {
for (uint16_t i = 0; i < len; i++) {
while (!LL_USART_IsActiveFlag_TC(DEBUG_USART));
LL_USART_TransmitData8(DEBUG_USART, *buff++);
LL_USART_TransmitData8(DEBUG_USART, (uint8_t) *buf++);
}
}
/** Debug print, used by debug / newlib */
ssize_t _write_r(struct _reent *rptr, int fd, const void *buf, size_t len)
{
(void)rptr;
debug_write(buf, len);
return len;
}

@ -8,4 +8,6 @@
void DebugUart_PreInit(void);
void DebugUart_Init(void);
void debug_write(const char *buf, uint16_t len);
#endif //GEX_DEBUG_UART_H

@ -82,7 +82,7 @@ void iw_section(IniWriter *iw, const char *format, ...)
iw_string(iw, "]\r\n");
}
void iw_comment(IniWriter *iw, const char *format, ...)
void iw_commentf(IniWriter *iw, const char *format, ...)
{
if (iw->count == 0) return;
if (!SystemSettings.ini_comments) return;
@ -92,6 +92,16 @@ void iw_comment(IniWriter *iw, const char *format, ...)
iw_newline(iw);
}
void iw_comment(IniWriter *iw, const char *text)
{
if (iw->count == 0) return;
if (!SystemSettings.ini_comments) return;
iw_string(iw, "# ");
iw_string(iw, text);
iw_newline(iw);
}
void iw_hdr_comment(IniWriter *iw, const char *format, ...)
{
if (iw->count == 0) return;

@ -85,13 +85,20 @@ void iw_sprintf(IniWriter *iw, const char *format, ...)
void iw_section(IniWriter *iw, const char *format, ...)
__attribute__((format(printf,2,3)));
/**
* Try to write a INI comment # blah\r\n
* @param iw - iniwriter handle
* @param text - format, like printf
*/
void iw_comment(IniWriter *iw, const char *text);
/**
* Try to write a INI comment # blah\r\n
* @param iw - iniwriter handle
* @param format - format, like printf
* @param ... - replacements
*/
void iw_comment(IniWriter *iw, const char *format, ...)
void iw_commentf(IniWriter *iw, const char *format, ...)
__attribute__((format(printf,2,3)));
/**

Loading…
Cancel
Save