1/****************************************************************************** 2 * 3 * Copyright (C) 2015 The Android Open Source Project 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at: 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 * 17 ***************************************************************************** 18 * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore 19*/ 20/** 21******************************************************************************* 22* @file 23* icv_platform_macros.h 24* 25* @brief 26* This header files contains all the platform/toolchain specific macros 27* 28* @author 29* Ittiam 30* 31* @par List of Functions: 32* 33* @remarks 34* None 35* 36******************************************************************************* 37*/ 38#ifndef __ICV_PLATFORM_MACROS_H__ 39#define __ICV_PLATFORM_MACROS_H__ 40 41#define INLINE inline 42 43static INLINE UWORD32 CLZ(UWORD32 u4_word) 44{ 45 if(u4_word) 46 return (__builtin_clz(u4_word)); 47 else 48 return 32; 49} 50 51static __inline UWORD32 CLZNZ(UWORD32 u4_word) 52{ 53 ASSERT(u4_word); 54 return (__builtin_clz(u4_word)); 55} 56 57#define CLIP_U8(x) ((x) > 255) ? (255) : (((x) < 0) ? (0) : (x)) 58#define CLIP_S8(x) ((x) > 127) ? (127) : (((x) < -128) ? (-128) : (x)) 59 60#define CLIP_U12(x) ((x) > 4095) ? (4095) : (((x) < 0) ? (0) : (x)) 61#define CLIP_S12(x) ((x) > 2047) ? (2047) : (((x) < -2048) ? (-2048) : (x)) 62 63#define CLIP_U16(x) ((x) > 65535) ? (65535) : (((x) < 0) ? (0) : (x)) 64#define CLIP_S16(x) ((x) > 32767) ? (32767) : (((x) < -32768) ? (-32768) : (x)) 65 66#define ITT_BIG_ENDIAN(x) __asm__("rev %0, %1" : "=r"(x) : "r"(x)); 67 68#define NOP(nop_cnt) \ 69{ \ 70 UWORD32 nop_i; \ 71 for (nop_i = 0; nop_i < nop_cnt; nop_i++) \ 72 __asm__ __volatile__("mov x0, x0"); \ 73} 74 75 76#define PREFETCH(x) __builtin_prefetch(x); 77 78#define DATA_SYNC() __sync_synchronize() 79 80#define SHL(x,y) (((y) < 32) ? ((x) << (y)) : 0) 81#define SHR(x,y) (((y) < 32) ? ((x) >> (y)) : 0) 82 83#define SHR_NEG(val,shift) (((shift) > 0) ? ( (val) >> (shift)) : ((val) << (-(shift)))) 84#define SHL_NEG(val,shift) (((shift) > 0) ? ( (val) >> (-(shift))) : ((val) << (shift))) 85 86#define INLINE inline 87 88#define MEM_ALIGN8 __attribute__ ((aligned (8))) 89#define MEM_ALIGN16 __attribute__ ((aligned (16))) 90#define MEM_ALIGN32 __attribute__ ((aligned (32))) 91 92 93#endif /* __ICV_PLATFORM_MACROS_H__ */ 94