[dpdk-dev] [PATCH] test-pmd: Fix "__BYTE_ORDER__" not defined error

Qiu, Michael michael.qiu at intel.com
Wed Dec 3 17:26:02 CET 2014


Hi all,

What about this patch?

It may be some network or mail client issue of me, so not sure this
patch posted to mail list successful.

If failed, I will re-post it later.

Thanks,
Michael

On 2014/12/3 19:28, Michael Qiu wrote:
> app/test-pmd/csumonly.c:84:5: error: "__BYTE_ORDER__" is not defined
> app/test-pmd/csumonly.c:84:23: error: "__ORDER_LITTLE_ENDIAN__" is not defined
>
> This because old gcc version, like 4.4.7, does not has these buildin macros.
>
> $ gcc -v
> Using built-in specs.
> Target: x86_64-redhat-linux
> ...
> gcc version 4.4.7 20120313 (Red Hat 4.4.7-4) (GCC)
>
> $ echo | gcc -dM -E -| grep "LITTLE"
> (none)
>
> In this situation, we should back to use the macros defined in
> <endian.h>
>
> Signed-off-by: Michael Qiu <michael.qiu at intel.com>
> ---
>  app/test-pmd/csumonly.c | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c
> index 6f43761..3fa81a2 100644
> --- a/app/test-pmd/csumonly.c
> +++ b/app/test-pmd/csumonly.c
> @@ -81,7 +81,13 @@
>  
>  /* we cannot use htons() from arpa/inet.h due to name conflicts, and we
>   * cannot use rte_cpu_to_be_16() on a constant in a switch/case */
> -#if  __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
> +#ifdef __BYTE_ORDER__
> +#define LITTLE_ENDIAN_CHECK (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)
> +#else
> +#define LITTLE_ENDIAN_CHECK (__BYTE_ORDER == __LITTLE_ENDIAN)
> +#endif
> +
> +#if LITTLE_ENDIAN_CHECK
>  #define _htons(x) ((uint16_t)((((x) & 0x00ffU) << 8) | (((x) & 0xff00U) >> 8)))
>  #else
>  #define _htons(x) (x)



More information about the dev mailing list