Skip to content

Commit

Permalink
Add cmake check for ioclt prototype (#82173)
Browse files Browse the repository at this point in the history
* Add cmake check for ioclt prototype

* .
  • Loading branch information
am11 authored Feb 16, 2023
1 parent 82c8918 commit 4e0ff82
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/native/libs/Common/pal_config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
#cmakedefine01 PRIORITY_REQUIRES_INT_WHO
#cmakedefine01 KEVENT_REQUIRES_INT_PARAMS
#cmakedefine01 HAVE_IOCTL
#cmakedefine01 HAVE_IOCTL_WITH_INT_REQUEST
#cmakedefine01 HAVE_TIOCGWINSZ
#cmakedefine01 HAVE_TIOCSWINSZ
#cmakedefine01 HAVE_SCHED_GETAFFINITY
Expand Down
4 changes: 4 additions & 0 deletions src/native/libs/System.Native/pal_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -1325,7 +1325,11 @@ int32_t SystemNative_CopyFile(intptr_t sourceFd, intptr_t destinationFd, int64_t
// Try copying data using a copy-on-write clone. This shares storage between the files.
if (sourceLength != 0)
{
#if HAVE_IOCTL_WITH_INT_REQUEST
while ((ret = ioctl(outFd, (int)FICLONE, inFd)) < 0 && errno == EINTR);
#else
while ((ret = ioctl(outFd, FICLONE, inFd)) < 0 && errno == EINTR);
#endif
copied = ret == 0;
}
#endif
Expand Down
7 changes: 7 additions & 0 deletions src/native/libs/configure.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -790,6 +790,13 @@ check_prototype_definition(
${STATFS_INCLUDES}
HAVE_NON_LEGACY_STATFS)

check_prototype_definition(
ioctl
"int ioctl(int fd, int request, ...)"
0
"sys/ioctl.h"
HAVE_IOCTL_WITH_INT_REQUEST)

check_c_source_compiles(
"
#include <stdlib.h>
Expand Down

0 comments on commit 4e0ff82

Please sign in to comment.