[libc-commits] [PATCH] D157792: [libc] Fix compilation on 32-bit systems

Mikhail Ramalho via Phabricator via libc-commits libc-commits at lists.llvm.org
Tue Aug 15 14:36:43 PDT 2023


mikhail.ramalho updated this revision to Diff 550482.
mikhail.ramalho added a comment.

- added LSEEK_SYSCALL_NO
- added cast to uint64_t back


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D157792/new/

https://reviews.llvm.org/D157792

Files:
  libc/src/unistd/linux/lseek.cpp


Index: libc/src/unistd/linux/lseek.cpp
===================================================================
--- libc/src/unistd/linux/lseek.cpp
+++ libc/src/unistd/linux/lseek.cpp
@@ -23,14 +23,15 @@
 #ifdef SYS_lseek
   int ret = __llvm_libc::syscall_impl<int>(SYS_lseek, fd, offset, whence);
   result = ret;
-#elif defined(SYS_llseek)
-  long ret = __llvm_libc::syscall_impl(SYS_llseek, fd,
-                                       (long)(((uint64_t)(offset)) >> 32),
-                                       (long)offset, &result, whence);
-  result = ret;
+#elif defined(SYS_llseek) || defined(SYS__llseek)
+#ifdef SYS_llseek
+  constexpr long LLSEEK_SYSCALL_NO = SYS_llseek;
 #elif defined(SYS__llseek)
-  int ret = __llvm_libc::syscall_impl<int>(SYS__llseek, fd, offset >> 32,
-                                           offset, &result, whence);
+  constexpr long LLSEEK_SYSCALL_NO = SYS__llseek;
+#endif
+  uint64_t offset_64 = static_cast<uint64_t>(offset);
+  int ret = __llvm_libc::syscall_impl<int>(
+      LLSEEK_SYSCALL_NO, fd, offset_64 >> 32, offset_64, &result, whence);
 #else
 #error "lseek, llseek and _llseek syscalls not available."
 #endif


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D157792.550482.patch
Type: text/x-patch
Size: 1161 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libc-commits/attachments/20230815/c6a68ef7/attachment.bin>


More information about the libc-commits mailing list