Commit Graph

50 Commits (d8350738d3ea07f8a6e129546a14ba3ef5685fca)

Author SHA1 Message Date
Marcus Chang d8350738d3 Add support for fprintf and vfprintf (#21)
Debug print is routed to stderr which relies on [v]fprintf.
This change adds support for overwriting the build-in [v]fprintf.
2019-07-04 10:46:31 +01:00
Evelyne Donnaes 96b5c1d6d4 Fixed floating point support (#24)
This PR adds:
* Support for hexadecimal printing in lower case
* Fixes to floating point printing (leading zeros in decimal part)
2019-07-02 11:09:49 +01:00
Marcus Chang fe6bdca74e Merge pull request #23 from marcuschangarm/https
Change CI from using HTTP to HTTPS for connecting to RaaS
2019-04-30 15:27:40 +01:00
Marcus Chang c975429e3d Change CI from using HTTP to HTTPS for connecting to RaaS 2019-04-30 07:06:44 -07:00
Marcus Chang f8feff2920 Merge pull request #22 from marcuschangarm/fix-ci
Remove wrapper file in CI
2019-04-17 22:31:21 +01:00
Marcus Chang 9c157de289 Remove wrapper file in CI
So we don't compare minimal-printf with itself.
2019-04-17 14:25:06 -07:00
Marcus Chang dc630f8d01 Merge pull request #20 from marcuschangarm/conform
Improve conformity
2019-04-17 11:52:05 +01:00
Marcus Chang 705d428fde Improve conformity
* Parse each specifier based on this pattern:
   %[flags][width][.precision][length]specifier
   http://www.cplusplus.com/reference/cstdio/printf/
 * Flags and width are still ignored.
 * Precision is supported for strings (string precision is used by Pelion Client).
 * Length is supported.
2019-04-16 04:49:44 -07:00
Marcus Chang 7a7a2996fc Merge pull request #19 from marcuschangarm/update-profiles
Update Mbed OS compile profiles to include Arm Compiler 6
2019-04-12 11:55:15 +01:00
Marcus Chang aa8915611a Update Mbed OS compile profiles to include Arm Compiler 6
Compiler profiles are only necessary for GCC but with
updated profiles the user can choose to use either.
2019-04-11 03:13:00 -07:00
Marcus Chang 3a76cbae19 Merge pull request #18 from marcuschangarm/optimize-arm
Optimize Arm Compiler
2019-04-09 18:36:11 +01:00
Marcus Chang 92089f66de Optimize Arm Compiler
Arm Compiler uses dedicated functions for each format specifier used by
[sn/v/vsn]printf. When minimal-printf overwrites [sn/v/vsn]printf the
linker is unable to remove unused functions related to printf.

The following stubs replace the built-in functions with dummy versions
that take up less space.
2019-04-09 07:57:41 -07:00
Marcus Chang bb92fd1147 Merge pull request #17 from ARMmbed/jenkins
Add Jenkins file
2019-04-09 10:52:09 +01:00
Marcus Chang b641111605 Add Jenkins file
Build [ARM, IAR, GCC_ARM] and test [K64F, NUCLEO_F429ZI].
2019-04-08 10:13:05 -07:00
Marcus Chang df84714d9d Merge pull request #15 from marcuschangarm/fix-file-endings
Fix file endings
2019-04-01 17:17:01 +01:00
Marcus Chang 8701e0f4c4 Fix file endings
Make all files have Unix style line endings.
2019-04-01 09:09:06 -07:00
Marcus Chang 5480969d14 Merge pull request #14 from marcuschangarm/fix-tests
Add consistent casts and widths to constants
2019-03-27 14:28:12 +00:00
Marcus Chang 0ee94bc8c4 Add consistent casts and widths to constants 2019-03-27 07:19:39 -07:00
Alon Nof 71966b6e5a remove warning: comparison of an unsigned value (#13)
remove compile warning: comparison of an unsigned value is always true
2018-12-17 10:38:42 +00:00
LIYOU ZHOU 3e3b133515 Merge pull request #12 from ARMmbed/feature-swo
Optional SWO output instead of UART
2018-05-22 17:06:06 +01:00
Marcus Chang cbdb3fe3fd Optional SWO output instead of UART
Change the default output from STDIO UART to SWO by overriding:

    "minimal-printf.console-output": "SWO"
2018-05-06 20:07:24 -07:00
Bogdan Marinescu 1b206471e9 Merge pull request #11 from ARMmbed/fix_mbed_tests
Implementation and test fixes
2018-05-01 12:48:48 +03:00
Bogdan Marinescu 541455d75f TEST_ASSERT_EQUAL_STRING always tests against the base version 2018-05-01 12:27:28 +03:00
Bogdan Marinescu c6cac23960 Implementation fixes
The printf(3) man page says "The functions snprintf() and vsnprintf() do
not write more than size bytes (including the terminating null byte
('\0')).  If the output was truncated due to this limit, then the return
value is the number of characters (excluding the terminating null byte)
which would have been written to the final string if enough space had been
available." The last part of this spec (returning the number of
characters which would have been written to the string if enough space
had been available) was not implemented in minimal-printf. This PR
changes that by redirecting all the processed characters through the
"minimal_printf_putchar" helper function. This function will not write
to the buffer if there's no space left, but it will always increment the
number of written characters, in order to match the above description.
minimal_printf_putchar also contains checks for overflows, so these
checks are no longer needed in the rest of the code.

Other changes:

- In some cases, mbed_minimal_formatted_string didn't put the string
  terminator in the output buffer. This PR ensures that this always
  happens.
- Fixed a bug in printed hexadecimal numbers introduced by a previous
  commit.
- Added buffer overflow tests for snprintf.
2018-04-26 13:37:33 +03:00
Bogdan Marinescu 362dd3fbcf Bugfixes for the implementation and the compliance test
In the implementation, don't always display double hex digits when
printing with "%X". This is in line with the behaviour observed both
in mbed OS's printf (Newlib) and Linux's printf (glibc).
In the tests, always compare the baseline result with the result
returned by the minimal printf implementation, instead of comparing
with a constant value.
2018-04-26 00:05:52 +03:00
Bogdan Marinescu fbbffd613e Disabled tests that aren't relevant on mbed targets
The minimal-printf implementation supports a number of length modifiers
(j, z and t) that are not supported by the native mbed OS libc
implementation. The compliance test has tests for these modifiers, which
means that it isn't possible to check the output of mbed-printf against
a known good implementation (libc's printf) when running on mbed OS.
This, in turn, can give the impression that the tests for these
modifiers pass, when that might not be the case. To address this issue,
this PR removes the tests for these modifiers in mbed OS.

This PR was created because some of the tests for these modifiers
actually fail in Linux, for example:

```
>>> Running case #3: 'printf %u'...
hhu: 0
hhu: 0
hhu: 255
hhu: 255
hu: 0
hu: 0
hu: 65535
hu: 65535
u: 0
u: 0
u: 4294967295
u: 4294967295
lu: 0
lu: 0
lu: 4294967295
lu: 4294967295
llu: 0
llu: 0
llu: 18446744073709551615
llu: 18446744073709551615
ju: 0
ju: 0
ju: 4294967295
ju: 18446744073709551615
:188::FAIL: Expected 7 Was 16
>>> 'printf %u': 0 passed, 1 failed with reason 'Assertion Failed'
```
2018-04-25 19:06:46 +03:00
Bogdan Marinescu 66d5739e86 Merge pull request #10 from ARMmbed/fixes
[BUGFIX][IOTUC-18] Library fixes
2018-04-16 14:17:33 +01:00
Bogdan Marinescu 2a01a54e17 Address code review issues
- Improved comments to explain the checks on 'result'.
- Check for non-NULL format specifier.
2018-03-23 10:23:48 +02:00
Bogdan Marinescu a5f07166f9 [BUGFIX][IOTUC-18] Library fixes
This commit adds mostly integer (and buffer) overflow checks for the
current buffer index (`result` variable).
2018-03-22 18:47:39 +02:00
Marcus Chang de7024f7ab Add missing include stdbool.h 2017-11-12 15:14:38 -08:00
Marcus Chang 8a2d3a0ff1 Merge pull request #7 from ARMmbed/remove_ssize_t
Remove references to ssize_t in the code
2017-11-02 13:10:06 -05:00
Bogdan Marinescu 75845c3dc7 Remove references to ssize_t in the code
ssize_t doesn't exist at all in armcc.
2017-11-02 17:12:06 +00:00
Marcus Chang d805e84a98 Merge pull request #6 from ARMmbed/add_debug_info
Add "-g" to 'release' and 'develop' profiles
2017-10-30 13:37:48 -05:00
Bogdan Marinescu 2e988a3649 Add "-g" to 'release' and 'develop' profiles
This is used by mbed-os-linker-report and doesn't increase the code
size.
2017-10-30 19:10:19 +02:00
Marcus Chang 48d35c4fb0 Merge pull request #5 from ARMmbed/add_profiles
Add compile profiles
2017-10-27 08:53:07 -05:00
Bogdan Marinescu cad10ad569 Add compile profiles 2017-10-27 14:44:31 +03:00
Marcus Chang dddce56032 Update README.md 2017-10-26 16:03:40 -05:00
Marcus Chang ab700c02df Fix file permissions 2017-10-26 13:41:32 -07:00
Marcus Chang 809c7ec16c Merge pull request #4 from ARMmbed/width
Add support for width specifiers
2017-10-26 15:40:11 -05:00
Marcus Chang 8ec1d473a1 Fixed bug in getting absolute value 2017-10-26 13:28:08 -07:00
Marcus Chang 3da2057328 Add test case 2017-10-26 08:56:00 -07:00
Marcus Chang 3be1165fe7 Add support for width specifiers 2017-10-26 07:28:15 -07:00
Marcus Chang 2206ae598e Add variable list versions of printf and snprintf
This makes it possible to use the minimal printf and snprintf
through mbed_retarget.cpp
2017-10-15 21:25:24 -07:00
Marcus Chang 4fd19a0d82 Support for floating points (disabled by default)
Use mbed_app.json to enable floating points.
Automatically ignore flags and width specifiers.
2017-10-15 19:26:01 -07:00
Marcus Chang a70a5332a8 Update README.md 2017-10-14 22:21:38 -05:00
Marcus Chang 63d33c68b9 Fix compile warnings 2017-10-14 20:12:17 -07:00
Marcus Chang 15e566faad Add mbed initialization 2017-10-14 20:03:30 -07:00
Marcus Chang 45afbf6bf3 Update README.md 2017-10-14 21:20:10 -05:00
Marcus Chang 9a21fe521b Minimal printf
Supports %d %u %X %p %s
 Doesn't use malloc
2017-10-14 19:16:50 -07:00
Marcus Chang 02840194ab Initial commit 2017-10-14 20:55:13 -05:00