Skip to content

Commit af38cfa

Browse files
committed
RISCV: relax some static_assert to DS2ASSERT
This relaxes the assertions to runtime as `std::log2` is not required to be marked as `constexpr`. This will result in an inability to build in such a case. This loosens the requirement on the c++ runtime.
1 parent 115fc18 commit af38cfa

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Sources/Target/Linux/RISCV/ProcessRISCV.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ inline void mmap(size_t size, int protection, ByteVector &code) {
2727
DS2BUG("do not know how to mmap on this bitness")
2828
#elif __riscv_xlen == 64
2929
static_assert(sizeof(size) == 8, "size_t should be 8-bytes on RISCV64");
30-
static_assert(std::log2(MAP_ANON | MAP_PRIVATE) <= 20, "20-bit immediate");
31-
static_assert(std::log2(__NR_mmap) <= 20, "20-bit immediate");
30+
DS2ASSERT(std::log2(MAP_ANON | MAP_PRIVATE) <= 20);
31+
DS2ASSERT(std::log2(__NR_mmap) <= 20);
3232
DS2ASSERT(std::log2(protection) <= 20);
3333

3434
for (uint32_t instruction: {
@@ -57,7 +57,7 @@ inline void munmap(uintptr_t address, size_t size, ByteVector &code) {
5757
DS2BUG("do not know how to munmap on this bitness")
5858
#elif __riscv_xlen == 64
5959
static_assert(sizeof(size) == 8, "size_t should be 8-bytes on RISCV64");
60-
static_assert(std::log2(__NR_munmap) <= 20, "20-bit immediate");
60+
DS2ASSERT(std::log2(__NR_munmap) <= 20);
6161

6262
for (uint32_t instruction: {
6363
static_cast<uint32_t>(0x00000517), // ld a0, .Laddress

0 commit comments

Comments
 (0)