This is an archive of the discontinued LLVM Phabricator instance.

[libc] Fix compilation on 32-bit systems
ClosedPublic

Authored by mikhail.ramalho on Aug 12 2023, 11:09 AM.

Details

Summary

This fixes the following compilation error: no known conversion from 'off_t *'
(aka 'long long *') to 'long' for 5th argument.

Since pointers are 32-bit long anyway, casting it to long shouldn't be a
problem. Tested on rv32.

Diff Detail

Event Timeline

Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptAug 12 2023, 11:09 AM
mikhail.ramalho requested review of this revision.Aug 12 2023, 11:09 AM

Change is fine, but in general C++ style casts are preferred over C style casts.

  • Removed old SYS_llseek and reuse SYS__llseek
  • Rebased
sivachandra added inline comments.Aug 15 2023, 1:57 PM
libc/src/unistd/linux/lseek.cpp
29–30

May be you should keep the cast to uint64_t here because off_t is a signed type?

31

At this point, the best would probably be:

#ifdef SYS_llseek
constexpr long LLSEEK_SYSCALL_NO = SYS_llseek;
#elif defined(SYS__llseek)
constexpr long LSEEK_SYSCALL_NO = SYS__llseek;
#else
#error ...
#endif
int ret = __llvm_libc::syscall_impl<int>(LLSEEK_SYSCALL_NO, fd, offset >> 32,
                                         offset, &result, whence);
  • added LSEEK_SYSCALL_NO
  • added cast to uint64_t back
sivachandra accepted this revision.Aug 15 2023, 2:51 PM
This revision is now accepted and ready to land.Aug 15 2023, 2:51 PM