diff options
author | Gil Pitney <gil.pitney@linaro.org> | 2015-05-29 21:24:31 +0000 |
---|---|---|
committer | Gil Pitney <gil.pitney@linaro.org> | 2015-05-29 21:24:31 +0000 |
commit | aec5b6f387c8cb206ad4d19255a13a7242149ef6 (patch) | |
tree | 5e2490a66194ef9b11a05a03b0b1640b3c59ab0c | |
parent | fbf7f378ca49bbad15148ffcb893aa3ce49c11f9 (diff) |
Fix abs() builtin function for CPU.
Take cue from dsp.h, which has the abs() function working.
Signed-off-by: Gil Pitney <gil.pitney@linaro.org>
-rw-r--r-- | include/cpu.h | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/include/cpu.h b/include/cpu.h index 0f74f1f..2bfc289 100644 --- a/include/cpu.h +++ b/include/cpu.h @@ -148,14 +148,15 @@ UNARY_VEC_DECL(uint, uint, popcount) UNARY_VEC_DECL(long, long, popcount) UNARY_VEC_DECL(ulong, ulong, popcount) -_CLC_OVERLOAD _CLC_DECL uchar abs(char x) ; -_CLC_OVERLOAD _CLC_DECL ushort abs(short x) ; -_CLC_OVERLOAD _CLC_DECL uint abs(int x) ; -_CLC_OVERLOAD _CLC_DECL ulong abs(long x) ; -_CLC_OVERLOAD _CLC_DECL uchar abs(uchar x) ; -_CLC_OVERLOAD _CLC_DECL ushort abs(ushort x) ; -_CLC_OVERLOAD _CLC_DECL uint abs(uint x) ; -_CLC_OVERLOAD _CLC_DECL ulong abs(ulong x) ; +_CLC_OVERLOAD _CLC_INLINE uchar abs(char x) { return __builtin_abs(x); } +_CLC_OVERLOAD _CLC_INLINE ushort abs(short x) { return __builtin_abs(x); } +_CLC_OVERLOAD _CLC_INLINE uint abs(int x) { return __builtin_abs(x); } +_CLC_OVERLOAD _CLC_INLINE ulong abs(long x) { if (x < 0) x = -x; return x; } + +_CLC_OVERLOAD _CLC_INLINE uchar abs(uchar x) { return x; } +_CLC_OVERLOAD _CLC_INLINE ushort abs(ushort x) { return x; } +_CLC_OVERLOAD _CLC_INLINE uint abs(uint x) { return x; } +_CLC_OVERLOAD _CLC_INLINE ulong abs(ulong x) { return x; } UNARY_VEC_DECL(char, uchar, abs) UNARY_VEC_DECL(short, ushort, abs) |