Add cmake check for ioclt prototype (#82173)
authorAdeel Mujahid <3840695+am11@users.noreply.github.com>
Thu, 16 Feb 2023 18:21:36 +0000 (20:21 +0200)
committerGitHub <noreply@github.com>
Thu, 16 Feb 2023 18:21:36 +0000 (19:21 +0100)
* Add cmake check for ioclt prototype

* .

src/native/libs/Common/pal_config.h.in
src/native/libs/System.Native/pal_io.c
src/native/libs/configure.cmake

index 7b592d1..a5ce0ce 100644 (file)
@@ -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
index 22fcf3a..7551b42 100644 (file)
@@ -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
index 0b86bd6..cbaac69 100644 (file)
@@ -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>