diff options
Diffstat (limited to 'platform/linux-generic/include/odp/api/plat/byteorder_inlines.h')
-rw-r--r-- | platform/linux-generic/include/odp/api/plat/byteorder_inlines.h | 59 |
1 files changed, 50 insertions, 9 deletions
diff --git a/platform/linux-generic/include/odp/api/plat/byteorder_inlines.h b/platform/linux-generic/include/odp/api/plat/byteorder_inlines.h index e7818904b..692c66c74 100644 --- a/platform/linux-generic/include/odp/api/plat/byteorder_inlines.h +++ b/platform/linux-generic/include/odp/api/plat/byteorder_inlines.h @@ -1,7 +1,5 @@ -/* Copyright (c) 2016, Linaro Limited - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright (c) 2016-2018 Linaro Limited */ /** @@ -17,9 +15,54 @@ extern "C" { #endif -/** @ingroup odp_compiler_optim - * @{ +#include <odp/api/abi/byteorder.h> + +/** @cond _ODP_HIDE_FROM_DOXYGEN_ */ + +#ifndef __odp_force +#define __odp_force +#endif + +#ifndef _ODP_NO_INLINE + /* Inline functions by default */ + #define _ODP_INLINE static inline + #define odp_be_to_cpu_16 __odp_be_to_cpu_16 + #define odp_be_to_cpu_32 __odp_be_to_cpu_32 + #define odp_be_to_cpu_64 __odp_be_to_cpu_64 + #define odp_cpu_to_be_16 __odp_cpu_to_be_16 + #define odp_cpu_to_be_32 __odp_cpu_to_be_32 + #define odp_cpu_to_be_64 __odp_cpu_to_be_64 + #define odp_le_to_cpu_16 __odp_le_to_cpu_16 + #define odp_le_to_cpu_32 __odp_le_to_cpu_32 + #define odp_le_to_cpu_64 __odp_le_to_cpu_64 + #define odp_cpu_to_le_16 __odp_cpu_to_le_16 + #define odp_cpu_to_le_32 __odp_cpu_to_le_32 + #define odp_cpu_to_le_64 __odp_cpu_to_le_64 +#else + #define _ODP_INLINE +#endif + +/** @internal GNU compiler version */ +#define GCC_VERSION (__GNUC__ * 10000 \ + + __GNUC_MINOR__ * 100 \ + + __GNUC_PATCHLEVEL__) + +/** + * @internal + * Compiler __builtin_bswap16() is not available on all platforms + * until GCC 4.8.0 - work around this by offering __odp_builtin_bswap16() + * Don't use this function directly, instead see odp_byteorder.h */ +#if GCC_VERSION < 40800 +/* + * We have to explicitly cast back to uint16_t because clang promotes the + * left side of << operator to int. + */ +#define __odp_builtin_bswap16(u16) ((uint16_t)(((u16)&0x00ff) << 8) | \ + (((u16)&0xff00) >> 8)) +#else +#define __odp_builtin_bswap16(u16) __builtin_bswap16(u16) +#endif _ODP_INLINE uint16_t odp_be_to_cpu_16(odp_u16be_t be16) { @@ -129,9 +172,7 @@ _ODP_INLINE odp_u64le_t odp_cpu_to_le_64(uint64_t cpu64) #endif } -/** - * @} - */ +/** @endcond */ #ifdef __cplusplus } |