8 Star 10 Fork 17

SpacemiT Buildroot SDK/linux-6.6

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
rwonce.h 1.02 KB
一键复制 编辑 原始数据 按行查看 历史
James Deng 提交于 2024-12-11 19:19 +08:00 . Update for v2.0.4
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (C) 2024 Spaciemit Ltd.
*/
#ifndef __ASM_RWONCE_H
#define __ASM_RWONCE_H
#if defined(CONFIG_SPACEMIT_ERRATA_LOAD_ATOMIC) && !defined(__ASSEMBLY__)
#define __READ_ONCE(x) \
({ \
typeof(&(x)) __x = &(x); \
int atomic = 1; \
union { __unqual_scalar_typeof(*__x) __val; char __c[1]; } __u; \
switch (sizeof(x)) { \
case 4: \
asm volatile ( \
"lr.w %0, 0(%1)" \
: "=r" (*(__u32 *)__u.__c) \
: "r" (__x) \
: "memory" \
); \
break; \
case 8: \
asm volatile ( \
"lr.d %0, 0(%1)" \
: "=r" (*(__u64 *)__u.__c) \
: "r" (__x) \
: "memory" \
); \
break; \
default: \
asm volatile ("fence rw, rw" ::: "memory"); \
atomic = 0; \
} \
atomic ? (typeof(*__x))__u.__val : (*(volatile typeof(__x))__x);\
})
#endif /* CONFIG_SPACEMIT_ERRATA_LOAD_ATOMIC && !__ASSEMBLY__ */
#include <asm-generic/rwonce.h>
#endif /* __ASM_RWONCE_H */
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/spacemit-buildroot/linux-6.6.git
git@gitee.com:spacemit-buildroot/linux-6.6.git
spacemit-buildroot
linux-6.6
linux-6.6
345615c3bcc8859838f7537f84cfade2f79b7717

搜索帮助