diff --git a/src/kernel/arch/riscv64/include/cpu/regs.hpp b/src/kernel/arch/riscv64/include/cpu/regs.hpp index 9423ebf5..fe29ec56 100644 --- a/src/kernel/arch/riscv64/include/cpu/regs.hpp +++ b/src/kernel/arch/riscv64/include/cpu/regs.hpp @@ -1234,10 +1234,10 @@ class ReadWriteField : public ReadOnlyField, * @param value 新值 */ static __always_inline void Write(RegInfo::DataType value) { - uint64_t org_value = Reg::Read(); - uint64_t new_value = - (org_value & ~RegInfo::kBitMask) | - (((uint64_t)value << RegInfo::kBitOffset) & RegInfo::kBitMask); + auto org_value = Reg::Read(); + auto new_value = (org_value & ~RegInfo::kBitMask) | + (((decltype(org_value))value << RegInfo::kBitOffset) & + RegInfo::kBitMask); Reg::Write(new_value); } @@ -1247,10 +1247,10 @@ class ReadWriteField : public ReadOnlyField, * @return RegInfo::DataType 由寄存器规定的数据类型 */ static __always_inline RegInfo::DataType ReadWrite(RegInfo::DataType value) { - uint64_t org_value = Reg::Read(); - uint64_t new_value = - (org_value & ~RegInfo::kBitMask) | - (((uint64_t)value << RegInfo::kBitOffset) & RegInfo::kBitMask); + auto org_value = Reg::Read(); + auto new_value = (org_value & ~RegInfo::kBitMask) | + (((decltype(org_value))value << RegInfo::kBitOffset) & + RegInfo::kBitMask); Reg::Write(new_value); return (RegInfo::DataType)((org_value & RegInfo::kBitMask) >> RegInfo::kBitOffset);