Blob Blame History Raw
From: Florian Weimer <fweimer@redhat.com>
Date: Thu, 24 Nov 2022 11:59:22 +0100
Subject: [PATCH] configure.ac: C99 fixes for poll_works check

Include <fcntl.h> if it is available for the open prototype.
Return from main instead of calling exit, so that no function
declaration is needed.

diff --git a/erts/configure b/erts/configure
index f31d7775a4..77fb9d0d7f 100755
--- a/erts/configure
+++ b/erts/configure
@@ -24893,10 +24893,13 @@ else $as_nop
 /* end confdefs.h.  */
 
 #include <poll.h>
-main()
+#ifdef HAVE_FCNTL_H
+#include <fcntl.h>
+#endif
+int main()
 {
 #ifdef _POLL_EMUL_H_
-  exit(1); /* Implemented using select() -- fail */
+  return 1; /* Implemented using select() -- fail */
 #else
   struct pollfd fds[1];
   int fd;
@@ -24905,9 +24908,9 @@ main()
   fds[0].events = POLLIN;
   fds[0].revents = 0;
   if (poll(fds, 1, 0) < 0 || (fds[0].revents & POLLNVAL) != 0) {
-    exit(1);  /* Does not work for devices -- fail */
+    return 1;  /* Does not work for devices -- fail */
   }
-  exit(0);
+  return 0;
 #endif
 }
 
diff --git a/erts/configure.ac b/erts/configure.ac
index 59c4d05460..0abb11a967 100644
--- a/erts/configure.ac
+++ b/erts/configure.ac
@@ -3102,10 +3102,13 @@ poll_works=no
 
 AC_RUN_IFELSE([AC_LANG_SOURCE([[
 #include <poll.h>
-main()
+#ifdef HAVE_FCNTL_H
+#include <fcntl.h>
+#endif
+int main()
 {
 #ifdef _POLL_EMUL_H_
-  exit(1); /* Implemented using select() -- fail */
+  return 1; /* Implemented using select() -- fail */
 #else
   struct pollfd fds[1];
   int fd;
@@ -3114,9 +3117,9 @@ main()
   fds[0].events = POLLIN;
   fds[0].revents = 0;
   if (poll(fds, 1, 0) < 0 || (fds[0].revents & POLLNVAL) != 0) {
-    exit(1);  /* Does not work for devices -- fail */
+    return 1;  /* Does not work for devices -- fail */
   }
-  exit(0);
+  return 0;
 #endif
 }
 ]])],[poll_works=yes],[poll_works=no],[