实际上 atomic_t 和 atomic64_t 这两个类型 是linux 头文件("kernel/include/linux/types.h")里定义。
typedef unsigned long irq_hw_number_t;
typedef struct {
int counter;
} atomic_t;
#ifdef CONFIG_64BIT
typedef struct {
long counter;
} atomic64_t;
#endif
"kernel/include/linux/types.h"
它是一个结构体,所以不能直接在printf中转换为 unsigned int 等类型直接打印出来。编译器会报语法错误。
kernel/include/asm-generic/atomic-long.h:
typedef atomic_t atomic_long_t;
atomic_long_t 实际上就是 atomic_t 类型。
这篇博客介绍了Linux内核中用于原子操作的atomic_t、atomic64_t和atomic_long_t类型。atomic_t是一个包含整数counter的结构体,而atomic64_t在64位系统中定义,用于长整型计数。atomic_long_t实际上等同于atomic_t。这些类型不支持直接转换为常规类型进行打印,避免了编译错误。
554

被折叠的 条评论
为什么被折叠?



