summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--storage/innobase/CMakeLists.txt27
-rw-r--r--storage/innobase/handler/ha_innodb.cc2
-rw-r--r--storage/xtradb/CMakeLists.txt27
-rw-r--r--storage/xtradb/handler/ha_innodb.cc2
4 files changed, 56 insertions, 2 deletions
diff --git a/storage/innobase/CMakeLists.txt b/storage/innobase/CMakeLists.txt
index 2a45f05c463..7470f2985c0 100644
--- a/storage/innobase/CMakeLists.txt
+++ b/storage/innobase/CMakeLists.txt
@@ -246,6 +246,33 @@ IF(HAVE_IB_ATOMIC_PTHREAD_T_GCC)
ADD_DEFINITIONS(-DHAVE_IB_ATOMIC_PTHREAD_T_GCC=1)
ENDIF()
+CHECK_C_SOURCE(
+"
+#include <unistd.h>
+#include <fcntl.h>
+#include <stdlib.h>
+int main() {
+ char filename[] = "/tmp/mytemp.XXXXXX";
+ int fd = mkstemp(filename);
+ if (fd != -1) {
+ int fd2=fcntl(fd, F_DUPFD_CLOEXEC, 0);
+ if (fd2 != -1) {
+ close(fd2);
+ close(fd);
+ unlink(filename);
+ return (0);
+ }
+ close (fd);
+ unlink(filename);
+ }
+ return (1);
+}"
+HAVE_IB_F_DUPFD_CLOEXEC)
+
+IF (HAVE_IB_F_DUPFD_CLOEXEC)
+ ADD_DEFINITIONS(-DHAVE_IB_F_DUPFD_CLOEXEC=1)
+ENDIF()
+
CHECK_C_SOURCE_COMPILES("struct t1{ int a; char *b; }; struct t1 c= { .a=1, .b=0 }; main() { }" HAVE_C99_INITIALIZERS)
ENDIF(NOT MSVC)
diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc
index 5667efea5df..6843d90b0a9 100644
--- a/storage/innobase/handler/ha_innodb.cc
+++ b/storage/innobase/handler/ha_innodb.cc
@@ -2414,7 +2414,7 @@ innobase_mysql_tmpfile(
}
}
#else
-#ifdef F_DUPFD_CLOEXEC
+#if defined(F_DUPFD_CLOEXEC) && defined(HAVE_IB_F_DUPFD_CLOEXEC)
fd2 = fcntl(fd, F_DUPFD_CLOEXEC, 0);
#else
fd2 = dup(fd);
diff --git a/storage/xtradb/CMakeLists.txt b/storage/xtradb/CMakeLists.txt
index f5ec6fd746d..5ec5881a247 100644
--- a/storage/xtradb/CMakeLists.txt
+++ b/storage/xtradb/CMakeLists.txt
@@ -255,6 +255,33 @@ IF(HAVE_IB_ATOMIC_PTHREAD_T_GCC)
ADD_DEFINITIONS(-DHAVE_IB_ATOMIC_PTHREAD_T_GCC=1)
ENDIF()
+CHECK_C_SOURCE(
+"
+#include <unistd.h>
+#include <fcntl.h>
+#include <stdlib.h>
+int main() {
+ char filename[] = "/tmp/mytemp.XXXXXX";
+ int fd = mkstemp(filename);
+ if (fd != -1) {
+ int fd2=fcntl(fd, F_DUPFD_CLOEXEC, 0);
+ if (fd2 != -1) {
+ close(fd2);
+ close(fd);
+ unlink(filename);
+ return (0);
+ }
+ close (fd);
+ unlink(filename);
+ }
+ return (1);
+}"
+HAVE_IB_F_DUPFD_CLOEXEC)
+
+IF (HAVE_IB_F_DUPFD_CLOEXEC)
+ ADD_DEFINITIONS(-DHAVE_IB_F_DUPFD_CLOEXEC=1)
+ENDIF()
+
CHECK_C_SOURCE_COMPILES("struct t1{ int a; char *b; }; struct t1 c= { .a=1, .b=0 }; main() { }" HAVE_C99_INITIALIZERS)
ENDIF(NOT MSVC)
diff --git a/storage/xtradb/handler/ha_innodb.cc b/storage/xtradb/handler/ha_innodb.cc
index 3cd7cb6977b..fd62bc00ca4 100644
--- a/storage/xtradb/handler/ha_innodb.cc
+++ b/storage/xtradb/handler/ha_innodb.cc
@@ -2738,7 +2738,7 @@ innobase_mysql_tmpfile(
}
}
#else
-#ifdef F_DUPFD_CLOEXEC
+#if defined(F_DUPFD_CLOEXEC) && defined(HAVE_IB_F_DUPFD_CLOEXEC)
fd2 = fcntl(fd, F_DUPFD_CLOEXEC, 0);
#else
fd2 = dup(fd);