Uploaded image for project: 'Embedded Software & Tools'
  1. Embedded Software & Tools
  2. EXT_EP-10804

Using --printf_support=minimal uses up much more stack than required

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Unresolved
    • Icon: Medium Medium

      The internal RTS header file format.h has these lines ...

      #ifndef __FORMAT_H
      #define __FORMAT_H
      #include <stdarg.h>
      
      #if defined (MINIMAL)
      #define FORMAT_CONVERSION_BUFSIZE 32
      #elif defined (__MSP430__)
      #define F_CONVERSION_BUFSIZE      100
      #define FLOAT_VALUE_BUFSIZE       32
      #else
      /****************************************************************************/
      /*   The minimum max conversion size to be C89 compliant is 509             */
      /****************************************************************************/
      #define F_CONVERSION_BUFSIZE      510
      #define FLOAT_VALUE_BUFSIZE       100
      #endif
      

      The RTS source file _printfi.c has these lines ...

      /**************************************************************************/
      /*  Full printf definition                                                */
      /**************************************************************************/
      #define _PRINTFI __TI_printfi
      #include "_printfi_template.c"
      #undef _PRINTFI
      /**************************************************************************/
      /*  No float printf definition                                            */
      /**************************************************************************/
      #define _PRINTFI __TI_printfi_nofloat
      #define NOFLOAT
      #include "_printfi_template.c"
      #undef NOFLOAT
      #undef _PRINTFI
      /**************************************************************************/
      /*  Minimal printf definition                                             */
      /**************************************************************************/
      #define _PRINTFI __TI_printfi_minimal
      #define MINIMAL
      #include "_printfi_template.c"
      #undef MINIMAL
      #undef _PRINTFI
      

      Note how _printfi_template.c is included three times. The file _printfi_template.c includes format.h. Because of the inclusion guards, this definition ...

      #if defined (MINIMAL)
      #define FORMAT_CONVERSION_BUFSIZE 32
      

      ... is never seen. Even for --printf_support=minimal, FORMAT_CONVERSION_BUFSIZE is 510. Therefore this local buffer in the function _printfi_minimal ...

               char fld[FORMAT_CONVERSION_BUFSIZE];
      

      ... is 510 bytes, and not 32. This means _printfi_minimal uses much more stack space than required.

            syncuser TI User
            syncuser TI User
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: