You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by GitBox <gi...@apache.org> on 2022/10/31 07:34:53 UTC

[GitHub] [incubator-nuttx] xiaoxiang781216 opened a new pull request, #7476: arch/arm: Typedef _[u]int32_t to __[U]INT32_TYPE__ if __INT32_TYPE__ is defined

xiaoxiang781216 opened a new pull request, #7476:
URL: https://github.com/apache/incubator-nuttx/pull/7476

   ## Summary
   This reverts commit b1ed95f29d820f3c3d02fdff073c482e6742e6dd.
   
   ## Impact
   [u]int32_t mapping
   
   ## Testing
   Pass CI
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a diff in pull request #7476: arch/arm: Typedef _[u]int32_t to __[U]INT32_TYPE__ if __INT32_TYPE__ is defined

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #7476:
URL: https://github.com/apache/incubator-nuttx/pull/7476#discussion_r1009482201


##########
arch/arm/include/inttypes.h:
##########
@@ -29,91 +29,138 @@
  * Pre-processor Prototypes
  ****************************************************************************/
 
+#define int         +2
+#define long        +4

Review Comment:
   It's a clever hack I guess from newlib:
   https://github.com/bminor/newlib/blob/master/newlib/libc/include/sys/_intsup.h#L57-L58
   The compiler may define `__INTPTR_TYPE__`  to `int`, `long` or `'long int`, how can we know which one in the compile time?
   We can define `int` to +2 and `long` to +4, so `__INTPTR_TYPE__` will expand to `+2` for `int` or `+4` or `+2 + 4` for `long` and `long int`.
   so the compare of `__INT32_TYPE__` equal 2 can work as expect. 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] xiaoxiang781216 commented on pull request #7476: Revert "arm: Change _int32_t from int to long to match the compiler"

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on PR #7476:
URL: https://github.com/apache/incubator-nuttx/pull/7476#issuecomment-1296486722

   [@pkarashchenko](https://github.com/pkarashchenko) [@yamt](https://github.com/yamt) I change the typedef of `[u]int32_t` to `__[U]INT32_TYPE__` which is used by many libc implementation. If this patch can pass CI which mean gcc assume `uint32_t` is `unsigned long`, otherwise should be `unsigned int`.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] xiaoxiang781216 commented on pull request #7476: arch/arm: Typedef _[u]int32_t to __[U]INT32_TYPE__ if __INT32_TYPE__ is defined

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on PR #7476:
URL: https://github.com/apache/incubator-nuttx/pull/7476#issuecomment-1312631206

   https://github.com/apache/incubator-nuttx/pull/7391


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a diff in pull request #7476: arch/arm: Typedef _[u]int32_t to __[U]INT32_TYPE__ if __INT32_TYPE__ is defined

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #7476:
URL: https://github.com/apache/incubator-nuttx/pull/7476#discussion_r1009229311


##########
arch/arm/include/inttypes.h:
##########
@@ -31,89 +31,130 @@
 
 #define PRId8       "d"
 #define PRId16      "d"
-#define PRId32      "ld"
+#if defined(__INT32_TYPE__) && __INT32_TYPE__ == 2
+#  define PRId32    "d"
+#else
+#  define PRId32    "ld"
+#endif
 #define PRId64      "lld"
-
 #define PRIdPTR     "d"
 
 #define PRIi8       "i"
 #define PRIi16      "i"
-#define PRIi32      "li"
+#if defined(__INT32_TYPE__) && __INT32_TYPE__ == 2
+#  define PRIi32    "i"
+#else
+#  define PRIi32    "li"
+#endif
 #define PRIi64      "lli"
-
 #define PRIiPTR     "i"
 
 #define PRIo8       "o"
 #define PRIo16      "o"
-#define PRIo32      "lo"
+#if defined(__INT32_TYPE__) && __INT32_TYPE__ == 2
+#  define PRIo32    "o"
+#else
+#  define PRIo32    "lo"
+#endif
 #define PRIo64      "llo"
-
 #define PRIoPTR     "o"
 
 #define PRIu8       "u"
 #define PRIu16      "u"
-#define PRIu32      "lu"
+#if defined(__INT32_TYPE__) && __INT32_TYPE__ == 2
+#  define PRIu32    "u"
+#else
+#  define PRIu32    "lu"
+#endif
 #define PRIu64      "llu"
-
 #define PRIuPTR     "u"
 
 #define PRIx8       "x"
 #define PRIx16      "x"
-#define PRIx32      "lx"
+#if defined(__INT32_TYPE__) && __INT32_TYPE__ == 2
+#  define PRIx32    "x"
+#else
+#  define PRIx32    "lx"
+#endif
 #define PRIx64      "llx"
-
 #define PRIxPTR     "x"
 
 #define PRIX8       "X"
 #define PRIX16      "X"
-#define PRIX32      "lX"
+#if defined(__INT32_TYPE__) && __INT32_TYPE__ == 2

Review Comment:
   Done.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a diff in pull request #7476: arch/arm: Typedef _[u]int32_t to __[U]INT32_TYPE__ if __INT32_TYPE__ is defined

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #7476:
URL: https://github.com/apache/incubator-nuttx/pull/7476#discussion_r1009788746


##########
arch/arm/include/inttypes.h:
##########
@@ -29,91 +29,142 @@
  * Pre-processor Prototypes
  ****************************************************************************/
 
+#define signed      +0
+#define unsigned    +0
+#define int         +2
+#define long        +4

Review Comment:
   +1 if for `uint16_t` if you want to know `uint16_t` typedef to `short int` or `int` since gcc/clang typedef uint16_t to short, I omit the related code. If you are interesting please reference newlib link I gave above.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] xiaoxiang781216 commented on pull request #7476: arch/arm: Typedef _[u]int32_t to __[U]INT32_TYPE__ if __INT32_TYPE__ is defined

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on PR #7476:
URL: https://github.com/apache/incubator-nuttx/pull/7476#issuecomment-1298546684

   @pkarashchenko do you have more suggestion?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] xiaoxiang781216 commented on pull request #7476: arch/arm: Typedef _[u]int32_t to __[U]INT32_TYPE__ if __INT32_TYPE__ is defined

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on PR #7476:
URL: https://github.com/apache/incubator-nuttx/pull/7476#issuecomment-1298594461

   @yamt do you have more concern?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] xiaoxiang781216 commented on pull request #7476: Revert "arm: Change _int32_t from int to long to match the compiler"

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on PR #7476:
URL: https://github.com/apache/incubator-nuttx/pull/7476#issuecomment-1296278197

   @yamt where do you get information that `int32_t` map to `long int` by compiler?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] pkarashchenko commented on pull request #7476: Revert "arm: Change _int32_t from int to long to match the compiler"

