Skip to content

[libc] Change fcntl cmd when only fcntl64 is available #99675

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 23 additions & 9 deletions libc/src/__support/OSUtil/linux/fcntl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,17 +86,31 @@ int fcntl(int fd, int cmd, void *arg) {
libc_errno = -ret;
return -1;
}
// The general case
default: {
int retVal = LIBC_NAMESPACE::syscall_impl<int>(
FCNTL_SYSCALL_ID, fd, cmd, reinterpret_cast<void *>(arg));
if (retVal >= 0) {
return retVal;
}
libc_errno = -retVal;
return -1;
#ifdef SYS_fcntl64
case F_GETLK: {
if constexpr (FCNTL_SYSCALL_ID == SYS_fcntl64)
return fcntl(fd, F_GETLK64, arg);
break;
}
case F_SETLK: {
if constexpr (FCNTL_SYSCALL_ID == SYS_fcntl64)
return fcntl(fd, F_SETLK64, arg);
break;
}
case F_SETLKW: {
if constexpr (FCNTL_SYSCALL_ID == SYS_fcntl64)
return fcntl(fd, F_SETLKW64, arg);
break;
}
#endif
}
int retVal = LIBC_NAMESPACE::syscall_impl<int>(FCNTL_SYSCALL_ID, fd, cmd,
reinterpret_cast<void *>(arg));
if (retVal >= 0) {
return retVal;
}
libc_errno = -retVal;
return -1;
}

} // namespace internal
Expand Down
Loading