Skip to content

Commit 050a338

Browse files
committed
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 substitution
1 parent 65ab346 commit 050a338

File tree

17 files changed

+387
-395
lines changed

17 files changed

+387
-395
lines changed

features/minimal-printf/TESTS/minimal-printf/compliance/README.md renamed to TESTS/mbed_platform/minimal-printf/compliance/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ You can use the following command to run tests:
88

99
`mbed test -m K64F -t GCC_ARM -n *printf* -v -c`
1010

11-
Do not use --profile mprintf so minimal-printf is not compared with itself.
11+
Do not use --profile minimal-printf so minimal-printf is not compared with itself.

features/minimal-printf/TESTS/minimal-printf/compliance/main.cpp renamed to TESTS/mbed_platform/minimal-printf/compliance/main.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#ifdef TARGET_LIKE_MBED
1818
#include "mbed.h"
1919
#endif
20-
#include "mbed_printf.h"
20+
#include "platform/minimal-printf/mbed_printf.h"
2121

2222
#include "utest/utest.h"
2323
#include "unity/unity.h"
@@ -721,7 +721,7 @@ static control_t test_snprintf_x(const size_t call_count)
721721
return CaseNext;
722722
}
723723

724-
#if MBED_CONF_MINIMAL_PRINTF_ENABLE_FLOATING_POINT
724+
#if MBED_CONF_PLATFORM_MINIMAL_PRINTF_ENABLE_FLOATING_POINT
725725
static control_t test_printf_f(const size_t call_count)
726726
{
727727
int result_baseline;
@@ -891,7 +891,7 @@ static control_t test_snprintf_buffer_overflow_llx(const size_t call_count)
891891

892892
utest::v1::status_t greentea_setup(const size_t number_of_cases)
893893
{
894-
GREENTEA_SETUP(30*60, "default_auto");
894+
GREENTEA_SETUP(30 * 60, "default_auto");
895895
return greentea_test_setup_handler(number_of_cases);
896896
}
897897

@@ -902,7 +902,7 @@ Case cases[] = {
902902
Case("snprintf %u", test_snprintf_u),
903903
Case("printf %x", test_printf_x),
904904
Case("snprintf %x", test_snprintf_x),
905-
#if MBED_CONF_MINIMAL_PRINTF_ENABLE_FLOATING_POINT
905+
#if MBED_CONF_PLATFORM_MINIMAL_PRINTF_ENABLE_FLOATING_POINT
906906
Case("printf %f", test_printf_f),
907907
Case("snprintf %f", test_snprintf_f),
908908
#endif

features/minimal-printf/mbed_printf.c renamed to TESTS/mbed_platform/minimal-printf/compliance/mbed_printf.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
#include <limits.h>
2020

21+
2122
int mbed_printf(const char *format, ...)
2223
{
2324
va_list arguments;
@@ -28,7 +29,7 @@ int mbed_printf(const char *format, ...)
2829
return result;
2930
}
3031

31-
int mbed_snprintf(char* buffer, size_t length, const char* format, ...)
32+
int mbed_snprintf(char *buffer, size_t length, const char *format, ...)
3233
{
3334
va_list arguments;
3435
va_start(arguments, format);
@@ -38,18 +39,18 @@ int mbed_snprintf(char* buffer, size_t length, const char* format, ...)
3839
return result;
3940
}
4041

41-
int mbed_vprintf(const char* format, va_list arguments)
42+
int mbed_vprintf(const char *format, va_list arguments)
4243
{
4344
return mbed_minimal_formatted_string(NULL, LONG_MAX, format, arguments, NULL);
4445
}
4546

46-
int mbed_vsnprintf(char* buffer, size_t length, const char* format, va_list arguments)
47+
int mbed_vsnprintf(char *buffer, size_t length, const char *format, va_list arguments)
4748
{
4849
return mbed_minimal_formatted_string(buffer, length, format, arguments, NULL);
4950
}
5051

51-
#if MBED_CONF_MINIMAL_PRINTF_ENABLE_FILE_STREAM
52-
int mbed_fprintf(FILE* stream, const char *format, ...)
52+
#if MBED_CONF_PLATFORM_MINIMAL_PRINTF_ENABLE_FILE_STREAM
53+
int mbed_fprintf(FILE *stream, const char *format, ...)
5354
{
5455
va_list arguments;
5556
va_start(arguments, format);
@@ -59,7 +60,7 @@ int mbed_fprintf(FILE* stream, const char *format, ...)
5960
return result;
6061
}
6162

62-
int mbed_vfprintf(FILE* stream, const char* format, va_list arguments)
63+
int mbed_vfprintf(FILE *stream, const char *format, va_list arguments)
6364
{
6465
return mbed_minimal_formatted_string(NULL, LONG_MAX, format, arguments, stream);
6566
}

features/minimal-printf/mbed_printf.h renamed to TESTS/mbed_platform/minimal-printf/compliance/mbed_printf.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,36 +36,36 @@ int mbed_printf(const char *format, ...);
3636
*
3737
* Prints directly to buffer without using malloc.
3838
*/
39-
int mbed_snprintf(char* buffer, size_t length, const char* format, ...);
39+
int mbed_snprintf(char *buffer, size_t length, const char *format, ...);
4040

4141
/**
4242
* Minimal printf
4343
*
4444
* Prints directly to stdio/UART without using malloc.
4545
*/
46-
int mbed_vprintf(const char* format, va_list arguments);
46+
int mbed_vprintf(const char *format, va_list arguments);
4747

4848
/**
4949
* Minimal snprintf
5050
*
5151
* Prints directly to buffer without using malloc.
5252
*/
53-
int mbed_vsnprintf(char* buffer, size_t length, const char* format, va_list arguments);
53+
int mbed_vsnprintf(char *buffer, size_t length, const char *format, va_list arguments);
5454

55-
#if MBED_CONF_MINIMAL_PRINTF_ENABLE_FILE_STREAM
55+
#if MBED_CONF_PLATFORM_MINIMAL_PRINTF_ENABLE_FILE_STREAM
5656
/**
5757
* Minimal fprintf
5858
*
5959
* Prints directly to file stream without using malloc.
6060
*/
61-
int mbed_fprintf(FILE* stream, const char *format, ...);
61+
int mbed_fprintf(FILE *stream, const char *format, ...);
6262

6363
/**
6464
* Minimal vfprintf
6565
*
6666
* Prints directly to file stream without using malloc.
6767
*/
68-
int mbed_vfprintf(FILE* stream, const char* format, va_list arguments);
68+
int mbed_vfprintf(FILE *stream, const char *format, va_list arguments);
6969
#endif
7070

7171
#ifdef __cplusplus
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"target_overrides": {
33
"*": {
4-
"minimal-printf.enable-file-stream": 1
4+
"platform.minimal-printf-enable-file-stream": 1
55
}
66
}
77
}

features/minimal-printf/README.md

Lines changed: 0 additions & 115 deletions
This file was deleted.

features/minimal-printf/mbed_lib.json

Lines changed: 0 additions & 25 deletions
This file was deleted.

platform/bare_metal/mbed_lib.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
22
"name": "bare-metal",
3-
"requires": ["platform", "drivers", "minimal-printf"]
3+
"requires": ["platform", "drivers"]
44
}

platform/mbed_lib.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,26 @@
127127
"use-mpu": {
128128
"help": "Use the MPU if available to fault execution from RAM and writes to ROM. Can be disabled to reduce image size.",
129129
"value": true
130+
},
131+
"minimal-printf-console-output": {
132+
"help": "Console output when using mprintf profile. Options: UART, SWO",
133+
"value": "UART"
134+
},
135+
"minimal-printf-enable-64-bit": {
136+
"help": "Enable printing 64 bit integers when using mprintf profile",
137+
"value": true
138+
},
139+
"minimal-printf-enable-file-stream": {
140+
"help": "Enable printing to a FILE stream when using mprintf profile",
141+
"value": true
142+
},
143+
"minimal-printf-enable-floating-point": {
144+
"help": "Enable floating point printing when using mprintf profile",
145+
"value": true
146+
},
147+
"minimal-printf-set-floating-point-max-decimals": {
148+
"help": "Maximum number of decimals to be printed",
149+
"value": 6
130150
}
131151
},
132152
"target_overrides": {

0 commit comments

Comments
 (0)