Posted by GitBox <gi...@apache.org>.
pkarashchenko commented on PR #7476:
URL: https://github.com/apache/incubator-nuttx/pull/7476#issuecomment-1296280064

   @xiaoxiang781216 what are the issues with mapping to long?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] pkarashchenko commented on a diff in pull request #7476: arch/arm: Typedef _[u]int32_t to __[U]INT32_TYPE__ if __INT32_TYPE__ is defined

Posted by GitBox <gi...@apache.org>.
pkarashchenko commented on code in PR #7476:
URL: https://github.com/apache/incubator-nuttx/pull/7476#discussion_r1009206227


##########
arch/arm/include/inttypes.h:
##########
@@ -31,89 +31,130 @@
 
 #define PRId8       "d"
 #define PRId16      "d"
-#define PRId32      "ld"
+#if defined(__INT32_TYPE__) && __INT32_TYPE__ == 2
+#  define PRId32    "d"
+#else
+#  define PRId32    "ld"
+#endif
 #define PRId64      "lld"
-
 #define PRIdPTR     "d"
 
 #define PRIi8       "i"
 #define PRIi16      "i"
-#define PRIi32      "li"
+#if defined(__INT32_TYPE__) && __INT32_TYPE__ == 2
+#  define PRIi32    "i"
+#else
+#  define PRIi32    "li"
+#endif
 #define PRIi64      "lli"
-
 #define PRIiPTR     "i"
 
 #define PRIo8       "o"
 #define PRIo16      "o"
-#define PRIo32      "lo"
+#if defined(__INT32_TYPE__) && __INT32_TYPE__ == 2
+#  define PRIo32    "o"
+#else
+#  define PRIo32    "lo"
+#endif
 #define PRIo64      "llo"
-
 #define PRIoPTR     "o"
 
 #define PRIu8       "u"
 #define PRIu16      "u"
-#define PRIu32      "lu"
+#if defined(__INT32_TYPE__) && __INT32_TYPE__ == 2
+#  define PRIu32    "u"
+#else
+#  define PRIu32    "lu"
+#endif
 #define PRIu64      "llu"
-
 #define PRIuPTR     "u"
 
 #define PRIx8       "x"
 #define PRIx16      "x"
-#define PRIx32      "lx"
+#if defined(__INT32_TYPE__) && __INT32_TYPE__ == 2
+#  define PRIx32    "x"
+#else
+#  define PRIx32    "lx"
+#endif
 #define PRIx64      "llx"
-
 #define PRIxPTR     "x"
 
 #define PRIX8       "X"
 #define PRIX16      "X"
-#define PRIX32      "lX"
+#if defined(__INT32_TYPE__) && __INT32_TYPE__ == 2

Review Comment:
   No. I mean reduce number of ifders in this file by:
   ```
   #if defined(__INT32_TYPE__) && __INT32_TYPE__ == 2
   # define PRI32_PREFIX ""
   #else
   # define PRI32_PREFIX "l"
   #endif
   ...
   #define PRId32 PRI32_PREFIX"d"
   ...
   #define PRIX32 PRI32_PREFIX"X"
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] pkarashchenko commented on pull request #7476: Revert "arm: Change _int32_t from int to long to match the compiler"

Posted by GitBox <gi...@apache.org>.
pkarashchenko commented on PR #7476:
URL: https://github.com/apache/incubator-nuttx/pull/7476#issuecomment-1296281194

   According to https://www.ccoderun.ca/programming/2017-03-10_sizeof/ the size is the same. But maybe together with typedef update the PRIx32, PRIu32, etc. should be updated as well?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a diff in pull request #7476: arch/arm: Typedef _[u]int32_t to __[U]INT32_TYPE__ if __INT32_TYPE__ is defined

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #7476:
URL: https://github.com/apache/incubator-nuttx/pull/7476#discussion_r1009482201


##########
arch/arm/include/inttypes.h:
##########
@@ -29,91 +29,138 @@
  * Pre-processor Prototypes
  ****************************************************************************/
 
+#define int         +2
+#define long        +4

Review Comment:
   It's a clever hack I guess from newlib:
   https://github.com/bminor/newlib/blob/master/newlib/libc/include/sys/_intsup.h#L57-L58
   The compiler may define `__INTPTR_TYPE__`  to `int`, `long` or `'long int`, how can we know which one in the compile time?
   We can define `int` to +2 and `long` to +4, so `__INTPTR_TYPE__` will expand to `+2` for `int` or `+4` or `+2 + 4` for `long int` and `long`.
   so the compare of `__INT32_TYPE__` equal 2 can work as expect. 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] xiaoxiang781216 commented on pull request #7476: arch/arm: Typedef _[u]int32_t to __[U]INT32_TYPE__ if __INT32_TYPE__ is defined

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on PR #7476:
URL: https://github.com/apache/incubator-nuttx/pull/7476#issuecomment-1298984050

   > Let's merge PR. @xiaoxiang781216 please add some link for reference or short explanation into the code as a comment to improve readability
   
   @pkarashchenko it's here: https://github.com/apache/incubator-nuttx/pull/7502


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] pkarashchenko commented on pull request #7476: Revert "arm: Change _int32_t from int to long to match the compiler"

