📄 intrindefs.h
字号:
/****************************************************************************//* intrindefs.h v3.83 *//* Copyright (c) 1997-2002 Texas Instruments Incorporated *//****************************************************************************/#ifndef _INTRINDEF#define _INTRINDEF#include <linkage.h>#define MAX_16 0x7fff#define MIN_16 -32768#define MAX_32 0x7fffffff#define MIN_32 0x80000000/*--------------------------------------------------------------------------*//* External variables used by ETSI basicop functions *//*--------------------------------------------------------------------------*/extern int Overflow;extern int Carry;/*--------------------------------------------------------------------------*//* Mappings for ETSI functions to built-in compiler intrinsics *//*--------------------------------------------------------------------------*/#define L_add(a,b) (_lsadd((a),(b)))#define L_sub(a,b) (_lssub((a),(b)))#define L_negate(a) (_lsneg(a)) #define L_deposit_h(a) ((long)a<<16) #define L_deposit_l(a) (a) #define L_abs(a) (_labss((a))) #define L_mult(a,b) (_lsmpy((a),(b)))#define L_mac(a,b,c) (_smac((a),(b),(c)))#define L_macNs(a,b,c) (L_add_c((a),L_mult((b),(c))))#define L_msu(a,b,c) (_smas((a),(b),(c))) #define L_msuNs(a,b,c) (L_sub_c((a),L_mult((b),(c))))#define L_shl(a,b) ((b) < 0 ? L_crshft((a),(-b)) : \ (b) < 9 ? _lsshl((a),(b)) : \ L_clshft((a),(b)))#define L_shr(a,b) (L_crshft((a),(b)))#define L_shr_r(a,b) (L_crshft_r((a),(b)))#define abs_s(a) (_abss((a))) #define add(a,b) (_sadd((a),(b))) #define sub(a,b) (_ssub((a),(b))) #define extract_h(a) ((unsigned)((a)>>16)) #define extract_l(a) ((int)a) #define round(a) (_rnd(a)) #define mac_r(a,b,c) (_smacr((a),(b),(c))) #define msu_r(a,b,c) (_smasr((a),(b),(c))) #define mult_r(a,b) (_smpyr((a),(b))) #define mult(a,b) (_smpy((a),(b)))#define norm_l(a) (_lnorm(a)) #define norm_s(a) (_norm(a)) #define negate(a) (_sneg(a)) #define shl(a,b) (clshft((a),(b)))#define shr(a,b) (crshft((a),(b)))#define shr_r(a,b) (crshft_r((a),(b)))#define div_s(a,b) (divs(a,b))/*--------------------------------------------------------------------------*//* Declarations for ETSI functions implemented as function calls (or *//* inline functions) *//*--------------------------------------------------------------------------*/#ifdef __cplusplusextern "C"{#endif /* __cplusplus */int clshft (int x, int y);int crshft (long x, int y);int crshft_r (int x, int y);long L_clshft (long x, int y);long L_crshft (long x, int y);long L_crshft_r (long x, int y);int divs (int x, int y);_IDECL long L_add_c(long, long);_IDECL long L_sub_c(long, long);_IDECL long L_sat(long); /*--------------------------------------------------------------------------*//* Definitions of ETSI functions implemented as inline functions. *//*--------------------------------------------------------------------------*/#ifdef _INLINE/****************************************************************************//* Integer (32-bit) add with carry and overflow testing. *//****************************************************************************/static inline long L_add_c (long L_var1, long L_var2){ unsigned long uv1 = L_var1; unsigned long uv2 = L_var2; int cin = Carry; unsigned long result = uv1 + uv2 + cin; Carry = ((~result & (uv1 | uv2)) | (uv1 & uv2)) >> 31; Overflow = ((~(uv1 ^ uv2)) & (uv1 ^ result)) >> 31; if (cin && result == 0x80000000) Overflow = 1; return (long)result;} /****************************************************************************//* Integer (32-bit) subtract with carry and overflow testing. *//****************************************************************************/static inline long L_sub_c (long L_var1, long L_var2){ unsigned long uv1 = L_var1; unsigned long uv2 = L_var2; int cin = Carry; unsigned long result = uv1 + ~uv2 + cin; Carry = ((~result & (uv1 | ~uv2)) | (uv1 & ~uv2)) >> 31; Overflow = ((uv1 ^ uv2) & (uv1 ^ result)) >> 31; if (!cin && result == 0x7fffffff) Overflow = 1; return (long)result;}/****************************************************************************//* Saturate any result after L_addc or L_sub_c if overflow is set. *//****************************************************************************/static inline long L_sat (long L_var1){ int cin = Carry; return !Overflow ? L_var1 : (Carry = Overflow = 0, 0x7fffffff+cin);}#endif /* !_INLINE */#ifdef __cplusplus} /* extern "C" */#endif /* __cplusplus */#endif /* !_INTRINDEF */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -