new: 增加一些编译器相关的宏

This commit is contained in:
fslongjin
2022-10-05 21:40:03 +08:00
parent 7087e9fbc1
commit 9b37ff3e5a
7 changed files with 94 additions and 16 deletions

View File

@ -18,6 +18,21 @@
#define io_lfence() __asm__ __volatile__("lfence\n\t" :: \
: "memory") // 在lfence指令前的读操作必须在lfence指令后的读操作前完成。
/*
* Macros to generate condition code outputs from inline assembly,
* The output operand must be type "bool".
*/
// 如果编译器支持输出标志寄存器值到变量的话则会定义__GCC_ASM_FLAG_OUTPUTS__
#ifdef __GCC_ASM_FLAG_OUTPUTS__
// CC_SET(c)则是用于设置标志寄存器中的某一位
#define CC_SET(c) "\n\t/* output condition code " #c "*/\n"
// "=@cccond"的用法是将标志寄存器中的cond也就是指令集定义的标准条件的值输出到变量中
#define CC_OUT(c) "=@cc" #c
#else
#define CC_SET(c) "\n\tset" #c " %[_cc_" #c "]\n"
#define CC_OUT(c) [_cc_##c] "=qm"
#endif
#define rdtsc() ({ \
uint64_t tmp1 = 0, tmp2 = 0; \
asm volatile("rdtsc" \