Posted by GitBox <gi...@apache.org>.
pkarashchenko commented on PR #7476:
URL: https://github.com/apache/incubator-nuttx/pull/7476#issuecomment-1296335554

   If the type cast near byteswap built-in fix the issue, then let's go with it.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] xiaoxiang781216 commented on pull request #7476: arch/arm: Typedef _[u]int32_t to __[U]INT32_TYPE__ if __INT32_TYPE__ is defined

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on PR #7476:
URL: https://github.com/apache/incubator-nuttx/pull/7476#issuecomment-1296700427

   > Yeah. The printf format specifiers should be tuned as well. @xiaoxiang781216 if the issue appears to be only with __builtin_swapXX usage, then let's add a cast to the NuttX swapXX macro and fix this with "small blood"?
   
   This patch just want to identify what's the compiler default setting. Since the change pass ci, which mean it's right that `uint32_t` map to `unsigned long int`. 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a diff in pull request #7476: arch/arm: Typedef _[u]int32_t to __[U]INT32_TYPE__ if __INT32_TYPE__ is defined

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #7476:
URL: https://github.com/apache/incubator-nuttx/pull/7476#discussion_r1009482201


##########
arch/arm/include/inttypes.h:
##########
@@ -29,91 +29,138 @@
  * Pre-processor Prototypes
  ****************************************************************************/
 
+#define int         +2
+#define long        +4

Review Comment:
   It's a clever hack I guess from newlib:
   https://github.com/bminor/newlib/blob/master/newlib/libc/include/sys/_intsup.h#L57-L58
   The compiler may define `__INTPTR_TYPE__`  to `int`, `long` or `'long int`, how can we know which one in the compiler time?
   We can define `int` to +2 and `long` to +4, so `__INTPTR_TYPE__` will expand to `+2` for `int` or `+4` or `+2 + 4` for `long int` and `long`.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a diff in pull request #7476: arch/arm: Typedef _[u]int32_t to __[U]INT32_TYPE__ if __INT32_TYPE__ is defined

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #7476:
URL: https://github.com/apache/incubator-nuttx/pull/7476#discussion_r1009788746


##########
arch/arm/include/inttypes.h:
##########
@@ -29,91 +29,142 @@
  * Pre-processor Prototypes
  ****************************************************************************/
 
+#define signed      +0
+#define unsigned    +0
+#define int         +2
+#define long        +4

Review Comment:
   +1 if for `uint16_t` if you want to know `uint16_t` typedef to `short int` or `int`. Since gcc/clang typedef uint16_t to short, I omit the related code. If you are interesting please reference newlib link I gave above.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] pkarashchenko commented on a diff in pull request #7476: arch/arm: Typedef _[u]int32_t to __[U]INT32_TYPE__ if __INT32_TYPE__ is defined

Posted by GitBox <gi...@apache.org>.
pkarashchenko commented on code in PR #7476:
URL: https://github.com/apache/incubator-nuttx/pull/7476#discussion_r1009772428


##########
arch/arm/include/inttypes.h:
##########
@@ -29,91 +29,142 @@
  * Pre-processor Prototypes
  ****************************************************************************/
 
+#define signed      +0
+#define unsigned    +0
+#define int         +2
+#define long        +4

Review Comment:
   Just for my understanding, can it be `+1`, `+2`? Or 2 and 4 are some magic numbers?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] pkarashchenko commented on pull request #7476: Revert "arm: Change _int32_t from int to long to match the compiler"

Posted by GitBox <gi...@apache.org>.
pkarashchenko commented on PR #7476:
URL: https://github.com/apache/incubator-nuttx/pull/7476#issuecomment-1296309761

   > @xiaoxiang781216 what are the issues with mapping to long?
   
   Could you please answer this?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] pkarashchenko commented on pull request #7476: arch/arm: Typedef _[u]int32_t to __[U]INT32_TYPE__ if __INT32_TYPE__ is defined

Posted by GitBox <gi...@apache.org>.
pkarashchenko commented on PR #7476:
URL: https://github.com/apache/incubator-nuttx/pull/7476#issuecomment-1298972418

   Let's merge PR. @xiaoxiang781216 please add some link for reference or short explanation into the code as a comment to improve readability


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] yamt commented on pull request #7476: arch/arm: Typedef _[u]int32_t to __[U]INT32_TYPE__ if __INT32_TYPE__ is defined

