mirror of
https://github.com/facebook/zstd.git
synced 2025-12-08 00:03:24 -05:00
Merge pull request #4046 from josepho0918/iar
Improve support for IAR compiler with attributes and intrinsics
This commit is contained in:
commit
f70fb7c870
@ -43,6 +43,8 @@ MEM_STATIC unsigned ZSTD_countTrailingZeros32(U32 val)
|
|||||||
# endif
|
# endif
|
||||||
# elif defined(__GNUC__) && (__GNUC__ >= 4)
|
# elif defined(__GNUC__) && (__GNUC__ >= 4)
|
||||||
return (unsigned)__builtin_ctz(val);
|
return (unsigned)__builtin_ctz(val);
|
||||||
|
# elif defined(__ICCARM__)
|
||||||
|
return (unsigned)__builtin_ctz(val);
|
||||||
# else
|
# else
|
||||||
return ZSTD_countTrailingZeros32_fallback(val);
|
return ZSTD_countTrailingZeros32_fallback(val);
|
||||||
# endif
|
# endif
|
||||||
@ -82,6 +84,8 @@ MEM_STATIC unsigned ZSTD_countLeadingZeros32(U32 val)
|
|||||||
# endif
|
# endif
|
||||||
# elif defined(__GNUC__) && (__GNUC__ >= 4)
|
# elif defined(__GNUC__) && (__GNUC__ >= 4)
|
||||||
return (unsigned)__builtin_clz(val);
|
return (unsigned)__builtin_clz(val);
|
||||||
|
# elif defined(__ICCARM__)
|
||||||
|
return (unsigned)__builtin_clz(val);
|
||||||
# else
|
# else
|
||||||
return ZSTD_countLeadingZeros32_fallback(val);
|
return ZSTD_countLeadingZeros32_fallback(val);
|
||||||
# endif
|
# endif
|
||||||
@ -105,6 +109,8 @@ MEM_STATIC unsigned ZSTD_countTrailingZeros64(U64 val)
|
|||||||
# endif
|
# endif
|
||||||
# elif defined(__GNUC__) && (__GNUC__ >= 4) && defined(__LP64__)
|
# elif defined(__GNUC__) && (__GNUC__ >= 4) && defined(__LP64__)
|
||||||
return (unsigned)__builtin_ctzll(val);
|
return (unsigned)__builtin_ctzll(val);
|
||||||
|
# elif defined(__ICCARM__)
|
||||||
|
return (unsigned)__builtin_ctzll(val);
|
||||||
# else
|
# else
|
||||||
{
|
{
|
||||||
U32 mostSignificantWord = (U32)(val >> 32);
|
U32 mostSignificantWord = (U32)(val >> 32);
|
||||||
@ -136,6 +142,8 @@ MEM_STATIC unsigned ZSTD_countLeadingZeros64(U64 val)
|
|||||||
# endif
|
# endif
|
||||||
# elif defined(__GNUC__) && (__GNUC__ >= 4)
|
# elif defined(__GNUC__) && (__GNUC__ >= 4)
|
||||||
return (unsigned)(__builtin_clzll(val));
|
return (unsigned)(__builtin_clzll(val));
|
||||||
|
# elif defined(__ICCARM__)
|
||||||
|
return (unsigned)(__builtin_clzll(val));
|
||||||
# else
|
# else
|
||||||
{
|
{
|
||||||
U32 mostSignificantWord = (U32)(val >> 32);
|
U32 mostSignificantWord = (U32)(val >> 32);
|
||||||
|
|||||||
@ -27,7 +27,7 @@
|
|||||||
# define INLINE_KEYWORD
|
# define INLINE_KEYWORD
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(__GNUC__) || defined(__ICCARM__)
|
#if defined(__GNUC__) || defined(__IAR_SYSTEMS_ICC__)
|
||||||
# define FORCE_INLINE_ATTR __attribute__((always_inline))
|
# define FORCE_INLINE_ATTR __attribute__((always_inline))
|
||||||
#elif defined(_MSC_VER)
|
#elif defined(_MSC_VER)
|
||||||
# define FORCE_INLINE_ATTR __forceinline
|
# define FORCE_INLINE_ATTR __forceinline
|
||||||
@ -54,7 +54,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* UNUSED_ATTR tells the compiler it is okay if the function is unused. */
|
/* UNUSED_ATTR tells the compiler it is okay if the function is unused. */
|
||||||
#if defined(__GNUC__)
|
#if defined(__GNUC__) || defined(__IAR_SYSTEMS_ICC__)
|
||||||
# define UNUSED_ATTR __attribute__((unused))
|
# define UNUSED_ATTR __attribute__((unused))
|
||||||
#else
|
#else
|
||||||
# define UNUSED_ATTR
|
# define UNUSED_ATTR
|
||||||
@ -95,6 +95,8 @@
|
|||||||
#ifndef MEM_STATIC /* already defined in Linux Kernel mem.h */
|
#ifndef MEM_STATIC /* already defined in Linux Kernel mem.h */
|
||||||
#if defined(__GNUC__)
|
#if defined(__GNUC__)
|
||||||
# define MEM_STATIC static __inline UNUSED_ATTR
|
# define MEM_STATIC static __inline UNUSED_ATTR
|
||||||
|
#elif defined(__IAR_SYSTEMS_ICC__)
|
||||||
|
# define MEM_STATIC static inline UNUSED_ATTR
|
||||||
#elif defined (__cplusplus) || (defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 */)
|
#elif defined (__cplusplus) || (defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 */)
|
||||||
# define MEM_STATIC static inline
|
# define MEM_STATIC static inline
|
||||||
#elif defined(_MSC_VER)
|
#elif defined(_MSC_VER)
|
||||||
@ -108,7 +110,7 @@
|
|||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
# define FORCE_NOINLINE static __declspec(noinline)
|
# define FORCE_NOINLINE static __declspec(noinline)
|
||||||
#else
|
#else
|
||||||
# if defined(__GNUC__) || defined(__ICCARM__)
|
# if defined(__GNUC__) || defined(__IAR_SYSTEMS_ICC__)
|
||||||
# define FORCE_NOINLINE static __attribute__((__noinline__))
|
# define FORCE_NOINLINE static __attribute__((__noinline__))
|
||||||
# else
|
# else
|
||||||
# define FORCE_NOINLINE static
|
# define FORCE_NOINLINE static
|
||||||
@ -117,7 +119,7 @@
|
|||||||
|
|
||||||
|
|
||||||
/* target attribute */
|
/* target attribute */
|
||||||
#if defined(__GNUC__) || defined(__ICCARM__)
|
#if defined(__GNUC__) || defined(__IAR_SYSTEMS_ICC__)
|
||||||
# define TARGET_ATTRIBUTE(target) __attribute__((__target__(target)))
|
# define TARGET_ATTRIBUTE(target) __attribute__((__target__(target)))
|
||||||
#else
|
#else
|
||||||
# define TARGET_ATTRIBUTE(target)
|
# define TARGET_ATTRIBUTE(target)
|
||||||
|
|||||||
@ -30,6 +30,8 @@ extern "C" {
|
|||||||
#if defined(_MSC_VER) /* Visual Studio */
|
#if defined(_MSC_VER) /* Visual Studio */
|
||||||
# include <stdlib.h> /* _byteswap_ulong */
|
# include <stdlib.h> /* _byteswap_ulong */
|
||||||
# include <intrin.h> /* _byteswap_* */
|
# include <intrin.h> /* _byteswap_* */
|
||||||
|
#elif defined(__ICCARM__)
|
||||||
|
# include <intrinsics.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*-**************************************************************
|
/*-**************************************************************
|
||||||
@ -154,6 +156,8 @@ MEM_STATIC unsigned MEM_isLittleEndian(void)
|
|||||||
return 1;
|
return 1;
|
||||||
#elif defined(__DMC__) && defined(_M_IX86)
|
#elif defined(__DMC__) && defined(_M_IX86)
|
||||||
return 1;
|
return 1;
|
||||||
|
#elif defined(__IAR_SYSTEMS_ICC__) && __LITTLE_ENDIAN__
|
||||||
|
return 1;
|
||||||
#else
|
#else
|
||||||
const union { U32 u; BYTE c[4]; } one = { 1 }; /* don't use static : performance detrimental */
|
const union { U32 u; BYTE c[4]; } one = { 1 }; /* don't use static : performance detrimental */
|
||||||
return one.c[0];
|
return one.c[0];
|
||||||
@ -246,6 +250,8 @@ MEM_STATIC U32 MEM_swap32(U32 in)
|
|||||||
#elif (defined (__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ >= 403)) \
|
#elif (defined (__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ >= 403)) \
|
||||||
|| (defined(__clang__) && __has_builtin(__builtin_bswap32))
|
|| (defined(__clang__) && __has_builtin(__builtin_bswap32))
|
||||||
return __builtin_bswap32(in);
|
return __builtin_bswap32(in);
|
||||||
|
#elif defined(__ICCARM__)
|
||||||
|
return __REV(in);
|
||||||
#else
|
#else
|
||||||
return MEM_swap32_fallback(in);
|
return MEM_swap32_fallback(in);
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -57,7 +57,7 @@ extern "C" {
|
|||||||
#else
|
#else
|
||||||
# if defined (__cplusplus) && (__cplusplus >= 201402) /* C++14 or greater */
|
# if defined (__cplusplus) && (__cplusplus >= 201402) /* C++14 or greater */
|
||||||
# define ZSTD_DEPRECATED(message) [[deprecated(message)]]
|
# define ZSTD_DEPRECATED(message) [[deprecated(message)]]
|
||||||
# elif (defined(GNUC) && (GNUC > 4 || (GNUC == 4 && GNUC_MINOR >= 5))) || defined(__clang__)
|
# elif (defined(GNUC) && (GNUC > 4 || (GNUC == 4 && GNUC_MINOR >= 5))) || defined(__clang__) || defined(__IAR_SYSTEMS_ICC__)
|
||||||
# define ZSTD_DEPRECATED(message) __attribute__((deprecated(message)))
|
# define ZSTD_DEPRECATED(message) __attribute__((deprecated(message)))
|
||||||
# elif defined(__GNUC__) && (__GNUC__ >= 3)
|
# elif defined(__GNUC__) && (__GNUC__ >= 3)
|
||||||
# define ZSTD_DEPRECATED(message) __attribute__((deprecated))
|
# define ZSTD_DEPRECATED(message) __attribute__((deprecated))
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user