Repository navigation
Use a few integer types from the compiler - #2222
Conversation
fd9ad67 to
5544ea5
Compare
775cd4f to
801f83e
Compare
c2df423 to
9c75443
Compare
|
finally the ci is green. yay. |
|
@yamt great work! but there are many intermediate patches, can you organize the patch series into two:
The fix for type, nxstyle and annotation is good and ready to merge, inttype.h need more review and dissuss. |
|
i guess compilers used for arch/z80 and arch/z16 don't provide in that case, those types.h need to be updated to provide _intmax_t and _uintmax_t. |
Very unlikely. It is c89 which is before stdint.h
You will need to add those. |
thank you. i added them. |
root@212cf3f52994:/tools# p32-gcc -mlong32 -dM -E - < /dev/null | grep "__INT.*_TYPE__"|sort
#define __INT16_TYPE__ short int
#define __INT32_TYPE__ long int
#define __INT64_TYPE__ long long int
#define __INT8_TYPE__ signed char
#define __INTMAX_TYPE__ long long int
#define __INTPTR_TYPE__ int
#define __INT_FAST16_TYPE__ int
#define __INT_FAST32_TYPE__ int
#define __INT_FAST64_TYPE__ long long int
#define __INT_FAST8_TYPE__ int
#define __INT_LEAST16_TYPE__ short int
#define __INT_LEAST32_TYPE__ long int
#define __INT_LEAST64_TYPE__ long long int
#define __INT_LEAST8_TYPE__ signed char
root@212cf3f52994:/tools#
64-bit size_t/intptr_t/ptrdiff_t are long, not long long,
for macOS and Linux.
Note: we don't care CONFIG_SIM_M32 on macOS.
macOS:
spacetanuki% uname -a
Darwin spacetanuki.lan 18.7.0 Darwin Kernel Version 18.7.0: Mon Aug 31 20:53:32 PDT 2020; root:xnu-4903.278.44~1/RELEASE_X86_64 x86_64
spacetanuki% cc --version
Apple clang version 11.0.0 (clang-1100.0.33.17)
Target: x86_64-apple-darwin18.7.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
spacetanuki% cc -dM -E - < /dev/null|grep __SIZE_TYPE__
#define __SIZE_TYPE__ long unsigned int
spacetanuki% cc -m32 -dM -E - < /dev/null|grep __SIZE_TYPE__
#define __SIZE_TYPE__ long unsigned int
spacetanuki%
Linux:
root@4c2e9e83ac82:/tools# uname -a
Linux 4c2e9e83ac82 5.4.39-linuxkit apache#1 SMP Fri May 8 23:03:06 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
root@4c2e9e83ac82:/tools# cc --version
cc (Ubuntu 9.3.0-10ubuntu2) 9.3.0
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
root@4c2e9e83ac82:/tools# cc -dM -E - < /dev/null|grep __SIZE_TYPE__
#define __SIZE_TYPE__ long unsigned int
root@4c2e9e83ac82:/tools# cc -m32 -dM -E - < /dev/null|grep __SIZE_TYPE__
#define __SIZE_TYPE__ unsigned int
root@4c2e9e83ac82:/tools#
libc is just a part of C runtime. the compiler is also a fundamental part of it. having said that, i dropped the compiler_stdint.h stuff from this PR because it turned out to be more controversial than i expected. |
|
@yamt after reviewing the final patchset, I found that the common typedef for intmax_t/uintmax_t in include/stdint.h: should work fine after we correct _int64_t/_uint64_t/_int32_t/_uint32_t. Why we move intmax_t/uintmax_t to arch/inttype.h? |
|
Ok, thanks for explanation, it's clear now. |
Summary
The main motivaion is to allow to use -Wformat compiler warnings.
Otherwise, it complains on long vs long long differences for intmax_t.
Note: The compiler only knows the printf format and the host OS types.
It doesn't know NuttX types.
Note: On both of 64-bit macOS and Ubuntu x86_64, the host intmax_t
is "long int" while NuttX's intmax_t without this change is
"signed long long". While they are both 64-bit integers, clang -Wformat
complains on the difference.
Impact
all archs, especially 64-bit ones
Testing
tested with local app on sim/macOS