Posted by GitBox <gi...@apache.org>.
yamt commented on PR #7476:
URL: https://github.com/apache/incubator-nuttx/pull/7476#issuecomment-1296543118

   > @yamt where do you get information that `int32_t` map to `long int` not `int` by arm compiler?
   
   i don't remember.
   it was probably from a compiler used for nuttx build at that point.
   ```
   spacetanuki% arm-none-eabi-gcc -E -dM - < /dev/null|grep INT32_TYPE
   #define __INT32_TYPE__ long int
   #define __UINT32_TYPE__ long unsigned int
   spacetanuki% 
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] xiaoxiang781216 commented on pull request #7476: Revert "arm: Change _int32_t from int to long to match the compiler"

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on PR #7476:
URL: https://github.com/apache/incubator-nuttx/pull/7476#issuecomment-1296318701

   > > @xiaoxiang781216 what are the issues with mapping to long?
   > 
   > Could you please answer this?
   
   I am waiting clang result(https://github.com/apache/incubator-nuttx/pull/7391).
   From this PR CI(https://github.com/apache/incubator-nuttx/actions/runs/3356313797/jobs/5561312611), gcc expect `uint32_t` equals `long unsigned int` :
   <img width="762" alt="image" src="https://user-images.githubusercontent.com/18066964/198894405-69783826-2aa3-4c61-b3f2-d4b9994e574e.png">
   From clang PR CI(https://github.com/apache/incubator-nuttx/actions/runs/3356310699/jobs/5561304512), clang expect `'uint32_t` equals `unsigned int`:
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] xiaoxiang781216 closed pull request #7476: arch/arm: Typedef _[u]int32_t to __[U]INT32_TYPE__ if __INT32_TYPE__ is defined

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 closed pull request #7476: arch/arm: Typedef _[u]int32_t to __[U]INT32_TYPE__ if __INT32_TYPE__ is defined
URL: https://github.com/apache/incubator-nuttx/pull/7476


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] pkarashchenko commented on a diff in pull request #7476: arch/arm: Typedef _[u]int32_t to __[U]INT32_TYPE__ if __INT32_TYPE__ is defined

Posted by GitBox <gi...@apache.org>.
pkarashchenko commented on code in PR #7476:
URL: https://github.com/apache/incubator-nuttx/pull/7476#discussion_r1009178122


##########
arch/arm/include/inttypes.h:
##########
@@ -31,89 +31,130 @@
 
 #define PRId8       "d"
 #define PRId16      "d"
-#define PRId32      "ld"
+#if defined(__INT32_TYPE__) && __INT32_TYPE__ == 2
+#  define PRId32    "d"
+#else
+#  define PRId32    "ld"
+#endif
 #define PRId64      "lld"
-
 #define PRIdPTR     "d"
 
 #define PRIi8       "i"
 #define PRIi16      "i"
-#define PRIi32      "li"
+#if defined(__INT32_TYPE__) && __INT32_TYPE__ == 2
+#  define PRIi32    "i"
+#else
+#  define PRIi32    "li"
+#endif
 #define PRIi64      "lli"
-
 #define PRIiPTR     "i"
 
 #define PRIo8       "o"
 #define PRIo16      "o"
-#define PRIo32      "lo"
+#if defined(__INT32_TYPE__) && __INT32_TYPE__ == 2
+#  define PRIo32    "o"
+#else
+#  define PRIo32    "lo"
+#endif
 #define PRIo64      "llo"
-
 #define PRIoPTR     "o"
 
 #define PRIu8       "u"
 #define PRIu16      "u"
-#define PRIu32      "lu"
+#if defined(__INT32_TYPE__) && __INT32_TYPE__ == 2
+#  define PRIu32    "u"
+#else
+#  define PRIu32    "lu"
+#endif
 #define PRIu64      "llu"
-
 #define PRIuPTR     "u"
 
 #define PRIx8       "x"
 #define PRIx16      "x"
-#define PRIx32      "lx"
+#if defined(__INT32_TYPE__) && __INT32_TYPE__ == 2
+#  define PRIx32    "x"
+#else
+#  define PRIx32    "lx"
+#endif
 #define PRIx64      "llx"
-
 #define PRIxPTR     "x"
 
 #define PRIX8       "X"
 #define PRIX16      "X"
-#define PRIX32      "lX"
+#if defined(__INT32_TYPE__) && __INT32_TYPE__ == 2

Review Comment:
   What about something like
   
   ```
   #if defined(__INT32_TYPE__) && __INT32_TYPE__ == 2
   #  define PRI32_PREFIX ""
   #else
   #  define PRI32_PREFIX "l"
   #endif
   ```
   And then use it in all places?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a diff in pull request #7476: arch/arm: Typedef _[u]int32_t to __[U]INT32_TYPE__ if __INT32_TYPE__ is defined

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #7476:
URL: https://github.com/apache/incubator-nuttx/pull/7476#discussion_r1009197485


##########
arch/arm/include/inttypes.h:
##########
@@ -31,89 +31,130 @@
 
 #define PRId8       "d"
 #define PRId16      "d"
-#define PRId32      "ld"
+#if defined(__INT32_TYPE__) && __INT32_TYPE__ == 2
+#  define PRId32    "d"
+#else
+#  define PRId32    "ld"
+#endif
 #define PRId64      "lld"
-
 #define PRIdPTR     "d"
 
 #define PRIi8       "i"
 #define PRIi16      "i"
-#define PRIi32      "li"
+#if defined(__INT32_TYPE__) && __INT32_TYPE__ == 2
+#  define PRIi32    "i"
+#else
+#  define PRIi32    "li"
+#endif
 #define PRIi64      "lli"
-
 #define PRIiPTR     "i"
 
 #define PRIo8       "o"
 #define PRIo16      "o"
