mynewt-nimble
mynewt-nimble copied to clipboard
porting/nimble/include: Add check of macro
There isn't macro BYTE_ORDER and ORDER_BIG_ENDIAN on other compiler like KEIL or IAR. In that case, the complier will complier without error, but the HCI cmd will be BIG_ENDIAN as default which is wrong on ARM Cortex-m little endian platform.
Style check summary
Our coding style is here!
porting/nimble/include/os/endian.h
@@ -29,35 +29,35 @@
/* Internal helpers */
#ifndef os_bswap_64
#define os_bswap_64(x) ((uint64_t) \
- ((((x) & 0xff00000000000000ull) >> 56) | \
- (((x) & 0x00ff000000000000ull) >> 40) | \
- (((x) & 0x0000ff0000000000ull) >> 24) | \
- (((x) & 0x000000ff00000000ull) >> 8) | \
- (((x) & 0x00000000ff000000ull) << 8) | \
- (((x) & 0x0000000000ff0000ull) << 24) | \
- (((x) & 0x000000000000ff00ull) << 40) | \
- (((x) & 0x00000000000000ffull) << 56)))
+ ((((x) & 0xff00000000000000ull) >> 56) | \
+ (((x) & 0x00ff000000000000ull) >> 40) | \
+ (((x) & 0x0000ff0000000000ull) >> 24) | \
+ (((x) & 0x000000ff00000000ull) >> 8) | \
+ (((x) & 0x00000000ff000000ull) << 8) | \
+ (((x) & 0x0000000000ff0000ull) << 24) | \
+ (((x) & 0x000000000000ff00ull) << 40) | \
+ (((x) & 0x00000000000000ffull) << 56)))
#endif
#ifndef os_bswap_32
#define os_bswap_32(x) ((uint32_t) \
- ((((x) & 0xff000000) >> 24) | \
- (((x) & 0x00ff0000) >> 8) | \
- (((x) & 0x0000ff00) << 8) | \
- (((x) & 0x000000ff) << 24)))
+ ((((x) & 0xff000000) >> 24) | \
+ (((x) & 0x00ff0000) >> 8) | \
+ (((x) & 0x0000ff00) << 8) | \
+ (((x) & 0x000000ff) << 24)))
#endif
#ifndef os_bswap_16
#define os_bswap_16(x) ((uint16_t) \
- ((((x) & 0xff00) >> 8) | \
- (((x) & 0x00ff) << 8)))
-#endif
-
-#ifndef __BYTE_ORDER__
+ ((((x) & 0xff00) >> 8) | \
+ (((x) & 0x00ff) << 8)))
+#endif
+
+#ifndef __BYTE_ORDER__
#error "Please define __BYTE_ORDER__ on complier"
#endif
-#ifndef __ORDER_BIG_ENDIAN__
+#ifndef __ORDER_BIG_ENDIAN__
#error "Please define __ORDER_BIG_ENDIAN__ on complier"
#endif
Style check summary
Our coding style is here!
porting/nimble/include/os/endian.h
@@ -29,35 +29,35 @@ /* Internal helpers */ #ifndef os_bswap_64 #define os_bswap_64(x) ((uint64_t) \ - ((((x) & 0xff00000000000000ull) >> 56) | \ - (((x) & 0x00ff000000000000ull) >> 40) | \ - (((x) & 0x0000ff0000000000ull) >> 24) | \ - (((x) & 0x000000ff00000000ull) >> 8) | \ - (((x) & 0x00000000ff000000ull) << 8) | \ - (((x) & 0x0000000000ff0000ull) << 24) | \ - (((x) & 0x000000000000ff00ull) << 40) | \ - (((x) & 0x00000000000000ffull) << 56))) + ((((x) & 0xff00000000000000ull) >> 56) | \ + (((x) & 0x00ff000000000000ull) >> 40) | \ + (((x) & 0x0000ff0000000000ull) >> 24) | \ + (((x) & 0x000000ff00000000ull) >> 8) | \ + (((x) & 0x00000000ff000000ull) << 8) | \ + (((x) & 0x0000000000ff0000ull) << 24) | \ + (((x) & 0x000000000000ff00ull) << 40) | \ + (((x) & 0x00000000000000ffull) << 56))) #endif #ifndef os_bswap_32 #define os_bswap_32(x) ((uint32_t) \ - ((((x) & 0xff000000) >> 24) | \ - (((x) & 0x00ff0000) >> 8) | \ - (((x) & 0x0000ff00) << 8) | \ - (((x) & 0x000000ff) << 24))) + ((((x) & 0xff000000) >> 24) | \ + (((x) & 0x00ff0000) >> 8) | \ + (((x) & 0x0000ff00) << 8) | \ + (((x) & 0x000000ff) << 24))) #endif #ifndef os_bswap_16 #define os_bswap_16(x) ((uint16_t) \ - ((((x) & 0xff00) >> 8) | \ - (((x) & 0x00ff) << 8))) -#endif - -#ifndef __BYTE_ORDER__ + ((((x) & 0xff00) >> 8) | \ + (((x) & 0x00ff) << 8))) +#endif + +#ifndef __BYTE_ORDER__ #error "Please define __BYTE_ORDER__ on complier" #endif -#ifndef __ORDER_BIG_ENDIAN__ +#ifndef __ORDER_BIG_ENDIAN__ #error "Please define __ORDER_BIG_ENDIAN__ on complier" #endif
could you give me the cmd of astyle? or something else cmd