Skip to content

Commit 5c3fc50

Browse files
committed
[libunwind] [risc-v] This patch is for fixing
immediate build failure when Cross Unwinding enabled. Follow up patch will cleanup some Macros handling. Differential Revision: https://reviews.llvm.org/D97762
1 parent b6c2f53 commit 5c3fc50

File tree

1 file changed

+20
-11
lines changed

1 file changed

+20
-11
lines changed

libunwind/src/Registers.hpp

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3731,26 +3731,35 @@ inline const char *Registers_hexagon::getRegisterName(int regNum) {
37313731
/// Registers_riscv holds the register state of a thread in a RISC-V
37323732
/// process.
37333733

3734-
# if __riscv_xlen == 32
3734+
// This check makes it safe when LIBUNWIND_ENABLE_CROSS_UNWINDING enabled.
3735+
# ifdef __riscv
3736+
# if __riscv_xlen == 32
37353737
typedef uint32_t reg_t;
3736-
# elif __riscv_xlen == 64
3738+
# elif __riscv_xlen == 64
37373739
typedef uint64_t reg_t;
3738-
# else
3739-
# error "Unsupported __riscv_xlen"
3740-
# endif
3740+
# else
3741+
# error "Unsupported __riscv_xlen"
3742+
# endif
37413743

3742-
# if defined(__riscv_flen)
3743-
# if __riscv_flen == 64
3744+
# if defined(__riscv_flen)
3745+
# if __riscv_flen == 64
37443746
typedef double fp_t;
3745-
# elif __riscv_flen == 32
3747+
# elif __riscv_flen == 32
37463748
typedef float fp_t;
3749+
# else
3750+
# error "Unsupported __riscv_flen"
3751+
# endif
37473752
# else
3748-
# error "Unsupported __riscv_flen"
3753+
// This is just for supressing undeclared error of fp_t.
3754+
typedef double fp_t;
37493755
# endif
37503756
# else
3751-
// This is just for supressing undeclared error of fp_t.
3757+
// Use Max possible width when cross unwinding
3758+
typedef uint64_t reg_t;
37523759
typedef double fp_t;
3753-
# endif
3760+
# define __riscv_xlen 64
3761+
# define __riscv_flen 64
3762+
#endif
37543763

37553764
/// Registers_riscv holds the register state of a thread.
37563765
class _LIBUNWIND_HIDDEN Registers_riscv {

0 commit comments

Comments
 (0)