-#define PRIo32      "lo"
+#if defined(__INT32_TYPE__) && __INT32_TYPE__ == 2
+#  define PRIo32    "o"
+#else
+#  define PRIo32    "lo"
+#endif
 #define PRIo64      "llo"
-
 #define PRIoPTR     "o"
 
 #define PRIu8       "u"
 #define PRIu16      "u"
-#define PRIu32      "lu"
+#if defined(__INT32_TYPE__) && __INT32_TYPE__ == 2
+#  define PRIu32    "u"
+#else
+#  define PRIu32    "lu"
+#endif
 #define PRIu64      "llu"
-
 #define PRIuPTR     "u"
 
 #define PRIx8       "x"
 #define PRIx16      "x"
-#define PRIx32      "lx"
+#if defined(__INT32_TYPE__) && __INT32_TYPE__ == 2
+#  define PRIx32    "x"
+#else
+#  define PRIx32    "lx"
+#endif
 #define PRIx64      "llx"
-
 #define PRIxPTR     "x"
 
 #define PRIX8       "X"
 #define PRIX16      "X"
-#define PRIX32      "lX"
+#if defined(__INT32_TYPE__) && __INT32_TYPE__ == 2

Review Comment:
   You mean other arch? Since uint32_t definition in other arch is fixed, I think the current solution is fine, only arm need the special treatment.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] pkarashchenko commented on a diff in pull request #7476: arch/arm: Typedef _[u]int32_t to __[U]INT32_TYPE__ if __INT32_TYPE__ is defined

Posted by GitBox <gi...@apache.org>.
pkarashchenko commented on code in PR #7476:
URL: https://github.com/apache/incubator-nuttx/pull/7476#discussion_r1009341876


##########
arch/arm/include/inttypes.h:
##########
@@ -29,91 +29,92 @@
  * Pre-processor Prototypes
  ****************************************************************************/
 
+#define int +2
+#define long +4
+
+#if defined(__INT32_TYPE__) && __INT32_TYPE__ == 2
+#  define INT32_MOD
+#else
+#  define INT32_MOD l
+#endif
+
+#undef int
+#undef long
+
 #define PRId8       "d"
 #define PRId16      "d"
-#define PRId32      "ld"
+#define PRId32      #INT32_MOD ## "d"
 #define PRId64      "lld"
-
 #define PRIdPTR     "d"
 
 #define PRIi8       "i"
 #define PRIi16      "i"
-#define PRIi32      "li"
+#define PRIi32      #INT32_MOD ## "i"
 #define PRIi64      "lli"
-
 #define PRIiPTR     "i"
 
 #define PRIo8       "o"
 #define PRIo16      "o"
-#define PRIo32      "lo"
+#define PRIo32      #INT32_MOD ## "o"
 #define PRIo64      "llo"
-
 #define PRIoPTR     "o"
 
 #define PRIu8       "u"
 #define PRIu16      "u"
-#define PRIu32      "lu"
+#define PRIu32      #INT32_MOD ## "u"
 #define PRIu64      "llu"
-
 #define PRIuPTR     "u"
 
 #define PRIx8       "x"
 #define PRIx16      "x"
-#define PRIx32      "lx"
+#define PRIx32      #INT32_MOD ## "x"
 #define PRIx64      "llx"
-
 #define PRIxPTR     "x"
 
 #define PRIX8       "X"
 #define PRIX16      "X"
-#define PRIX32      "lX"
+#define PRIX32      #INT32_MOD ## "X"
 #define PRIX64      "llX"
-
 #define PRIXPTR     "X"
 
 #define SCNd8       "hhd"
 #define SCNd16      "hd"
-#define SCNd32      "ld"
+#define SCNd32      #INT32_MOD ## "d"
 #define SCNd64      "lld"
-
 #define SCNdPTR     "d"
 
 #define SCNi8       "hhi"
 #define SCNi16      "hi"
-#define SCNi32      "li"
+#define SCNi32      #INT32_MOD ## "i"
 #define SCNi64      "lli"
-
 #define SCNiPTR     "i"
 
 #define SCNo8       "hho"
 #define SCNo16      "ho"
-#define SCNo32      "lo"
+#define SCNo32      #INT32_MOD ## "o"
 #define SCNo64      "llo"
-
 #define SCNoPTR     "o"
 
 #define SCNu8       "hhu"
 #define SCNu16      "hu"
-#define SCNu32      "lu"
+#define SCNu32      #INT32_MOD ## "u"
 #define SCNu64      "llu"
-
 #define SCNuPTR     "u"
 
 #define SCNx8       "hhx"
 #define SCNx16      "hx"
-#define SCNx32      "lx"
+#define SCNx32      #INT32_MOD ## "x"
 #define SCNx64      "llx"
-
 #define SCNxPTR     "x"
 
 #define INT8_C(x)   x
 #define INT16_C(x)  x
-#define INT32_C(x)  x ## l
+#define INT32_C(x)  x ## INT32_MOD
 #define INT64_C(x)  x ## ll
 
 #define UINT8_C(x)  x
 #define UINT16_C(x) x
-#define UINT32_C(x) x ## ul
+#define UINT32_C(x) x ## u ## INT32_MOD

