c_op.h 918 字节
Newer Older
1 2
#ifndef __RTL_C_OP_H__
#define __RTL_C_OP_H__
Z
Zihao Yu 已提交
3 4 5 6 7 8 9 10

#define c_add(a, b) ((a) + (b))
#define c_sub(a, b) ((a) - (b))
#define c_and(a, b) ((a) & (b))
#define c_or(a, b)  ((a) | (b))
#define c_xor(a, b) ((a) ^ (b))
#define c_shl(a, b) ((a) << (b))
#define c_shr(a, b) ((a) >> (b))
11 12
#define c_sar(a, b) ((sword_t)(a) >> (b))

Z
Zihao Yu 已提交
13
#define c_mul_lo(a, b) ((a) * (b))
14 15 16 17 18 19 20 21 22
#define c_imul_lo(a, b) ((sword_t)(a) * (sword_t)(b))
#ifdef ISA64
# define c_mul_hi(a, b) (((__uint128_t)(a) * (__uint128_t)(b)) >> 64)
# define c_imul_hi(a, b) (((__int128_t)(sword_t)(a) * (__int128_t)(sword_t)(b)) >> 64)
#else
# define c_mul_hi(a, b) (((uint64_t)(a) * (uint64_t)(b)) >> 32)
# define c_imul_hi(a, b) (((int64_t)(sword_t)(a) * (int64_t)(sword_t)(b)) >> 32)
#endif

Z
Zihao Yu 已提交
23 24
#define c_div_q(a, b) ((a) / (b))
#define c_div_r(a, b)  ((a) % (b))
25 26
#define c_idiv_q(a, b) ((sword_t)(a) / (sword_t)(b))
#define c_idiv_r(a, b)  ((sword_t)(a) % (sword_t)(b))
Z
Zihao Yu 已提交
27 28

#endif