[newlib] print formats for FAST and LEAST types
Andre Vieira
Andre.SimoesDiasVieira@arm.com
Thu Aug 27 10:57:00 GMT 2015
On 24/07/15 11:49, Corinna Vinschen wrote:
> On Jul 24 11:21, Andre Vieira wrote:
>> On 23/07/15 20:43, Corinna Vinschen wrote:
>>> Hi Andre,
>>>
>>> On Jul 23 11:28, Andre Vieira wrote:
>>>> The PRI and SCN macro's were producing formats that did not match their
>>>> target types set by GCC. This patch uses the types defined for
>>>> __INTxx_TYPE__, __INT_FASTxx_TYPE__ and __INT_LEASTxx_TYPE__ to define their
>>>> corresponding macros.
>>>>
>>>> newlib/ChangeLog:
>>>> 2015-07-23 Andre Vieira <...>
>>>>
>>>> * libc/include/sys/_intsup.h: Defined new __INTxx, __FASTxx and
>>>> _LEASTxx macro's to hold information regarding the respective types
>>>> print and scan formats.
>>>> * libc/include/inttypes.h: Defined LEAST and FAST specific PRI and SCN
>>>> macro's as these are not always the same as the INT variants. Used
>>>> the new
>>>> __INTxx, __FASTxx and __LEASTxx macro's in their corresponding PRI
>>>> and SCN macros.
>>>
>>> I gave your patch a quick glance and it looks basically ok to me.
>>> I'll review it more thorougly tomorrow (I hope), but I have a question:
>>>
>>> How did you test your patch?
>>>
>>>
>>> Thanks,
>>> Corinna
>>>
>> Hi Corinna,
>>
>> That is a very good question. To be honest with you I ran gcc and newlib
>> regression tests and did a manual test on one machine. As I was about to
>> send you the manual patch I noticed I forgot to change the SCN16(x) define.
>> So I'll respin this patch for you and I'll also give testing a bit more
>> thinking.
>>
>> There is no straightforward way of testing this I think. Though I will try
>> to create a sensible sscanf/sprintf test and get back to you. Suggestions
>> are welcome.
>
> Some simple testcase which allows easy manual inspection of the results
> would do, I guess. You know, output in rows, kind of like
>
> typename basetype printf macro scanf macro
> int32_t int "d" "d"
> int16fast_t long "ld" "ld"
>
> If you have a chance to test on, say, 2 platforms, I'd add inspection on
> 32 and 64 bit Cygwin. That should allow to be reasonable sure that the
> patch doesn't break any platform.
>
>
> Thanks,
> Corinna
>
Sorry for the delay.
As Kevin reported on Launchpad
(https://answers.launchpad.net/gcc-arm-embedded/+question/269083), the
PRI and SCN macro's were producing formats that did not match their
target types set by GCC. This patch uses the types defined for
__INTxx_TYPE__, __INT_FASTxx_TYPE__ and __INT_LEASTxx_TYPE__ to define
their corresponding macros. Attached you can find the file used for
manual testing and the results of running this test for compiled
versions for arm-none-eabi(32 bit) and aarch64-none-elf(64 bit), named
arm.run and aarch64.run respectively.
newlib/ChangeLog:
2015-07-23 Andre Vieira <andre.simoesdiasvieira@arm.com>
* libc/include/sys/_intsup.h: Defined new __INTxx, __FASTxx and
__LEASTxx
macro's to hold information regarding the respective types print and scan
formats.
* libc/include/inttypes.h: Defined LEAST and FAST specific PRI and SCN
macro's as these are not always the same as the INT variants. Used
the new
__INTxx, __FASTxx and __LEASTxx macro's in their corresponding PRI
and SCN
macros.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Fix-for-pri-and-scn-formats.patch
Type: text/x-patch
Size: 15359 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/newlib/attachments/20150827/845f8877/attachment.bin>
-------------- next part --------------
Signed types
typename basetype printf macro scanf macro
int16_t short int hd hd
int_least16_t short int hd hd
int_fast16_t int d d
int32_t int d d
int_least32_t int d d
int_fast32_t int d d
int64_t long int ld ld
int_least64_t long int ld ld
int_fast64_t long int ld ld
Unsigned types
typename basetype printf macro scanf macro
uint16_t short unsigned int hu hu
uint_least16_t short unsigned int hu hu
uint_fast16_t unsigned int u u
uint32_t unsigned int u u
uint_least32_t unsigned int u u
uint_fast32_t unsigned int u u
uint64_t long unsigned int lu lu
uint_least64_t long unsigned int lu lu
uint_fast64_t long unsigned int lu lu
-------------- next part --------------
Signed types
typename basetype printf macro scanf macro
int16_t short int hd hd
int_least16_t short int hd hd
int_fast16_t int d d
int32_t long int ld ld
int_least32_t long int ld ld
int_fast32_t int d d
int64_t long long int lld lld
int_least64_t long long int lld lld
int_fast64_t long long int lld lld
Unsigned types
typename basetype printf macro scanf macro
uint16_t short unsigned int hu hu
uint_least16_t short unsigned int hu hu
uint_fast16_t unsigned int u u
uint32_t long unsigned int lu lu
uint_least32_t long unsigned int lu lu
uint_fast32_t unsigned int u u
uint64_t long long unsigned int llu llu
uint_least64_t long long unsigned int llu llu
uint_fast64_t long long unsigned int llu llu
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test_priscn.c
Type: text/x-csrc
Size: 4179 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/newlib/attachments/20150827/845f8877/attachment-0001.bin>
More information about the Newlib
mailing list