Review Comment:
   Things will not work this way. You need additional macro to expend INT32_MOD with ##



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] xiaoxiang781216 commented on pull request #7476: arch/arm: Typedef _[u]int32_t to __[U]INT32_TYPE__ if __INT32_TYPE__ is defined

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on PR #7476:
URL: https://github.com/apache/incubator-nuttx/pull/7476#issuecomment-1296764480

   > i guess you need to tweak PRIu32 etc as well.
   
   Done.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a diff in pull request #7476: arch/arm: Typedef _[u]int32_t to __[U]INT32_TYPE__ if __INT32_TYPE__ is defined

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #7476:
URL: https://github.com/apache/incubator-nuttx/pull/7476#discussion_r1009482201


##########
arch/arm/include/inttypes.h:
##########
@@ -29,91 +29,138 @@
  * Pre-processor Prototypes
  ****************************************************************************/
 
+#define int         +2
+#define long        +4

Review Comment:
   It's a clever hack I guess from newlib:
   https://github.com/bminor/newlib/blob/master/newlib/libc/include/sys/_intsup.h#L57-L58
   The compiler may define `__INTPTR_TYPE__`  to `int`, `long` or `'long int`, how can we know which one in the compiler time?
   We can define `int` to +2 and `long` to +4, so `__INTPTR_TYPE__` will expand to `+2` for `int` or `+4` or `+2 + 4` for `long int` and `long`.
   so the compare of __INT32_TYPE__ equal 2 can work as expect. 



##########
arch/arm/include/inttypes.h:
##########
@@ -29,91 +29,138 @@
  * Pre-processor Prototypes
  ****************************************************************************/
 
+#define int         +2
+#define long        +4

Review Comment:
   It's a clever hack I guess from newlib:
   https://github.com/bminor/newlib/blob/master/newlib/libc/include/sys/_intsup.h#L57-L58
   The compiler may define `__INTPTR_TYPE__`  to `int`, `long` or `'long int`, how can we know which one in the compiler time?
   We can define `int` to +2 and `long` to +4, so `__INTPTR_TYPE__` will expand to `+2` for `int` or `+4` or `+2 + 4` for `long int` and `long`.
   so the compare of `__INT32_TYPE__` equal 2 can work as expect. 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a diff in pull request #7476: arch/arm: Typedef _[u]int32_t to __[U]INT32_TYPE__ if __INT32_TYPE__ is defined

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #7476:
URL: https://github.com/apache/incubator-nuttx/pull/7476#discussion_r1009388651


##########
arch/arm/include/inttypes.h:
##########
@@ -29,91 +29,92 @@
  * Pre-processor Prototypes
  ****************************************************************************/
 
+#define int +2
+#define long +4
+
+#if defined(__INT32_TYPE__) && __INT32_TYPE__ == 2
+#  define INT32_MOD
+#else
+#  define INT32_MOD l
+#endif
+
+#undef int
+#undef long
+
 #define PRId8       "d"
 #define PRId16      "d"
-#define PRId32      "ld"
+#define PRId32      #INT32_MOD ## "d"
 #define PRId64      "lld"
-
 #define PRIdPTR     "d"
 
 #define PRIi8       "i"
 #define PRIi16      "i"
-#define PRIi32      "li"
+#define PRIi32      #INT32_MOD ## "i"
 #define PRIi64      "lli"
-
 #define PRIiPTR     "i"
 
 #define PRIo8       "o"
 #define PRIo16      "o"
-#define PRIo32      "lo"
+#define PRIo32      #INT32_MOD ## "o"
 #define PRIo64      "llo"
-
 #define PRIoPTR     "o"
 
 #define PRIu8       "u"
 #define PRIu16      "u"
-#define PRIu32      "lu"
+#define PRIu32      #INT32_MOD ## "u"
 #define PRIu64      "llu"
-
 #define PRIuPTR     "u"
 
 #define PRIx8       "x"
 #define PRIx16      "x"
-#define PRIx32      "lx"
+#define PRIx32      #INT32_MOD ## "x"
 #define PRIx64      "llx"
-
 #define PRIxPTR     "x"
 
 #define PRIX8       "X"
 #define PRIX16      "X"
-#define PRIX32      "lX"
+#define PRIX32      #INT32_MOD ## "X"
 #define PRIX64      "llX"
-
 #define PRIXPTR     "X"
 
 #define SCNd8       "hhd"
 #define SCNd16      "hd"
-#define SCNd32      "ld"
+#define SCNd32      #INT32_MOD ## "d"
 #define SCNd64      "lld"
-
 #define SCNdPTR     "d"
 
 #define SCNi8       "hhi"
 #define SCNi16      "hi"
-#define SCNi32      "li"
+#define SCNi32      #INT32_MOD ## "i"
 #define SCNi64      "lli"
-
 #define SCNiPTR     "i"
 
 #define SCNo8       "hho"
 #define SCNo16      "ho"
-#define SCNo32      "lo"
+#define SCNo32      #INT32_MOD ## "o"
 #define SCNo64      "llo"
-
 #define SCNoPTR     "o"
 
 #define SCNu8       "hhu"
 #define SCNu16      "hu"
-#define SCNu32      "lu"
+#define SCNu32      #INT32_MOD ## "u"
 #define SCNu64      "llu"
-
 #define SCNuPTR     "u"
 
 #define SCNx8       "hhx"
 #define SCNx16      "hx"
-#define SCNx32      "lx"
+#define SCNx32      #INT32_MOD ## "x"
 #define SCNx64      "llx"
-
 #define SCNxPTR     "x"
 
 #define INT8_C(x)   x
 #define INT16_C(x)  x
-#define INT32_C(x)  x ## l
+#define INT32_C(x)  x ## INT32_MOD
 #define INT64_C(x)  x ## ll
 
 #define UINT8_C(x)  x
 #define UINT16_C(x) x
