[libc-commits] [libc] [libc] {u}lkbits broken on riscv32 (PR #115799)

William Tran-Viet via libc-commits libc-commits at lists.llvm.org
Mon Nov 11 17:42:31 PST 2024


https://github.com/smallp-o-p created https://github.com/llvm/llvm-project/pull/115799

- Re-enabled ulkbits and lkbits for Risc-V
- Bumped `int_lk_t` to a `signed long long` and a `uint_ulk_t` to an `unsigned long long` to guarantee they both fit in 8 bytes, which `long _Accum` and `unsigned long _Accum` are defaulted to on 32bit architectures.

This is probably inconvenient on systems that have a word size larger than 64 bits?

>From 83a625cfda37a978c221b15db34d6442f8048546 Mon Sep 17 00:00:00 2001
From: William Tran-Viet <wtranviet at proton.me>
Date: Mon, 11 Nov 2024 20:22:34 -0500
Subject: [PATCH] Bump int_lk_t and uint_ulk_t to long long to fix an issue on
 32bit systems where long is 32 bits while long _Accum is 64 bits

---
 libc/config/linux/riscv/entrypoints.txt     | 4 ++--
 libc/include/llvm-libc-types/stdfix-types.h | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/libc/config/linux/riscv/entrypoints.txt b/libc/config/linux/riscv/entrypoints.txt
index 3758f0809960e5..5419462d4f5b3b 100644
--- a/libc/config/linux/riscv/entrypoints.txt
+++ b/libc/config/linux/riscv/entrypoints.txt
@@ -728,8 +728,8 @@ if(LIBC_COMPILER_HAS_FIXED_POINT)
     libc.src.stdfix.kbits
     libc.src.stdfix.ukbits
     # TODO: https://github.com/llvm/llvm-project/issues/115778
-    # libc.src.stdfix.lkbits
-    # libc.src.stdfix.ulkbits
+    libc.src.stdfix.lkbits
+    libc.src.stdfix.ulkbits
   )
 endif()
 
diff --git a/libc/include/llvm-libc-types/stdfix-types.h b/libc/include/llvm-libc-types/stdfix-types.h
index 759e59251a5e87..542d45ea97e96f 100644
--- a/libc/include/llvm-libc-types/stdfix-types.h
+++ b/libc/include/llvm-libc-types/stdfix-types.h
@@ -14,12 +14,12 @@ typedef signed short int int_r_t;
 typedef signed int int_lr_t;
 typedef signed short int_hk_t;
 typedef signed int int_k_t;
-typedef signed long int_lk_t;
+typedef signed long long int_lk_t;
 typedef unsigned char uint_uhr_t;
 typedef unsigned short int uint_ur_t;
 typedef unsigned int uint_ulr_t;
 typedef unsigned short int uint_uhk_t;
 typedef unsigned int uint_uk_t;
-typedef unsigned long uint_ulk_t;
+typedef unsigned long long uint_ulk_t;
 
 #endif // LLVM_LIBC_TYPES_STDFIX_TYPES_H



More information about the libc-commits mailing list