pkarashchenko commented on code in PR #6482: URL: https://github.com/apache/incubator-nuttx/pull/6482#discussion_r903382876
########## include/nuttx/compiler.h: ########## @@ -69,6 +69,36 @@ # undef CONFIG_HAVE_CXX14 #endif +#if defined(__cplusplus) && __cplusplus >= 201703L +# define CONFIG_HAVE_CXX17 1 +#else +# undef CONFIG_HAVE_CXX17 +#endif + + +/* Check for intrinsics */ +#ifdef __has_builtin +# if __has_builtin(__builtin_bswap16) +# define CONFIG_HAVE_BUILTIN_BSWAP16 1 +# endif +# if __has_builtin(__builtin_bswap32) +# define CONFIG_HAVE_BUILTIN_BSWAP32 1 +# endif +# if __has_builtin(__builtin_bswap64) && defined(CONFIG_HAVE_LONG_LONG) +# define CONFIG_HAVE_BUILTIN_BSWAP64 1 +# endif +# if __has_builtin(__builtin_ctz) +# define CONFIG_HAVE_BUILTIN_CTZ 1 +# endif +# if __has_builtin(__builtin_clz) +# define CONFIG_HAVE_BUILTIN_CLZ 1 +# endif +# if __has_builtin(__builtin_popcount) +# define CONFIG_HAVE_BUILTIN_POPCOUNT 1 +# endif +#endif Review Comment: Please move all this block under `#ifdef __GNUC__`. Also according https://stackoverflow.com/questions/54079257/how-to-check-builtin-function-is-available-on-gcc the `__has_builtin` is a new GCC feature while the old version might still have builtin functions available, but will fail `__has_builtin` check. It is better to rely on the GCC version. And please use 2 spaces indentation. ########## include/netinet/in.h: ########## @@ -217,26 +217,16 @@ /* This macro to convert a 16/32-bit constant values quantity from host byte * order to network byte order. The 16-bit version of this macro is required * for uIP: - * - * Author Adam Dunkels <a...@dunkels.com> - * Copyright (c) 2001-2003, Adam Dunkels. - * All rights reserved. */ #ifdef CONFIG_ENDIAN_BIG # define HTONS(ns) (ns) # define HTONL(nl) (nl) +#elif defined (CONFIG_ENDIAN_LITTLE) +# define HTONS(ns) ((uint16_t)__swap_uint16(((uint16_t) (ns)))) +# define HTONL(nl) ((uint32_t)__swap_uint32(((uint32_t) (nl)))) #else -# define HTONS(ns) \ - (unsigned short) \ - (((((unsigned short)(ns)) & 0x00ff) << 8) | \ - ((((unsigned short)(ns)) >> 8) & 0x00ff)) -# define HTONL(nl) \ - (unsigned long) \ - (((((unsigned long)(nl)) & 0x000000ffUL) << 24) | \ - ((((unsigned long)(nl)) & 0x0000ff00UL) << 8) | \ - ((((unsigned long)(nl)) & 0x00ff0000UL) >> 8) | \ - ((((unsigned long)(nl)) & 0xff000000UL) >> 24)) +# error "PDP-11s are not supported." Review Comment: ```suggestion # error "PDP-11s are not supported." ``` ########## include/netinet/in.h: ########## @@ -217,26 +217,16 @@ /* This macro to convert a 16/32-bit constant values quantity from host byte * order to network byte order. The 16-bit version of this macro is required * for uIP: - * - * Author Adam Dunkels <a...@dunkels.com> - * Copyright (c) 2001-2003, Adam Dunkels. - * All rights reserved. */ #ifdef CONFIG_ENDIAN_BIG # define HTONS(ns) (ns) # define HTONL(nl) (nl) +#elif defined (CONFIG_ENDIAN_LITTLE) Review Comment: ```suggestion #elif defined(CONFIG_ENDIAN_LITTLE) ``` ########## include/netinet/in.h: ########## @@ -217,26 +217,16 @@ /* This macro to convert a 16/32-bit constant values quantity from host byte * order to network byte order. The 16-bit version of this macro is required * for uIP: - * - * Author Adam Dunkels <a...@dunkels.com> - * Copyright (c) 2001-2003, Adam Dunkels. - * All rights reserved. */ #ifdef CONFIG_ENDIAN_BIG # define HTONS(ns) (ns) # define HTONL(nl) (nl) Review Comment: ```suggestion # define HTONS(ns) (ns) # define HTONL(nl) (nl) ``` -- 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-unsubscr...@nuttx.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org