-#define UINT32_C(x) x ## ul
+#define UINT32_C(x) x ## u ## INT32_MOD

Review Comment:
   So, I prefer to keep it in the simple form.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] yamt commented on a diff in pull request #7476: arch/arm: Typedef _[u]int32_t to __[U]INT32_TYPE__ if __INT32_TYPE__ is defined

Posted by GitBox <gi...@apache.org>.
yamt commented on code in PR #7476:
URL: https://github.com/apache/incubator-nuttx/pull/7476#discussion_r1010535210


##########
arch/arm/include/inttypes.h:
##########
@@ -29,91 +29,142 @@
  * Pre-processor Prototypes
  ****************************************************************************/
 
+#define signed      +0
+#define unsigned    +0
+#define int         +2

Review Comment:
   clever trick.
   but i guess it warrants a comment.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a diff in pull request #7476: arch/arm: Typedef _[u]int32_t to __[U]INT32_TYPE__ if __INT32_TYPE__ is defined

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #7476:
URL: https://github.com/apache/incubator-nuttx/pull/7476#discussion_r1009392685


##########
arch/arm/include/inttypes.h:
##########
@@ -31,89 +31,130 @@
 
 #define PRId8       "d"
 #define PRId16      "d"
-#define PRId32      "ld"
+#if defined(__INT32_TYPE__) && __INT32_TYPE__ == 2
+#  define PRId32    "d"
+#else
+#  define PRId32    "ld"
+#endif
 #define PRId64      "lld"
-
 #define PRIdPTR     "d"
 
 #define PRIi8       "i"
 #define PRIi16      "i"
-#define PRIi32      "li"
+#if defined(__INT32_TYPE__) && __INT32_TYPE__ == 2
+#  define PRIi32    "i"
+#else
+#  define PRIi32    "li"
+#endif
 #define PRIi64      "lli"
-
 #define PRIiPTR     "i"
 
 #define PRIo8       "o"
 #define PRIo16      "o"
-#define PRIo32      "lo"
+#if defined(__INT32_TYPE__) && __INT32_TYPE__ == 2
+#  define PRIo32    "o"
+#else
+#  define PRIo32    "lo"
+#endif
 #define PRIo64      "llo"
-
 #define PRIoPTR     "o"
 
 #define PRIu8       "u"
 #define PRIu16      "u"
-#define PRIu32      "lu"
+#if defined(__INT32_TYPE__) && __INT32_TYPE__ == 2
+#  define PRIu32    "u"
+#else
+#  define PRIu32    "lu"
+#endif
 #define PRIu64      "llu"
-
 #define PRIuPTR     "u"
 
 #define PRIx8       "x"
 #define PRIx16      "x"
-#define PRIx32      "lx"
+#if defined(__INT32_TYPE__) && __INT32_TYPE__ == 2
+#  define PRIx32    "x"
+#else
+#  define PRIx32    "lx"
+#endif
 #define PRIx64      "llx"
-
 #define PRIxPTR     "x"
 
 #define PRIX8       "X"
 #define PRIX16      "X"
-#define PRIX32      "lX"
+#if defined(__INT32_TYPE__) && __INT32_TYPE__ == 2

Review Comment:
   Since this approach need define more macro(e.g. STRINGIFY, CONCAT...), I prefer to keep the simple form.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] pkarashchenko commented on a diff in pull request #7476: arch/arm: Typedef _[u]int32_t to __[U]INT32_TYPE__ if __INT32_TYPE__ is defined

Posted by GitBox <gi...@apache.org>.
pkarashchenko commented on code in PR #7476:
URL: https://github.com/apache/incubator-nuttx/pull/7476#discussion_r1009468832


##########
arch/arm/include/inttypes.h:
##########
@@ -29,91 +29,138 @@
  * Pre-processor Prototypes
  ****************************************************************************/
 
+#define int         +2
+#define long        +4

Review Comment:
   Why this is needed?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a diff in pull request #7476: arch/arm: Typedef _[u]int32_t to __[U]INT32_TYPE__ if __INT32_TYPE__ is defined

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #7476:
URL: https://github.com/apache/incubator-nuttx/pull/7476#discussion_r1009482201


##########
arch/arm/include/inttypes.h:
##########
@@ -29,91 +29,138 @@
  * Pre-processor Prototypes
  ****************************************************************************/
 
+#define int         +2
+#define long        +4

Review Comment:
   It's a clever hack I guess from newlib:
   https://github.com/bminor/newlib/blob/master/newlib/libc/include/sys/_intsup.h#L57-L58
   The compiler may define `__INTPTR_TYPE__`  to 'int', `long` or `'long int`, how can we know which one in the compiler time?
   We can define `int` to +2 and `long` to +4, so `__INTPTR_TYPE__` will expand to `+2` for `int` or `+4` or `+2 + 4` for `long int` and `long`.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] GUIDINGLI commented on a diff in pull request #7476: arch/arm: Typedef _[u]int32_t to __[U]INT32_TYPE__ if __INT32_TYPE__ is defined

Posted by GitBox <gi...@apache.org>.
GUIDINGLI commented on code in PR #7476:
URL: https://github.com/apache/incubator-nuttx/pull/7476#discussion_r1009502352


##########
arch/arm/include/inttypes.h:
##########
@@ -29,91 +29,142 @@
  * Pre-processor Prototypes
  ****************************************************************************/
 
