mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-01 23:18:20 +02:00
util: os_same_file_description: fix unknown linux < 3.5 syscall SYS_kcmp
https://man7.org/linux/man-pages/man2/kcmp.2.html The kcmp() system call first appeared in Linux 3.5. But was probably also not supported by all major platforms at that time. So fallback to the check that is done for windows. Signed-off-by: Thomas Devoogdt <thomas.devoogdt@barco.com> Acked-by: Yonggang Luo <luoyonggang@gmail.com> Acked-by: Michel Dänzer <mdaenzer@redhat.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18517>
This commit is contained in:
parent
8fa16452ba
commit
3ef5149824
1 changed files with 6 additions and 12 deletions
|
|
@ -202,29 +202,23 @@ os_read_file(const char *filename, size_t *size)
|
|||
/* copied from <linux/kcmp.h> */
|
||||
#define KCMP_FILE 0
|
||||
|
||||
#endif
|
||||
|
||||
int
|
||||
os_same_file_description(int fd1, int fd2)
|
||||
{
|
||||
#ifdef SYS_kcmp
|
||||
pid_t pid = getpid();
|
||||
#endif
|
||||
|
||||
/* Same file descriptor trivially implies same file description */
|
||||
if (fd1 == fd2)
|
||||
return 0;
|
||||
|
||||
#ifdef SYS_kcmp
|
||||
return syscall(SYS_kcmp, pid, pid, KCMP_FILE, fd1, fd2);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
int
|
||||
os_same_file_description(int fd1, int fd2)
|
||||
{
|
||||
/* Same file descriptor trivially implies same file description */
|
||||
if (fd1 == fd2)
|
||||
return 0;
|
||||
|
||||
/* Otherwise we can't tell */
|
||||
return -1;
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue