mirror of https://github.com/ARMmbed/mbed-os.git
Addressed review comments, in particular:
* Fixed wrapper functions for IAR * Fixed and renamed profile to minimal-printf.json * Moved minimal-printf under platform * Removed minimal-printf/mbed_lib.json * Modified exporter template to work with partial profile * Prevented optimization of printf to avoid compiler function substitutionpull/11051/head
parent
65ab34695e
commit
050a338771
|
|
@ -8,4 +8,4 @@ You can use the following command to run tests:
|
||||||
|
|
||||||
`mbed test -m K64F -t GCC_ARM -n *printf* -v -c`
|
`mbed test -m K64F -t GCC_ARM -n *printf* -v -c`
|
||||||
|
|
||||||
Do not use --profile mprintf so minimal-printf is not compared with itself.
|
Do not use --profile minimal-printf so minimal-printf is not compared with itself.
|
||||||
6
features/minimal-printf/TESTS/minimal-printf/compliance/main.cpp → TESTS/mbed_platform/minimal-printf/compliance/main.cpp
Executable file → Normal file
6
features/minimal-printf/TESTS/minimal-printf/compliance/main.cpp → TESTS/mbed_platform/minimal-printf/compliance/main.cpp
Executable file → Normal file
|
|
@ -17,7 +17,7 @@
|
||||||
#ifdef TARGET_LIKE_MBED
|
#ifdef TARGET_LIKE_MBED
|
||||||
#include "mbed.h"
|
#include "mbed.h"
|
||||||
#endif
|
#endif
|
||||||
#include "mbed_printf.h"
|
#include "platform/minimal-printf/mbed_printf.h"
|
||||||
|
|
||||||
#include "utest/utest.h"
|
#include "utest/utest.h"
|
||||||
#include "unity/unity.h"
|
#include "unity/unity.h"
|
||||||
|
|
@ -721,7 +721,7 @@ static control_t test_snprintf_x(const size_t call_count)
|
||||||
return CaseNext;
|
return CaseNext;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if MBED_CONF_MINIMAL_PRINTF_ENABLE_FLOATING_POINT
|
#if MBED_CONF_PLATFORM_MINIMAL_PRINTF_ENABLE_FLOATING_POINT
|
||||||
static control_t test_printf_f(const size_t call_count)
|
static control_t test_printf_f(const size_t call_count)
|
||||||
{
|
{
|
||||||
int result_baseline;
|
int result_baseline;
|
||||||
|
|
@ -902,7 +902,7 @@ Case cases[] = {
|
||||||
Case("snprintf %u", test_snprintf_u),
|
Case("snprintf %u", test_snprintf_u),
|
||||||
Case("printf %x", test_printf_x),
|
Case("printf %x", test_printf_x),
|
||||||
Case("snprintf %x", test_snprintf_x),
|
Case("snprintf %x", test_snprintf_x),
|
||||||
#if MBED_CONF_MINIMAL_PRINTF_ENABLE_FLOATING_POINT
|
#if MBED_CONF_PLATFORM_MINIMAL_PRINTF_ENABLE_FLOATING_POINT
|
||||||
Case("printf %f", test_printf_f),
|
Case("printf %f", test_printf_f),
|
||||||
Case("snprintf %f", test_snprintf_f),
|
Case("snprintf %f", test_snprintf_f),
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -18,6 +18,7 @@
|
||||||
|
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
|
|
||||||
|
|
||||||
int mbed_printf(const char *format, ...)
|
int mbed_printf(const char *format, ...)
|
||||||
{
|
{
|
||||||
va_list arguments;
|
va_list arguments;
|
||||||
|
|
@ -48,7 +49,7 @@ int mbed_vsnprintf(char* buffer, size_t length, const char* format, va_list argu
|
||||||
return mbed_minimal_formatted_string(buffer, length, format, arguments, NULL);
|
return mbed_minimal_formatted_string(buffer, length, format, arguments, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if MBED_CONF_MINIMAL_PRINTF_ENABLE_FILE_STREAM
|
#if MBED_CONF_PLATFORM_MINIMAL_PRINTF_ENABLE_FILE_STREAM
|
||||||
int mbed_fprintf(FILE *stream, const char *format, ...)
|
int mbed_fprintf(FILE *stream, const char *format, ...)
|
||||||
{
|
{
|
||||||
va_list arguments;
|
va_list arguments;
|
||||||
|
|
@ -52,7 +52,7 @@ int mbed_vprintf(const char* format, va_list arguments);
|
||||||
*/
|
*/
|
||||||
int mbed_vsnprintf(char *buffer, size_t length, const char *format, va_list arguments);
|
int mbed_vsnprintf(char *buffer, size_t length, const char *format, va_list arguments);
|
||||||
|
|
||||||
#if MBED_CONF_MINIMAL_PRINTF_ENABLE_FILE_STREAM
|
#if MBED_CONF_PLATFORM_MINIMAL_PRINTF_ENABLE_FILE_STREAM
|
||||||
/**
|
/**
|
||||||
* Minimal fprintf
|
* Minimal fprintf
|
||||||
*
|
*
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"target_overrides": {
|
"target_overrides": {
|
||||||
"*": {
|
"*": {
|
||||||
"minimal-printf.enable-file-stream": 1
|
"platform.minimal-printf-enable-file-stream": 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,115 +0,0 @@
|
||||||
# Minimal printf and snprintf
|
|
||||||
|
|
||||||
Library supports both printf and snprintf in 1252 bytes of flash.
|
|
||||||
|
|
||||||
Prints directly to stdio/UART without using malloc. All flags and precision modifiers are ignored.
|
|
||||||
Floating point is enabled by default.
|
|
||||||
Printing to a FILE stream is enabled by default.
|
|
||||||
|
|
||||||
Supports:
|
|
||||||
* %d: signed integer [h, hh, (none), l, ll, z, j, t].
|
|
||||||
* %i: signed integer [h, hh, (none), l, ll, z, j, t].
|
|
||||||
* %u: unsigned integer [h, hh, (none), l, ll, z, j, t].
|
|
||||||
* %x: unsigned integer [h, hh, (none), l, ll, z, j, t], printed as hexadecimal number (e.g., ff).
|
|
||||||
* %X: unsigned integer [h, hh, (none), l, ll, z, j, t], printed as hexadecimal number (e.g., FF).
|
|
||||||
* %f: floating point (disabled by default).
|
|
||||||
* %F: floating point (disabled by default, treated as %f).
|
|
||||||
* %g: floating point (disabled by default, treated as %f).
|
|
||||||
* %G: floating point (disabled by default, treated as %f).
|
|
||||||
* %c: character.
|
|
||||||
* %s: string.
|
|
||||||
* %p: pointer (e.g. 0x00123456).
|
|
||||||
|
|
||||||
Unrecognized format specifiers are treated as ordinary characters.
|
|
||||||
|
|
||||||
Floating point support:
|
|
||||||
* Floating point is enabled by default.
|
|
||||||
* All floating points are treated as %f.
|
|
||||||
* No support for inf, infinity or nan
|
|
||||||
|
|
||||||
## Usage
|
|
||||||
|
|
||||||
To replace the standard implementation of the printf functions with the ones in this library:
|
|
||||||
|
|
||||||
Compile with mbed-cli using the custom `mprintf` profile. For example, to compile in release mode:
|
|
||||||
|
|
||||||
```
|
|
||||||
$ mbed compile -t <toolchain> -m <target> --profile release --profile mprintf
|
|
||||||
```
|
|
||||||
|
|
||||||
## Enabling FILE stream, floating point and 64 bit integers
|
|
||||||
|
|
||||||
In mbed_app.json:
|
|
||||||
|
|
||||||
```
|
|
||||||
"target_overrides": {
|
|
||||||
"*": {
|
|
||||||
"minimal-printf.enable-file-stream": true,
|
|
||||||
"minimal-printf.enable-floating-point": true,
|
|
||||||
"minimal-printf.set-floating-point-max-decimals": 6,
|
|
||||||
"minimal-printf.enable-64-bit": true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
## Size comparison
|
|
||||||
|
|
||||||
Example application compiled with minimal mbed OS (no RTOS) using this .mbedignore:
|
|
||||||
|
|
||||||
```
|
|
||||||
mbed-os/rtos/*
|
|
||||||
mbed-os/features/FEATURE_LWIP/*
|
|
||||||
mbed-os/features/FEATURE_CLIENT/*
|
|
||||||
mbed-os/features/FEATURE_COMMON_PAL/*
|
|
||||||
mbed-os/features/FEATURE_UVISOR/*
|
|
||||||
mbed-os/features/frameworks/*
|
|
||||||
mbed-os/features/net/*
|
|
||||||
mbed-os/features/netsocket/*
|
|
||||||
mbed-os/features/storage/*
|
|
||||||
mbed-os/events/*
|
|
||||||
```
|
|
||||||
|
|
||||||
### Example application
|
|
||||||
```
|
|
||||||
#include "mbed.h"
|
|
||||||
#include "mbed_printf.h"
|
|
||||||
#include <limits.h>
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
char buffer[1000];
|
|
||||||
int result;
|
|
||||||
|
|
||||||
double pi = 3.14159265359;
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
result = printf("hello world %d %u %X %p %s %2.5f %% %\r\n", LONG_MAX, ULONG_MAX, UCHAR_MAX, buffer, "muh", pi);
|
|
||||||
printf("results: %d\r\n", result);
|
|
||||||
|
|
||||||
result = snprintf(buffer, 1000, "hello world %d %u %X %p %s %2.5f %% %\r\n", LONG_MIN, 0, 0, buffer, "muh", -1*pi);
|
|
||||||
printf("%s\r\n", buffer);
|
|
||||||
|
|
||||||
printf("results: %d\r\n", result);
|
|
||||||
|
|
||||||
#else
|
|
||||||
result = mbed_printf("hello world %ld %llu %02X %p %s %2.5f %% %\r\n", LONG_MAX, ULONG_MAX, UCHAR_MAX, buffer, "muh", pi);
|
|
||||||
mbed_printf("results: %d\r\n", result);
|
|
||||||
|
|
||||||
result = mbed_snprintf(buffer, 1000, "hello world %d %u %X %p %s %2.5f %% %\r\n", LONG_MIN, 0, 0, buffer, "muh", -1*pi);
|
|
||||||
mbed_printf("%s\r\n", buffer);
|
|
||||||
|
|
||||||
mbed_printf("results: %d\r\n", result);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
### Full application size on K64F/GCC
|
|
||||||
|
|
||||||
| | Floating point | 64 bit integers | Flash | RAM |
|
|
||||||
| - | - | - | - | - |
|
|
||||||
| mbed-printf | | | 7772 | 2752 |
|
|
||||||
| mbed-printf | | X | 8708 | 2752 |
|
|
||||||
| mbed-printf | X | | 10368 | 2752 |
|
|
||||||
| mbed-printf | X | X | 11360 | 2752 |
|
|
||||||
| std printf | X | X | 37354 | 5364 |
|
|
||||||
|
|
@ -1,25 +0,0 @@
|
||||||
{
|
|
||||||
"name": "minimal-printf",
|
|
||||||
"config": {
|
|
||||||
"console-output": {
|
|
||||||
"help": "Console output. Options: UART, SWO",
|
|
||||||
"value": "UART"
|
|
||||||
},
|
|
||||||
"enable-64-bit": {
|
|
||||||
"help": "Enable printing 64 bit integers",
|
|
||||||
"value": true
|
|
||||||
},
|
|
||||||
"enable-file-stream": {
|
|
||||||
"help": "Enable printing to a FILE stream",
|
|
||||||
"value": true
|
|
||||||
},
|
|
||||||
"enable-floating-point": {
|
|
||||||
"help": "Enable floating point printing",
|
|
||||||
"value": true
|
|
||||||
},
|
|
||||||
"set-floating-point-max-decimals": {
|
|
||||||
"help": "Maximum number of decimals to be printed",
|
|
||||||
"value": 6
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
{
|
{
|
||||||
"name": "bare-metal",
|
"name": "bare-metal",
|
||||||
"requires": ["platform", "drivers", "minimal-printf"]
|
"requires": ["platform", "drivers"]
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -127,6 +127,26 @@
|
||||||
"use-mpu": {
|
"use-mpu": {
|
||||||
"help": "Use the MPU if available to fault execution from RAM and writes to ROM. Can be disabled to reduce image size.",
|
"help": "Use the MPU if available to fault execution from RAM and writes to ROM. Can be disabled to reduce image size.",
|
||||||
"value": true
|
"value": true
|
||||||
|
},
|
||||||
|
"minimal-printf-console-output": {
|
||||||
|
"help": "Console output when using mprintf profile. Options: UART, SWO",
|
||||||
|
"value": "UART"
|
||||||
|
},
|
||||||
|
"minimal-printf-enable-64-bit": {
|
||||||
|
"help": "Enable printing 64 bit integers when using mprintf profile",
|
||||||
|
"value": true
|
||||||
|
},
|
||||||
|
"minimal-printf-enable-file-stream": {
|
||||||
|
"help": "Enable printing to a FILE stream when using mprintf profile",
|
||||||
|
"value": true
|
||||||
|
},
|
||||||
|
"minimal-printf-enable-floating-point": {
|
||||||
|
"help": "Enable floating point printing when using mprintf profile",
|
||||||
|
"value": true
|
||||||
|
},
|
||||||
|
"minimal-printf-set-floating-point-max-decimals": {
|
||||||
|
"help": "Maximum number of decimals to be printed",
|
||||||
|
"value": 6
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"target_overrides": {
|
"target_overrides": {
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,158 @@
|
||||||
|
# Minimal printf and snprintf
|
||||||
|
|
||||||
|
|
||||||
|
Library supports both printf and snprintf in 1252 bytes of flash.
|
||||||
|
|
||||||
|
Prints directly to stdio/UART without using malloc. All flags and precision modifiers are ignored.
|
||||||
|
|
||||||
|
Supports:
|
||||||
|
* %d: signed integer [h, hh, (none), l, ll, z, j, t].
|
||||||
|
* %i: signed integer [h, hh, (none), l, ll, z, j, t].
|
||||||
|
* %u: unsigned integer [h, hh, (none), l, ll, z, j, t].
|
||||||
|
* %x: unsigned integer [h, hh, (none), l, ll, z, j, t], printed as hexadecimal number (e.g., ff).
|
||||||
|
* %X: unsigned integer [h, hh, (none), l, ll, z, j, t], printed as hexadecimal number (e.g., FF).
|
||||||
|
* %f: floating point (enabled by default).
|
||||||
|
* %F: floating point (enabled by default, treated as %f).
|
||||||
|
* %g: floating point (enabled by default, treated as %f).
|
||||||
|
* %G: floating point (enabled by default, treated as %f).
|
||||||
|
* %c: character.
|
||||||
|
* %s: string.
|
||||||
|
* %p: pointer (e.g. 0x00123456).
|
||||||
|
|
||||||
|
Unrecognized format specifiers are treated as ordinary characters.
|
||||||
|
|
||||||
|
Floating point limitations:
|
||||||
|
* All floating points are treated as %f.
|
||||||
|
* No support for inf, infinity or nan
|
||||||
|
|
||||||
|
## Configuration
|
||||||
|
|
||||||
|
|
||||||
|
Minimal printf is configured by the following parameters defined in `platform/mbed_lib.json`:
|
||||||
|
|
||||||
|
```
|
||||||
|
{
|
||||||
|
"name": "platform",
|
||||||
|
"config": {
|
||||||
|
"minimal-printf-console-output": {
|
||||||
|
"help": "Console output when using minimal-printf profile. Options: UART, SWO",
|
||||||
|
"value": "UART"
|
||||||
|
},
|
||||||
|
"minimal-printf-enable-64-bit": {
|
||||||
|
"help": "Enable printing 64 bit integers when using minimal-printf profile",
|
||||||
|
"value": true
|
||||||
|
},
|
||||||
|
"minimal-printf-enable-file-stream": {
|
||||||
|
"help": "Enable printing to a FILE stream when using minimal-printf profile",
|
||||||
|
"value": true
|
||||||
|
},
|
||||||
|
"minimal-printf-enable-floating-point": {
|
||||||
|
"help": "Enable floating point printing when using minimal-printf profile",
|
||||||
|
"value": true
|
||||||
|
},
|
||||||
|
"minimal-printf-set-floating-point-max-decimals": {
|
||||||
|
"help": "Maximum number of decimals to be printed",
|
||||||
|
"value": 6
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
By default, 64 bit integers, floating point and FILE stream printing are enabled.
|
||||||
|
|
||||||
|
If your target does not require some options then you can override the default configuration in your application `mbed_app.json` and achieve further memory optimisation (see next section for size comparison numbers).
|
||||||
|
|
||||||
|
In mbed_app.json:
|
||||||
|
|
||||||
|
```
|
||||||
|
"target_overrides": {
|
||||||
|
"*": {
|
||||||
|
"platform.minimal-printf-enable-file-stream": false,
|
||||||
|
"platform.minimal-printf-enable-floating-point": false,
|
||||||
|
"platform.minimal-printf-set-floating-point-max-decimals": 6,
|
||||||
|
"platform.minimal-printf-enable-64-bit": false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
|
||||||
|
To replace the standard implementation of the printf functions with the ones in this library:
|
||||||
|
|
||||||
|
Compile with mbed-cli using the custom `minimal-printf` profile. For example, to compile in release mode:
|
||||||
|
|
||||||
|
```
|
||||||
|
$ mbed compile -t <toolchain> -m <target> --profile release --profile minimal-printf
|
||||||
|
```
|
||||||
|
|
||||||
|
## Size comparison
|
||||||
|
|
||||||
|
|
||||||
|
### Blinky application
|
||||||
|
|
||||||
|
https://github.com/ARMmbed/mbed-os-example-blinky application compiled with the different toolchains.
|
||||||
|
|
||||||
|
Blinky application size on K64F/GCC_ARM
|
||||||
|
|
||||||
|
| | File stream | Floating point | 64 bit integers | Flash | RAM |
|
||||||
|
| - | - | - | - | - | - |
|
||||||
|
| mbed-printf | | | | 30,944 | 12,096 |
|
||||||
|
| mbed-printf | | | X | 31,084 | 12,096 |
|
||||||
|
| mbed-printf | | X | X | 33,824 | 12,096 |
|
||||||
|
| mbed-printf | X | X | X | 34,304 | 12,096 |
|
||||||
|
| std printf | X | X | X | 54,158 | 12,112 |
|
||||||
|
|
||||||
|
Blinky application size on K64F/ARMC6
|
||||||
|
|
||||||
|
| | File stream | Floating point | 64 bit integers | Flash | RAM |
|
||||||
|
| - | - | - | - | - | - |
|
||||||
|
| mbed-printf | | | | 31,543 | xxxxx |
|
||||||
|
| mbed-printf | | | X | 31,691 | xxxxx |
|
||||||
|
| mbed-printf | | X | X | 34,515 | xxxxx |
|
||||||
|
| mbed-printf | X | X | X | 34,647 | xxxxx |
|
||||||
|
| std printf | X | X | X | 37,458 | xxxxx |
|
||||||
|
|
||||||
|
Blinky application size on K64F/IAR
|
||||||
|
|
||||||
|
| | File stream | Floating point | 64 bit integers | Flash | RAM |
|
||||||
|
| - | - | - | - | - | - |
|
||||||
|
| mbed-printf | | | | 28,713 | 8,546 |
|
||||||
|
| mbed-printf | | | X | 28,853 | 8,546 |
|
||||||
|
| mbed-printf | | X | X | 30,661 | 8,546 |
|
||||||
|
| mbed-printf | X | X | X | 32,047 | 8,594 |
|
||||||
|
| std printf | X | X | X | 35,055 | 8,462 |
|
||||||
|
|
||||||
|
### Blinky bare metal application
|
||||||
|
|
||||||
|
https://github.com/ARMmbed/mbed-os-example-blinky-baremetal application compiled with the different toolchains.
|
||||||
|
|
||||||
|
Blinky application size on K64F/GCC_ARM
|
||||||
|
|
||||||
|
| | File stream | Floating point | 64 bit integers | Flash | RAM |
|
||||||
|
| - | - | - | - | - | - |
|
||||||
|
| mbed-printf | | | | 17,168 | 5,880 |
|
||||||
|
| mbed-printf | | | X | 17,308 | 5,880 |
|
||||||
|
| mbed-printf | | X | X | 20,044 | 5,880 |
|
||||||
|
| mbed-printf | X | X | X | 22,560 | 5,880 |
|
||||||
|
| std printf | X | X | X | 35,244 | 5,864 |
|
||||||
|
|
||||||
|
Blinky application size on K64F/ARMC6
|
||||||
|
|
||||||
|
| | File stream | Floating point | 64 bit integers | Flash | RAM |
|
||||||
|
| - | - | - | - | - | - |
|
||||||
|
| mbed-printf | | | | 19,496 | xxxxx |
|
||||||
|
| mbed-printf | | | X | 19,644 | xxxxx |
|
||||||
|
| mbed-printf | | X | X | 22,468 | xxxxx |
|
||||||
|
| mbed-printf | X | X | X | 23,060 | xxxxx |
|
||||||
|
| std printf | X | X | X | 25,393 | xxxxx |
|
||||||
|
|
||||||
|
Blinky application size on K64F/IAR
|
||||||
|
|
||||||
|
| | File stream | Floating point | 64 bit integers | Flash | RAM |
|
||||||
|
| - | - | - | - | - | - |
|
||||||
|
| mbed-printf | | | | 13,007 | 1,413 |
|
||||||
|
| mbed-printf | | | X | 13,147 | 1,413 |
|
||||||
|
| mbed-printf | | X | X | 14,955 | 1,413 |
|
||||||
|
| mbed-printf | X | X | X | 21,757 | 1,929 |
|
||||||
|
| std printf | X | X | X | 17,991 | 1,281 |
|
||||||
|
|
@ -23,6 +23,8 @@
|
||||||
* to resolve dependencies and correctly remove unused functions.
|
* to resolve dependencies and correctly remove unused functions.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#ifdef MBED_MINIMAL_PRINTF
|
||||||
|
|
||||||
#if defined(TOOLCHAIN_ARM)
|
#if defined(TOOLCHAIN_ARM)
|
||||||
|
|
||||||
#include "mbed_printf_implementation.h"
|
#include "mbed_printf_implementation.h"
|
||||||
|
|
@ -369,3 +371,5 @@ int $Sub$$_printf_x(const char *format, ...)
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#endif // MBED_MINIMAL_PRINTF
|
||||||
|
|
@ -30,7 +30,7 @@
|
||||||
#define CONSOLE_OUTPUT_SWO 2
|
#define CONSOLE_OUTPUT_SWO 2
|
||||||
#define mbed_console_concat_(x) CONSOLE_OUTPUT_##x
|
#define mbed_console_concat_(x) CONSOLE_OUTPUT_##x
|
||||||
#define mbed_console_concat(x) mbed_console_concat_(x)
|
#define mbed_console_concat(x) mbed_console_concat_(x)
|
||||||
#define CONSOLE_OUTPUT mbed_console_concat(MBED_CONF_MINIMAL_PRINTF_CONSOLE_OUTPUT)
|
#define CONSOLE_OUTPUT mbed_console_concat(MBED_CONF_PLATFORM_MINIMAL_PRINTF_CONSOLE_OUTPUT)
|
||||||
|
|
||||||
#if MBED_CONF_PLATFORM_STDIO_CONVERT_NEWLINES
|
#if MBED_CONF_PLATFORM_STDIO_CONVERT_NEWLINES
|
||||||
static char mbed_stdio_out_prev = 0;
|
static char mbed_stdio_out_prev = 0;
|
||||||
|
|
@ -51,8 +51,7 @@ static bool not_initialized = true;
|
||||||
|
|
||||||
static void init_serial()
|
static void init_serial()
|
||||||
{
|
{
|
||||||
if (not_initialized)
|
if (not_initialized) {
|
||||||
{
|
|
||||||
not_initialized = false;
|
not_initialized = false;
|
||||||
|
|
||||||
serial_init(&stdio_uart, STDIO_UART_TX, STDIO_UART_RX);
|
serial_init(&stdio_uart, STDIO_UART_TX, STDIO_UART_RX);
|
||||||
|
|
@ -86,23 +85,23 @@ static void init_serial()
|
||||||
/***************************/
|
/***************************/
|
||||||
#else
|
#else
|
||||||
/* Linux implementation is for debug only */
|
/* Linux implementation is for debug only */
|
||||||
#define MBED_CONF_MINIMAL_PRINTF_ENABLE_FLOATING_POINT 1
|
#define MBED_CONF_PLATFORM_MINIMAL_PRINTF_ENABLE_FLOATING_POINT 1
|
||||||
#define MBED_CONF_MINIMAL_PRINTF_SET_FLOATING_POINT_MAX_DECIMALS 6
|
#define MBED_CONF_PLATFORM_MINIMAL_PRINTF_SET_FLOATING_POINT_MAX_DECIMALS 6
|
||||||
#define MBED_CONF_MINIMAL_PRINTF_ENABLE_64_BIT 1
|
#define MBED_CONF_PLATFORM_MINIMAL_PRINTF_ENABLE_64_BIT 1
|
||||||
#define MBED_INITIALIZE_PRINT(x) { ; }
|
#define MBED_INITIALIZE_PRINT(x) { ; }
|
||||||
#define MBED_PRINT_CHARACTER(x) { printf("%c", x); }
|
#define MBED_PRINT_CHARACTER(x) { printf("%c", x); }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef MBED_CONF_MINIMAL_PRINTF_ENABLE_FLOATING_POINT
|
#ifndef MBED_CONF_PLATFORM_MINIMAL_PRINTF_ENABLE_FLOATING_POINT
|
||||||
#define MBED_CONF_MINIMAL_PRINTF_ENABLE_FLOATING_POINT 0
|
#define MBED_CONF_PLATFORM_MINIMAL_PRINTF_ENABLE_FLOATING_POINT 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef MBED_CONF_MINIMAL_PRINTF_SET_FLOATING_POINT_MAX_DECIMALS
|
#ifndef MBED_CONF_PLATFORM_MINIMAL_PRINTF_SET_FLOATING_POINT_MAX_DECIMALS
|
||||||
#define MBED_CONF_MINIMAL_PRINTF_SET_FLOATING_POINT_MAX_DECIMALS 6
|
#define MBED_CONF_PLATFORM_MINIMAL_PRINTF_SET_FLOATING_POINT_MAX_DECIMALS 6
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef MBED_CONF_MINIMAL_PRINTF_ENABLE_64_BIT
|
#ifndef MBED_CONF_PLATFORM_MINIMAL_PRINTF_ENABLE_64_BIT
|
||||||
#define MBED_CONF_MINIMAL_PRINTF_ENABLE_64_BIT 1
|
#define MBED_CONF_PLATFORM_MINIMAL_PRINTF_ENABLE_64_BIT 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -113,7 +112,7 @@ static void init_serial()
|
||||||
#if INTPTR_MAX == INT32_MAX
|
#if INTPTR_MAX == INT32_MAX
|
||||||
#define MBED_SIGNED_NATIVE_TYPE int32_t
|
#define MBED_SIGNED_NATIVE_TYPE int32_t
|
||||||
#define MBED_UNSIGNED_NATIVE_TYPE uint32_t
|
#define MBED_UNSIGNED_NATIVE_TYPE uint32_t
|
||||||
#if MBED_CONF_MINIMAL_PRINTF_ENABLE_64_BIT
|
#if MBED_CONF_PLATFORM_MINIMAL_PRINTF_ENABLE_64_BIT
|
||||||
#define MBED_SIGNED_STORAGE int64_t
|
#define MBED_SIGNED_STORAGE int64_t
|
||||||
#define MBED_UNSIGNED_STORAGE uint64_t
|
#define MBED_UNSIGNED_STORAGE uint64_t
|
||||||
#else
|
#else
|
||||||
|
|
@ -172,23 +171,16 @@ static void mbed_minimal_formatted_string_string(char* buffer, size_t length, in
|
||||||
static void mbed_minimal_putchar(char *buffer, size_t length, int *result, char data, FILE *stream)
|
static void mbed_minimal_putchar(char *buffer, size_t length, int *result, char data, FILE *stream)
|
||||||
{
|
{
|
||||||
/* only continue if 'result' doesn't overflow */
|
/* only continue if 'result' doesn't overflow */
|
||||||
if ((*result >= 0) && (*result <= INT_MAX - 1))
|
if ((*result >= 0) && (*result <= INT_MAX - 1)) {
|
||||||
{
|
|
||||||
/* write data only if there's enough space */
|
/* write data only if there's enough space */
|
||||||
if ((size_t)*result < length)
|
if ((size_t)*result < length) {
|
||||||
{
|
if (buffer) {
|
||||||
if (buffer)
|
|
||||||
{
|
|
||||||
buffer[*result] = data;
|
buffer[*result] = data;
|
||||||
}
|
} else {
|
||||||
else
|
#if MBED_CONF_PLATFORM_MINIMAL_PRINTF_ENABLE_FILE_STREAM
|
||||||
{
|
if (stream) {
|
||||||
#if MBED_CONF_MINIMAL_PRINTF_ENABLE_FILE_STREAM
|
|
||||||
if (stream)
|
|
||||||
{
|
|
||||||
fputc(data, (FILE *) stream);
|
fputc(data, (FILE *) stream);
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
MBED_PRINT_CHARACTER(data);
|
MBED_PRINT_CHARACTER(data);
|
||||||
|
|
@ -214,16 +206,13 @@ static void mbed_minimal_formatted_string_signed(char* buffer, size_t length, in
|
||||||
MBED_UNSIGNED_STORAGE new_value = 0;
|
MBED_UNSIGNED_STORAGE new_value = 0;
|
||||||
|
|
||||||
/* if value is negative print sign and treat as positive number */
|
/* if value is negative print sign and treat as positive number */
|
||||||
if (value < 0)
|
if (value < 0) {
|
||||||
{
|
|
||||||
/* write sign */
|
/* write sign */
|
||||||
mbed_minimal_putchar(buffer, length, result, '-', stream);
|
mbed_minimal_putchar(buffer, length, result, '-', stream);
|
||||||
|
|
||||||
/* get absolute value using two's complement */
|
/* get absolute value using two's complement */
|
||||||
new_value = ~((MBED_UNSIGNED_STORAGE) value) + 1;
|
new_value = ~((MBED_UNSIGNED_STORAGE) value) + 1;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
new_value = value;
|
new_value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -242,20 +231,16 @@ static void mbed_minimal_formatted_string_signed(char* buffer, size_t length, in
|
||||||
static void mbed_minimal_formatted_string_unsigned(char *buffer, size_t length, int *result, MBED_UNSIGNED_STORAGE value, FILE *stream)
|
static void mbed_minimal_formatted_string_unsigned(char *buffer, size_t length, int *result, MBED_UNSIGNED_STORAGE value, FILE *stream)
|
||||||
{
|
{
|
||||||
/* treat 0 as a corner case */
|
/* treat 0 as a corner case */
|
||||||
if (value == 0)
|
if (value == 0) {
|
||||||
{
|
|
||||||
mbed_minimal_putchar(buffer, length, result, '0', stream);
|
mbed_minimal_putchar(buffer, length, result, '0', stream);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
/* allocate 3 digits per byte */
|
/* allocate 3 digits per byte */
|
||||||
char scratch[sizeof(MBED_UNSIGNED_STORAGE) * 3] = { 0 };
|
char scratch[sizeof(MBED_UNSIGNED_STORAGE) * 3] = { 0 };
|
||||||
|
|
||||||
size_t index = 0;
|
size_t index = 0;
|
||||||
|
|
||||||
/* write numbers in reverse order to scratch pad */
|
/* write numbers in reverse order to scratch pad */
|
||||||
for ( ; value > 0; index++)
|
for (; value > 0; index++) {
|
||||||
{
|
|
||||||
/* use '0' as base and add digit */
|
/* use '0' as base and add digit */
|
||||||
scratch[index] = '0' + (value % 10);
|
scratch[index] = '0' + (value % 10);
|
||||||
|
|
||||||
|
|
@ -264,8 +249,7 @@ static void mbed_minimal_formatted_string_unsigned(char* buffer, size_t length,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* write scratch pad to buffer or output */
|
/* write scratch pad to buffer or output */
|
||||||
for ( ; index > 0; index--)
|
for (; index > 0; index--) {
|
||||||
{
|
|
||||||
mbed_minimal_putchar(buffer, length, result, scratch[index - 1], stream);
|
mbed_minimal_putchar(buffer, length, result, scratch[index - 1], stream);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -284,21 +268,21 @@ static void mbed_minimal_formatted_string_hexadecimal(char* buffer, size_t lengt
|
||||||
{
|
{
|
||||||
bool print_leading_zero = false;
|
bool print_leading_zero = false;
|
||||||
|
|
||||||
for (int index = 7; index >= 0; index--)
|
for (int index = 7; index >= 0; index--) {
|
||||||
{
|
|
||||||
/* get most significant byte */
|
/* get most significant byte */
|
||||||
uint8_t output = value >> (8 * index);
|
uint8_t output = value >> (8 * index);
|
||||||
|
|
||||||
/* only print leading zeros when set */
|
/* only print leading zeros when set */
|
||||||
if (print_leading_zero || (output != 0) || (index == 0))
|
if (print_leading_zero || (output != 0) || (index == 0)) {
|
||||||
{
|
|
||||||
unsigned int nibble_one = (output >> 4);
|
unsigned int nibble_one = (output >> 4);
|
||||||
unsigned int nibble_two = (output & 0x0F);
|
unsigned int nibble_two = (output & 0x0F);
|
||||||
|
|
||||||
const char int2hex_lower[16] = { '0', '1', '2', '3', '4', '5', '6', '7',
|
const char int2hex_lower[16] = { '0', '1', '2', '3', '4', '5', '6', '7',
|
||||||
'8', '9', 'a', 'b', 'c', 'd', 'e', 'f' };
|
'8', '9', 'a', 'b', 'c', 'd', 'e', 'f'
|
||||||
|
};
|
||||||
const char int2hex_upper[16] = { '0', '1', '2', '3', '4', '5', '6', '7',
|
const char int2hex_upper[16] = { '0', '1', '2', '3', '4', '5', '6', '7',
|
||||||
'8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
|
'8', '9', 'A', 'B', 'C', 'D', 'E', 'F'
|
||||||
|
};
|
||||||
const char *int2hex = upper ? int2hex_upper : int2hex_lower;
|
const char *int2hex = upper ? int2hex_upper : int2hex_lower;
|
||||||
|
|
||||||
if (print_leading_zero || nibble_one != 0) {
|
if (print_leading_zero || nibble_one != 0) {
|
||||||
|
|
@ -330,7 +314,7 @@ static void mbed_minimal_formatted_string_void_pointer(char* buffer, size_t leng
|
||||||
mbed_minimal_formatted_string_hexadecimal(buffer, length, result, (ptrdiff_t) value, stream, true);
|
mbed_minimal_formatted_string_hexadecimal(buffer, length, result, (ptrdiff_t) value, stream, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if MBED_CONF_MINIMAL_PRINTF_ENABLE_FLOATING_POINT
|
#if MBED_CONF_PLATFORM_MINIMAL_PRINTF_ENABLE_FLOATING_POINT
|
||||||
/**
|
/**
|
||||||
* @brief Write double.
|
* @brief Write double.
|
||||||
*
|
*
|
||||||
|
|
@ -353,8 +337,7 @@ static void mbed_minimal_formatted_string_double(char* buffer, size_t length, in
|
||||||
/* get decimal part */
|
/* get decimal part */
|
||||||
double precision = 1.0;
|
double precision = 1.0;
|
||||||
|
|
||||||
for (size_t index = 0; index < MBED_CONF_MINIMAL_PRINTF_SET_FLOATING_POINT_MAX_DECIMALS; index++)
|
for (size_t index = 0; index < MBED_CONF_PLATFORM_MINIMAL_PRINTF_SET_FLOATING_POINT_MAX_DECIMALS; index++) {
|
||||||
{
|
|
||||||
precision *= 10;
|
precision *= 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -363,21 +346,17 @@ static void mbed_minimal_formatted_string_double(char* buffer, size_t length, in
|
||||||
/* convert to unsigned integer */
|
/* convert to unsigned integer */
|
||||||
MBED_UNSIGNED_STORAGE decimal = 0;
|
MBED_UNSIGNED_STORAGE decimal = 0;
|
||||||
|
|
||||||
if (value < 0)
|
if (value < 0) {
|
||||||
{
|
|
||||||
MBED_SIGNED_STORAGE temp = value;
|
MBED_SIGNED_STORAGE temp = value;
|
||||||
decimal = ~((MBED_UNSIGNED_STORAGE) temp) + 1;
|
decimal = ~((MBED_UNSIGNED_STORAGE) temp) + 1;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
decimal = value;
|
decimal = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* round up or down */
|
/* round up or down */
|
||||||
value -= decimal;
|
value -= decimal;
|
||||||
|
|
||||||
if (!((value > -0.5) && (value < 0.5)))
|
if (!((value > -0.5) && (value < 0.5))) {
|
||||||
{
|
|
||||||
decimal++;
|
decimal++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -409,16 +388,12 @@ static void mbed_minimal_formatted_string_double(char* buffer, size_t length, in
|
||||||
static void mbed_minimal_formatted_string_character(char *buffer, size_t length, int *result, char character, FILE *stream)
|
static void mbed_minimal_formatted_string_character(char *buffer, size_t length, int *result, char character, FILE *stream)
|
||||||
{
|
{
|
||||||
/* write character */
|
/* write character */
|
||||||
if (buffer)
|
if (buffer) {
|
||||||
{
|
|
||||||
mbed_minimal_putchar(buffer, length, result, character, stream);
|
mbed_minimal_putchar(buffer, length, result, character, stream);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
/* convert \n to \r\n if enabled in platform configuration */
|
/* convert \n to \r\n if enabled in platform configuration */
|
||||||
#if MBED_CONF_PLATFORM_STDIO_CONVERT_NEWLINES
|
#if MBED_CONF_PLATFORM_STDIO_CONVERT_NEWLINES
|
||||||
if (character == '\n' && mbed_stdio_out_prev != '\r')
|
if (character == '\n' && mbed_stdio_out_prev != '\r') {
|
||||||
{
|
|
||||||
mbed_minimal_putchar(buffer, length, result, '\r', stream);
|
mbed_minimal_putchar(buffer, length, result, '\r', stream);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -440,8 +415,7 @@ static void mbed_minimal_formatted_string_character(char* buffer, size_t length,
|
||||||
*/
|
*/
|
||||||
static void mbed_minimal_formatted_string_string(char *buffer, size_t length, int *result, const char *string, size_t precision, FILE *stream)
|
static void mbed_minimal_formatted_string_string(char *buffer, size_t length, int *result, const char *string, size_t precision, FILE *stream)
|
||||||
{
|
{
|
||||||
while ((*string != '\0') && (precision))
|
while ((*string != '\0') && (precision)) {
|
||||||
{
|
|
||||||
mbed_minimal_putchar(buffer, length, result, *string, stream);
|
mbed_minimal_putchar(buffer, length, result, *string, stream);
|
||||||
string++;
|
string++;
|
||||||
precision--;
|
precision--;
|
||||||
|
|
@ -469,24 +443,18 @@ int mbed_minimal_formatted_string(char* buffer, size_t length, const char* forma
|
||||||
/* ensure that function wasn't called with an empty buffer, or with or with
|
/* ensure that function wasn't called with an empty buffer, or with or with
|
||||||
a buffer size that is larger than the maximum 'int' value, or with
|
a buffer size that is larger than the maximum 'int' value, or with
|
||||||
a NULL format specifier */
|
a NULL format specifier */
|
||||||
if (format && length <= INT_MAX)
|
if (format && length <= INT_MAX) {
|
||||||
{
|
|
||||||
/* Make sure that there's always space for the NULL terminator */
|
/* Make sure that there's always space for the NULL terminator */
|
||||||
if (length > 0)
|
if (length > 0) {
|
||||||
{
|
|
||||||
length --;
|
length --;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
/* the buffer is empty, there's no place to write the terminator */
|
/* the buffer is empty, there's no place to write the terminator */
|
||||||
empty_buffer = true;
|
empty_buffer = true;
|
||||||
}
|
}
|
||||||
/* parse string */
|
/* parse string */
|
||||||
for (size_t index = 0; format[index] != '\0'; index++)
|
for (size_t index = 0; format[index] != '\0'; index++) {
|
||||||
{
|
|
||||||
/* format specifier begin */
|
/* format specifier begin */
|
||||||
if (format[index] == '%')
|
if (format[index] == '%') {
|
||||||
{
|
|
||||||
size_t next_index = index + 1;
|
size_t next_index = index + 1;
|
||||||
|
|
||||||
/**************************************************************
|
/**************************************************************
|
||||||
|
|
@ -496,8 +464,7 @@ int mbed_minimal_formatted_string(char* buffer, size_t length, const char* forma
|
||||||
(format[next_index] == '+') ||
|
(format[next_index] == '+') ||
|
||||||
(format[next_index] == ' ') ||
|
(format[next_index] == ' ') ||
|
||||||
(format[next_index] == '#') ||
|
(format[next_index] == '#') ||
|
||||||
(format[next_index] == '0'))
|
(format[next_index] == '0')) {
|
||||||
{
|
|
||||||
/* skip to next character */
|
/* skip to next character */
|
||||||
next_index++;
|
next_index++;
|
||||||
}
|
}
|
||||||
|
|
@ -505,19 +472,15 @@ int mbed_minimal_formatted_string(char* buffer, size_t length, const char* forma
|
||||||
/**************************************************************
|
/**************************************************************
|
||||||
* skip and ignore width [(number)*]
|
* skip and ignore width [(number)*]
|
||||||
*************************************************************/
|
*************************************************************/
|
||||||
if (format[next_index] == '*')
|
if (format[next_index] == '*') {
|
||||||
{
|
|
||||||
/* skip to next character */
|
/* skip to next character */
|
||||||
next_index++;
|
next_index++;
|
||||||
|
|
||||||
/* discard argument */
|
/* discard argument */
|
||||||
va_arg(arguments, MBED_SIGNED_NATIVE_TYPE);
|
va_arg(arguments, MBED_SIGNED_NATIVE_TYPE);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
while ((format[next_index] >= '0') &&
|
while ((format[next_index] >= '0') &&
|
||||||
(format[next_index] <= '9'))
|
(format[next_index] <= '9')) {
|
||||||
{
|
|
||||||
/* skip to next character */
|
/* skip to next character */
|
||||||
next_index++;
|
next_index++;
|
||||||
}
|
}
|
||||||
|
|
@ -529,15 +492,12 @@ int mbed_minimal_formatted_string(char* buffer, size_t length, const char* forma
|
||||||
int precision = PRECISION_DEFAULT;
|
int precision = PRECISION_DEFAULT;
|
||||||
|
|
||||||
if ((format[next_index] == '.') &&
|
if ((format[next_index] == '.') &&
|
||||||
(format[next_index + 1] == '*'))
|
(format[next_index + 1] == '*')) {
|
||||||
{
|
|
||||||
next_index += 2;
|
next_index += 2;
|
||||||
|
|
||||||
/* read precision from argument list */
|
/* read precision from argument list */
|
||||||
precision = va_arg(arguments, MBED_SIGNED_NATIVE_TYPE);
|
precision = va_arg(arguments, MBED_SIGNED_NATIVE_TYPE);
|
||||||
}
|
} else if (format[next_index] == '.') {
|
||||||
else if (format[next_index] == '.')
|
|
||||||
{
|
|
||||||
/* precision modifier found, reset default to 0 and increment index */
|
/* precision modifier found, reset default to 0 and increment index */
|
||||||
next_index++;
|
next_index++;
|
||||||
precision = 0;
|
precision = 0;
|
||||||
|
|
@ -546,8 +506,7 @@ int mbed_minimal_formatted_string(char* buffer, size_t length, const char* forma
|
||||||
size_t inner_index = 0;
|
size_t inner_index = 0;
|
||||||
|
|
||||||
while ((format[next_index + inner_index] >= '0') &&
|
while ((format[next_index + inner_index] >= '0') &&
|
||||||
(format[next_index + inner_index] <= '9'))
|
(format[next_index + inner_index] <= '9')) {
|
||||||
{
|
|
||||||
precision = precision * 10 + (format[next_index + inner_index] - '0');
|
precision = precision * 10 + (format[next_index + inner_index] - '0');
|
||||||
|
|
||||||
inner_index++;
|
inner_index++;
|
||||||
|
|
@ -563,37 +522,23 @@ int mbed_minimal_formatted_string(char* buffer, size_t length, const char* forma
|
||||||
length_t length_modifier = LENGTH_NONE;
|
length_t length_modifier = LENGTH_NONE;
|
||||||
|
|
||||||
/* look for two character length modifier */
|
/* look for two character length modifier */
|
||||||
if ((format[next_index] == 'h') && (format[next_index + 1] == 'h'))
|
if ((format[next_index] == 'h') && (format[next_index + 1] == 'h')) {
|
||||||
{
|
|
||||||
length_modifier = LENGTH_HH;
|
length_modifier = LENGTH_HH;
|
||||||
}
|
} else if ((format[next_index] == 'l') && (format[next_index + 1] == 'l')) {
|
||||||
else if ((format[next_index] == 'l') && (format[next_index + 1] == 'l'))
|
|
||||||
{
|
|
||||||
length_modifier = LENGTH_LL;
|
length_modifier = LENGTH_LL;
|
||||||
}
|
}
|
||||||
/* look for one character length modifier if two character search failed */
|
/* look for one character length modifier if two character search failed */
|
||||||
else if (format[next_index] == 'h')
|
else if (format[next_index] == 'h') {
|
||||||
{
|
|
||||||
length_modifier = LENGTH_H;
|
length_modifier = LENGTH_H;
|
||||||
}
|
} else if (format[next_index] == 'l') {
|
||||||
else if (format[next_index] == 'l')
|
|
||||||
{
|
|
||||||
length_modifier = LENGTH_L;
|
length_modifier = LENGTH_L;
|
||||||
}
|
} else if (format[next_index] == 'j') {
|
||||||
else if (format[next_index] == 'j')
|
|
||||||
{
|
|
||||||
length_modifier = LENGTH_J;
|
length_modifier = LENGTH_J;
|
||||||
}
|
} else if (format[next_index] == 'z') {
|
||||||
else if (format[next_index] == 'z')
|
|
||||||
{
|
|
||||||
length_modifier = LENGTH_Z;
|
length_modifier = LENGTH_Z;
|
||||||
}
|
} else if (format[next_index] == 't') {
|
||||||
else if (format[next_index] == 't')
|
|
||||||
{
|
|
||||||
length_modifier = LENGTH_T;
|
length_modifier = LENGTH_T;
|
||||||
}
|
} else if (format[next_index] == 'L') {
|
||||||
else if (format[next_index] == 'L')
|
|
||||||
{
|
|
||||||
length_modifier = LENGTH_CAPITAL_L;
|
length_modifier = LENGTH_CAPITAL_L;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -607,20 +552,17 @@ int mbed_minimal_formatted_string(char* buffer, size_t length, const char* forma
|
||||||
char next = format[next_index];
|
char next = format[next_index];
|
||||||
|
|
||||||
/* signed integer */
|
/* signed integer */
|
||||||
if ((next == 'd') || (next == 'i'))
|
if ((next == 'd') || (next == 'i')) {
|
||||||
{
|
|
||||||
MBED_SIGNED_STORAGE value = 0;
|
MBED_SIGNED_STORAGE value = 0;
|
||||||
|
|
||||||
#if MBED_CONF_MINIMAL_PRINTF_ENABLE_64_BIT
|
#if MBED_CONF_PLATFORM_MINIMAL_PRINTF_ENABLE_64_BIT
|
||||||
/* if 64 bit is enabled and the integer types are larger than the native type */
|
/* if 64 bit is enabled and the integer types are larger than the native type */
|
||||||
if (((length_modifier == LENGTH_LL) && (sizeof(long long int) > sizeof(MBED_SIGNED_NATIVE_TYPE))) ||
|
if (((length_modifier == LENGTH_LL) && (sizeof(long long int) > sizeof(MBED_SIGNED_NATIVE_TYPE))) ||
|
||||||
((length_modifier == LENGTH_L) && (sizeof(long int) > sizeof(MBED_SIGNED_NATIVE_TYPE))) ||
|
((length_modifier == LENGTH_L) && (sizeof(long int) > sizeof(MBED_SIGNED_NATIVE_TYPE))) ||
|
||||||
((length_modifier == LENGTH_NONE) && (sizeof(int) > sizeof(MBED_SIGNED_NATIVE_TYPE))))
|
((length_modifier == LENGTH_NONE) && (sizeof(int) > sizeof(MBED_SIGNED_NATIVE_TYPE)))) {
|
||||||
{
|
|
||||||
/* use 64 bit storage type for readout */
|
/* use 64 bit storage type for readout */
|
||||||
value = va_arg(arguments, MBED_SIGNED_STORAGE);
|
value = va_arg(arguments, MBED_SIGNED_STORAGE);
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
/* use native storage type (which can be 32 or 64 bit) */
|
/* use native storage type (which can be 32 or 64 bit) */
|
||||||
|
|
@ -628,8 +570,7 @@ int mbed_minimal_formatted_string(char* buffer, size_t length, const char* forma
|
||||||
}
|
}
|
||||||
|
|
||||||
/* constrict value based on lenght modifier */
|
/* constrict value based on lenght modifier */
|
||||||
switch (length_modifier)
|
switch (length_modifier) {
|
||||||
{
|
|
||||||
case LENGTH_NONE:
|
case LENGTH_NONE:
|
||||||
value = (int) value;
|
value = (int) value;
|
||||||
break;
|
break;
|
||||||
|
|
@ -660,20 +601,17 @@ int mbed_minimal_formatted_string(char* buffer, size_t length, const char* forma
|
||||||
mbed_minimal_formatted_string_signed(buffer, length, &result, value, stream);
|
mbed_minimal_formatted_string_signed(buffer, length, &result, value, stream);
|
||||||
}
|
}
|
||||||
/* unsigned integer */
|
/* unsigned integer */
|
||||||
else if ((next == 'u') || (next == 'x') || (next == 'X'))
|
else if ((next == 'u') || (next == 'x') || (next == 'X')) {
|
||||||
{
|
|
||||||
MBED_UNSIGNED_STORAGE value = 0;
|
MBED_UNSIGNED_STORAGE value = 0;
|
||||||
|
|
||||||
#if MBED_CONF_MINIMAL_PRINTF_ENABLE_64_BIT
|
#if MBED_CONF_PLATFORM_MINIMAL_PRINTF_ENABLE_64_BIT
|
||||||
/* if 64 bit is enabled and the integer types are larger than the native type */
|
/* if 64 bit is enabled and the integer types are larger than the native type */
|
||||||
if (((length_modifier == LENGTH_LL) && (sizeof(unsigned long long int) > sizeof(MBED_UNSIGNED_NATIVE_TYPE))) ||
|
if (((length_modifier == LENGTH_LL) && (sizeof(unsigned long long int) > sizeof(MBED_UNSIGNED_NATIVE_TYPE))) ||
|
||||||
((length_modifier == LENGTH_L) && (sizeof(unsigned long int) > sizeof(MBED_UNSIGNED_NATIVE_TYPE))) ||
|
((length_modifier == LENGTH_L) && (sizeof(unsigned long int) > sizeof(MBED_UNSIGNED_NATIVE_TYPE))) ||
|
||||||
((length_modifier == LENGTH_NONE) && (sizeof(unsigned int) > sizeof(MBED_UNSIGNED_NATIVE_TYPE))))
|
((length_modifier == LENGTH_NONE) && (sizeof(unsigned int) > sizeof(MBED_UNSIGNED_NATIVE_TYPE)))) {
|
||||||
{
|
|
||||||
/* use 64 bit storage type for readout */
|
/* use 64 bit storage type for readout */
|
||||||
value = va_arg(arguments, MBED_UNSIGNED_STORAGE);
|
value = va_arg(arguments, MBED_UNSIGNED_STORAGE);
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
/* use native storage type (which can be 32 or 64 bit) */
|
/* use native storage type (which can be 32 or 64 bit) */
|
||||||
|
|
@ -681,8 +619,7 @@ int mbed_minimal_formatted_string(char* buffer, size_t length, const char* forma
|
||||||
}
|
}
|
||||||
|
|
||||||
/* constrict value based on lenght modifier */
|
/* constrict value based on lenght modifier */
|
||||||
switch (length_modifier)
|
switch (length_modifier) {
|
||||||
{
|
|
||||||
case LENGTH_NONE:
|
case LENGTH_NONE:
|
||||||
value = (unsigned int) value;
|
value = (unsigned int) value;
|
||||||
break;
|
break;
|
||||||
|
|
@ -714,19 +651,15 @@ int mbed_minimal_formatted_string(char* buffer, size_t length, const char* forma
|
||||||
index = next_index;
|
index = next_index;
|
||||||
|
|
||||||
/* write unsigned or hexadecimal */
|
/* write unsigned or hexadecimal */
|
||||||
if (next == 'u')
|
if (next == 'u') {
|
||||||
{
|
|
||||||
mbed_minimal_formatted_string_unsigned(buffer, length, &result, value, stream);
|
mbed_minimal_formatted_string_unsigned(buffer, length, &result, value, stream);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
mbed_minimal_formatted_string_hexadecimal(buffer, length, &result, value, stream, next == 'X');
|
mbed_minimal_formatted_string_hexadecimal(buffer, length, &result, value, stream, next == 'X');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#if MBED_CONF_MINIMAL_PRINTF_ENABLE_FLOATING_POINT
|
#if MBED_CONF_PLATFORM_MINIMAL_PRINTF_ENABLE_FLOATING_POINT
|
||||||
/* treat all floating points the same */
|
/* treat all floating points the same */
|
||||||
else if ((next == 'f') || (next == 'F') || (next == 'g') || (next == 'G'))
|
else if ((next == 'f') || (next == 'F') || (next == 'g') || (next == 'G')) {
|
||||||
{
|
|
||||||
double value = va_arg(arguments, double);
|
double value = va_arg(arguments, double);
|
||||||
index = next_index;
|
index = next_index;
|
||||||
|
|
||||||
|
|
@ -734,51 +667,41 @@ int mbed_minimal_formatted_string(char* buffer, size_t length, const char* forma
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
/* character */
|
/* character */
|
||||||
else if (next == 'c')
|
else if (next == 'c') {
|
||||||
{
|
|
||||||
char value = va_arg(arguments, MBED_SIGNED_NATIVE_TYPE);
|
char value = va_arg(arguments, MBED_SIGNED_NATIVE_TYPE);
|
||||||
index = next_index;
|
index = next_index;
|
||||||
|
|
||||||
mbed_minimal_formatted_string_character(buffer, length, &result, value, stream);
|
mbed_minimal_formatted_string_character(buffer, length, &result, value, stream);
|
||||||
}
|
}
|
||||||
/* string */
|
/* string */
|
||||||
else if (next == 's')
|
else if (next == 's') {
|
||||||
{
|
|
||||||
char *value = va_arg(arguments, char *);
|
char *value = va_arg(arguments, char *);
|
||||||
index = next_index;
|
index = next_index;
|
||||||
|
|
||||||
mbed_minimal_formatted_string_string(buffer, length, &result, value, precision, stream);
|
mbed_minimal_formatted_string_string(buffer, length, &result, value, precision, stream);
|
||||||
}
|
}
|
||||||
/* pointer */
|
/* pointer */
|
||||||
else if (next == 'p')
|
else if (next == 'p') {
|
||||||
{
|
|
||||||
void *value = va_arg(arguments, void *);
|
void *value = va_arg(arguments, void *);
|
||||||
index = next_index;
|
index = next_index;
|
||||||
|
|
||||||
mbed_minimal_formatted_string_void_pointer(buffer, length, &result, value, stream);
|
mbed_minimal_formatted_string_void_pointer(buffer, length, &result, value, stream);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
/* write all characters between format beginning and unrecognied modifier */
|
/* write all characters between format beginning and unrecognied modifier */
|
||||||
while (index < next_index)
|
while (index < next_index) {
|
||||||
{
|
|
||||||
mbed_minimal_formatted_string_character(buffer, length, &result, format[index], stream);
|
mbed_minimal_formatted_string_character(buffer, length, &result, format[index], stream);
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* if this is not the end of the string, write unrecognized modifier */
|
/* if this is not the end of the string, write unrecognized modifier */
|
||||||
if (next != '\0')
|
if (next != '\0') {
|
||||||
{
|
|
||||||
mbed_minimal_formatted_string_character(buffer, length, &result, format[index], stream);
|
mbed_minimal_formatted_string_character(buffer, length, &result, format[index], stream);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
/* break out of for loop */
|
/* break out of for loop */
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
/* not a format specifier */
|
/* not a format specifier */
|
||||||
{
|
{
|
||||||
/* write normal character */
|
/* write normal character */
|
||||||
|
|
@ -786,16 +709,12 @@ int mbed_minimal_formatted_string(char* buffer, size_t length, const char* forma
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (buffer && !empty_buffer)
|
if (buffer && !empty_buffer) {
|
||||||
{
|
|
||||||
/* NULL-terminate the buffer no matter what. We use '<=' to compare instead of '<'
|
/* NULL-terminate the buffer no matter what. We use '<=' to compare instead of '<'
|
||||||
because we know that we initially reserved space for '\0' by decrementing length */
|
because we know that we initially reserved space for '\0' by decrementing length */
|
||||||
if ((size_t)result <= length)
|
if ((size_t)result <= length) {
|
||||||
{
|
|
||||||
buffer[result] = '\0';
|
buffer[result] = '\0';
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
buffer[length] = '\0';
|
buffer[length] = '\0';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -803,3 +722,4 @@ int mbed_minimal_formatted_string(char* buffer, size_t length, const char* forma
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -14,7 +14,11 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#ifndef MBED_PRINTF_IMPLEMENTATION_H
|
||||||
|
#define MBED_PRINTF_IMPLEMENTATION_H
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
|
||||||
int mbed_minimal_formatted_string(char *buffer, size_t length, const char *format, va_list arguments, FILE *stream);
|
int mbed_minimal_formatted_string(char *buffer, size_t length, const char *format, va_list arguments, FILE *stream);
|
||||||
|
#endif
|
||||||
|
|
@ -14,22 +14,34 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#ifdef MBED_MINIMAL_PRINTF
|
||||||
|
|
||||||
#include "mbed_printf_implementation.h"
|
#include "mbed_printf_implementation.h"
|
||||||
|
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
|
|
||||||
#if defined(TOOLCHAIN_GCC)
|
|
||||||
|
#if defined(__GNUC__) /* GCC */
|
||||||
|
#define SUPER_PRINTF __real_printf
|
||||||
#define SUB_PRINTF __wrap_printf
|
#define SUB_PRINTF __wrap_printf
|
||||||
|
#define SUPER_SPRINTF __real_sprintf
|
||||||
#define SUB_SPRINTF __wrap_sprintf
|
#define SUB_SPRINTF __wrap_sprintf
|
||||||
|
#define SUPER_SNPRINTF __real_snprintf
|
||||||
#define SUB_SNPRINTF __wrap_snprintf
|
#define SUB_SNPRINTF __wrap_snprintf
|
||||||
|
#define SUPER_VPRINTF __real_vprintf
|
||||||
#define SUB_VPRINTF __wrap_vprintf
|
#define SUB_VPRINTF __wrap_vprintf
|
||||||
|
#define SUPER_VSPRINTF __real_vsprintf
|
||||||
#define SUB_VSPRINTF __wrap_vsprintf
|
#define SUB_VSPRINTF __wrap_vsprintf
|
||||||
|
#define SUPER_VSNPRINTF __real_vsnprintf
|
||||||
#define SUB_VSNPRINTF __wrap_vsnprintf
|
#define SUB_VSNPRINTF __wrap_vsnprintf
|
||||||
#if MBED_CONF_MINIMAL_PRINTF_ENABLE_FILE_STREAM
|
#if MBED_CONF_PLATFORM_MINIMAL_PRINTF_ENABLE_FILE_STREAM
|
||||||
|
#define SUPER_FPRINTF __real_fprintf
|
||||||
#define SUB_FPRINTF __wrap_fprintf
|
#define SUB_FPRINTF __wrap_fprintf
|
||||||
|
#define SUPER_VFPRINTF __real_vfprintf
|
||||||
#define SUB_VFPRINTF __wrap_vfprintf
|
#define SUB_VFPRINTF __wrap_vfprintf
|
||||||
#endif
|
#endif
|
||||||
#elif defined(TOOLCHAIN_ARM)
|
#elif defined(TOOLCHAIN_ARM) /* ARMC5/ARMC6 */\
|
||||||
|
|| defined(__ICCARM__) /* IAR */
|
||||||
#define SUPER_PRINTF $Super$$printf
|
#define SUPER_PRINTF $Super$$printf
|
||||||
#define SUB_PRINTF $Sub$$printf
|
#define SUB_PRINTF $Sub$$printf
|
||||||
#define SUPER_SPRINTF $Super$$sprintf
|
#define SUPER_SPRINTF $Super$$sprintf
|
||||||
|
|
@ -42,29 +54,28 @@
|
||||||
#define SUB_VSPRINTF $Sub$$vsprintf
|
#define SUB_VSPRINTF $Sub$$vsprintf
|
||||||
#define SUPER_VSNPRINTF $Super$$vsnprintf
|
#define SUPER_VSNPRINTF $Super$$vsnprintf
|
||||||
#define SUB_VSNPRINTF $Sub$$vsnprintf
|
#define SUB_VSNPRINTF $Sub$$vsnprintf
|
||||||
#if MBED_CONF_MINIMAL_PRINTF_ENABLE_FILE_STREAM
|
#if MBED_CONF_PLATFORM_MINIMAL_PRINTF_ENABLE_FILE_STREAM
|
||||||
#define SUB_FPRINTF $Sub$$fprintf
|
#define SUPER_FPRINTF $Super$$fprintf
|
||||||
#define SUB_VFPRINTF $Sub$$vfprintf
|
|
||||||
#endif
|
|
||||||
#elif defined(__ICCARM__)
|
|
||||||
#define SUPER_PRINTF $Super$$__iar_printf
|
|
||||||
#define SUB_PRINTF $Sub$$__iar_printf
|
|
||||||
#define SUPER_SPRINTF $Super$$__iar_sprintf
|
|
||||||
#define SUB_SPRINTF $Sub$$__iar_sprintf
|
|
||||||
#define SUPER_SNPRINTF $Super$$__iar_snprintf
|
|
||||||
#define SUB_SNPRINTF $Sub$$__iar_snprintf
|
|
||||||
#define SUPER_VPRINTF $Super$$__iar_vprintf
|
|
||||||
#define SUB_VPRINTF $Sub$$__iar_vprintf
|
|
||||||
#define SUPER_VSPRINTF $Super$$__iar_vsprintf
|
|
||||||
#define SUB_VSPRINTF $Sub$$__iar_vsprintf
|
|
||||||
#define SUPER_VSNPRINTF $Super$$__iar_vsnprintf
|
|
||||||
#define SUB_VSNPRINTF $Sub$$__iar_vsnprintf
|
|
||||||
#if MBED_CONF_MINIMAL_PRINTF_ENABLE_FILE_STREAM
|
|
||||||
#define SUB_FPRINTF $Sub$$fprintf
|
#define SUB_FPRINTF $Sub$$fprintf
|
||||||
|
#define SUPER_VFPRINTF $Super$$vfprintf
|
||||||
#define SUB_VFPRINTF $Sub$$vfprintf
|
#define SUB_VFPRINTF $Sub$$vfprintf
|
||||||
#endif
|
#endif
|
||||||
|
#else
|
||||||
|
#warning "This compiler is not yet supported."
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Prevent optimization of printf() by the ARMCC or IAR compiler.
|
||||||
|
// This is done to prevent optimization which can cause printf() to be
|
||||||
|
// substituted with a different function (e.g. puts()) and cause
|
||||||
|
// the output to be missing some strings.
|
||||||
|
// Note: Optimization prevention for other supported compilers is done
|
||||||
|
// via compiler optional command line arguments.
|
||||||
|
#if defined(__CC_ARM) /* ARMC5 */
|
||||||
|
#pragma push
|
||||||
|
#pragma O0
|
||||||
|
#elif defined(__ICCARM__) /* IAR */
|
||||||
|
#pragma optimize=none
|
||||||
|
#endif
|
||||||
int SUB_PRINTF(const char *format, ...)
|
int SUB_PRINTF(const char *format, ...)
|
||||||
{
|
{
|
||||||
va_list arguments;
|
va_list arguments;
|
||||||
|
|
@ -110,7 +121,7 @@ int SUB_VSNPRINTF(char* buffer, size_t length, const char* format, va_list argum
|
||||||
return mbed_minimal_formatted_string(buffer, length, format, arguments, NULL);
|
return mbed_minimal_formatted_string(buffer, length, format, arguments, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if MBED_CONF_MINIMAL_PRINTF_ENABLE_FILE_STREAM
|
#if MBED_CONF_PLATFORM_MINIMAL_PRINTF_ENABLE_FILE_STREAM
|
||||||
int SUB_FPRINTF(FILE *stream, const char *format, ...)
|
int SUB_FPRINTF(FILE *stream, const char *format, ...)
|
||||||
{
|
{
|
||||||
va_list arguments;
|
va_list arguments;
|
||||||
|
|
@ -126,3 +137,5 @@ int SUB_VFPRINTF(FILE* stream, const char* format, va_list arguments)
|
||||||
return mbed_minimal_formatted_string(NULL, LONG_MAX, format, arguments, stream);
|
return mbed_minimal_formatted_string(NULL, LONG_MAX, format, arguments, stream);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#endif // MBED_MINIMAL_PRINTF
|
||||||
|
|
@ -215,7 +215,7 @@
|
||||||
<listOptionValue builtIn="false" value=""${ProjDirPath}/{{file}}""/>
|
<listOptionValue builtIn="false" value=""${ProjDirPath}/{{file}}""/>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</option>
|
</option>
|
||||||
{% if opts['c']['compiler.std'] %}
|
{% if opts['c'].get('compiler.std') %}
|
||||||
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.c.compiler.std.{{u.id}}" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.c.compiler.std" value="ilg.gnuarmeclipse.managedbuild.cross.option.c.compiler.std.{{opts['c']['compiler.std']}}" valueType="enumerated"/>
|
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.c.compiler.std.{{u.id}}" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.c.compiler.std" value="ilg.gnuarmeclipse.managedbuild.cross.option.c.compiler.std.{{opts['c']['compiler.std']}}" valueType="enumerated"/>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if opts['c']['otheroptimizations'] != '' %}
|
{% if opts['c']['otheroptimizations'] != '' %}
|
||||||
|
|
@ -263,7 +263,7 @@
|
||||||
<listOptionValue builtIn="false" value=""${ProjDirPath}/{{file}}""/>
|
<listOptionValue builtIn="false" value=""${ProjDirPath}/{{file}}""/>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</option>
|
</option>
|
||||||
{% if opts['cpp']['compiler.std'] %}
|
{% if opts['cpp'].get('compiler.std') %}
|
||||||
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.cpp.compiler.std.{{u.id}}" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.cpp.compiler.std" value="ilg.gnuarmeclipse.managedbuild.cross.option.cpp.compiler.std.{{opts['cpp']['compiler.std']}}" valueType="enumerated"/>
|
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.cpp.compiler.std.{{u.id}}" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.cpp.compiler.std" value="ilg.gnuarmeclipse.managedbuild.cross.option.cpp.compiler.std.{{opts['cpp']['compiler.std']}}" valueType="enumerated"/>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,20 @@
|
||||||
|
{
|
||||||
|
"GCC_ARM": {
|
||||||
|
"common": ["-DMBED_MINIMAL_PRINTF", "-fno-builtin-printf"],
|
||||||
|
"ld": ["-Wl,--wrap,printf", "-Wl,--wrap,sprintf", "-Wl,--wrap,snprintf",
|
||||||
|
"-Wl,--wrap,vprintf", "-Wl,--wrap,vsprintf", "-Wl,--wrap,vsnprintf",
|
||||||
|
"-Wl,--wrap,fprintf", "-Wl,--wrap,vfprintf"]
|
||||||
|
},
|
||||||
|
"ARMC6": {
|
||||||
|
"common": ["-DMBED_MINIMAL_PRINTF", "-fno-builtin-printf"]
|
||||||
|
},
|
||||||
|
"ARM": {
|
||||||
|
"common": ["-DMBED_MINIMAL_PRINTF"]
|
||||||
|
},
|
||||||
|
"uARM": {
|
||||||
|
"common": ["-DMBED_MINIMAL_PRINTF", "-fno-builtin-printf"]
|
||||||
|
},
|
||||||
|
"IAR": {
|
||||||
|
"common": ["-DMBED_MINIMAL_PRINTF"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,8 +0,0 @@
|
||||||
{
|
|
||||||
"GCC_ARM": {
|
|
||||||
"common": ["-DMBED_MINIMAL_PRINTF"],
|
|
||||||
"ld": ["-Wl,--wrap,printf", "-Wl,--wrap,sprintf", "-Wl,--wrap,snprintf",
|
|
||||||
"-Wl,--wrap,vprintf", "-Wl,--wrap,vsprintf", "-Wl,--wrap,vsnprintf",
|
|
||||||
"-Wl,--wrap,fprintf", "-Wl,--wrap,vfprintf"]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Loading…
Reference in New Issue