+#define signed      +0
+#define unsigned    +0
+#define int         +2
+#define long        +4
+
 #define PRId8       "d"
 #define PRId16      "d"
-#define PRId32      "ld"
+#if defined(__INT32_TYPE__) && __INT32_TYPE__ == 2

Review Comment:
   change 2 to  signed int



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] pkarashchenko commented on pull request #7476: arch/arm: Typedef _[u]int32_t to __[U]INT32_TYPE__ if __INT32_TYPE__ is defined

Posted by GitBox <gi...@apache.org>.
pkarashchenko commented on PR #7476:
URL: https://github.com/apache/incubator-nuttx/pull/7476#issuecomment-1296557213

   Yeah. The printf format specifiers should be tuned as well. @xiaoxiang781216 if the issue appears to be only with __builtin_swapXX usage, then let's add a cast to the NuttX swapXX macro and fix this with "small blood"?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] pkarashchenko merged pull request #7476: arch/arm: Typedef _[u]int32_t to __[U]INT32_TYPE__ if __INT32_TYPE__ is defined

Posted by GitBox <gi...@apache.org>.
pkarashchenko merged PR #7476:
URL: https://github.com/apache/incubator-nuttx/pull/7476


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] pkarashchenko commented on pull request #7476: arch/arm: Typedef _[u]int32_t to __[U]INT32_TYPE__ if __INT32_TYPE__ is defined

Posted by GitBox <gi...@apache.org>.
pkarashchenko commented on PR #7476:
URL: https://github.com/apache/incubator-nuttx/pull/7476#issuecomment-1298558135

   I'm fine. Just waiting @yamt to approve.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a diff in pull request #7476: arch/arm: Typedef _[u]int32_t to __[U]INT32_TYPE__ if __INT32_TYPE__ is defined

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #7476:
URL: https://github.com/apache/incubator-nuttx/pull/7476#discussion_r1009503653


##########
arch/arm/include/inttypes.h:
##########
@@ -29,91 +29,142 @@
  * Pre-processor Prototypes
  ****************************************************************************/
 
+#define signed      +0
+#define unsigned    +0
+#define int         +2
+#define long        +4
+
 #define PRId8       "d"
 #define PRId16      "d"
-#define PRId32      "ld"
+#if defined(__INT32_TYPE__) && __INT32_TYPE__ == 2

Review Comment:
   Done. Yes, it's more clear to compare __INT32_TYPE__  to int



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a diff in pull request #7476: arch/arm: Typedef _[u]int32_t to __[U]INT32_TYPE__ if __INT32_TYPE__ is defined

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #7476:
URL: https://github.com/apache/incubator-nuttx/pull/7476#discussion_r1009503653


##########
arch/arm/include/inttypes.h:
##########
@@ -29,91 +29,142 @@
  * Pre-processor Prototypes
  ****************************************************************************/
 
+#define signed      +0
+#define unsigned    +0
+#define int         +2
+#define long        +4
+
 #define PRId8       "d"
 #define PRId16      "d"
-#define PRId32      "ld"
+#if defined(__INT32_TYPE__) && __INT32_TYPE__ == 2

Review Comment:
   Done.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a diff in pull request #7476: arch/arm: Typedef _[u]int32_t to __[U]INT32_TYPE__ if __INT32_TYPE__ is defined

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #7476:
URL: https://github.com/apache/incubator-nuttx/pull/7476#discussion_r1009197485


##########
arch/arm/include/inttypes.h:
##########
@@ -31,89 +31,130 @@
 
 #define PRId8       "d"
 #define PRId16      "d"
-#define PRId32      "ld"
+#if defined(__INT32_TYPE__) && __INT32_TYPE__ == 2
+#  define PRId32    "d"
+#else
+#  define PRId32    "ld"
+#endif
 #define PRId64      "lld"
-
 #define PRIdPTR     "d"
 
 #define PRIi8       "i"
 #define PRIi16      "i"
-#define PRIi32      "li"
+#if defined(__INT32_TYPE__) && __INT32_TYPE__ == 2
+#  define PRIi32    "i"
+#else
+#  define PRIi32    "li"
+#endif
 #define PRIi64      "lli"
-
 #define PRIiPTR     "i"
 
 #define PRIo8       "o"
 #define PRIo16      "o"
-#define PRIo32      "lo"
+#if defined(__INT32_TYPE__) && __INT32_TYPE__ == 2
+#  define PRIo32    "o"
+#else
+#  define PRIo32    "lo"
+#endif
 #define PRIo64      "llo"
-
 #define PRIoPTR     "o"
 
 #define PRIu8       "u"
 #define PRIu16      "u"
-#define PRIu32      "lu"
+#if defined(__INT32_TYPE__) && __INT32_TYPE__ == 2
+#  define PRIu32    "u"
+#else
+#  define PRIu32    "lu"
+#endif
 #define PRIu64      "llu"
-
 #define PRIuPTR     "u"
 
 #define PRIx8       "x"
 #define PRIx16      "x"
-#define PRIx32      "lx"
+#if defined(__INT32_TYPE__) && __INT32_TYPE__ == 2
+#  define PRIx32    "x"
+#else
+#  define PRIx32    "lx"
+#endif
 #define PRIx64      "llx"
-
 #define PRIxPTR     "x"
 
 #define PRIX8       "X"
 #define PRIX16      "X"
-#define PRIX32      "lX"
+#if defined(__INT32_TYPE__) && __INT32_TYPE__ == 2

Review Comment:
   You mean other arch? Since uint32_t definition in other arch is fixed, I think the current solution is fine.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org