]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
diagnostics: conditionally include afunix.h
authorTorbjörn SVENSSON <torbjorn.svensson@foss.st.com>
Thu, 29 Jan 2026 16:44:13 +0000 (17:44 +0100)
committerTorbjörn SVENSSON <torbjorn.svensson@foss.st.com>
Tue, 3 Feb 2026 13:15:06 +0000 (14:15 +0100)
afunix.h was first included in MinGW 10.0.0.  For earlier versions, fall
back to internal definition.

gcc/ChangeLog:

* config.in: Regenerate.
* configure: Regenerate.
* configure.ac (gcc_cv_header_afunix_h): New test.
(HAVE_AFUNIX_H): New AC_DEFINE.
* diagnostics/sarif-sink.cc: Conditionally include afunix.h
if it's available, else fall back to internal definition.

Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
gcc/config.in
gcc/configure
gcc/configure.ac
gcc/diagnostics/sarif-sink.cc

index 72d2eb1dc80052c9d6b5d27302d34b6b3a0cfca3..2feb1d12b1b9f268c4ca319e6b592d8646a6cea9 100644 (file)
 #endif
 
 
+/* Define if you have a working <afunix.h> header file. */
+#ifndef USED_FOR_TARGET
+#undef HAVE_AFUNIX_H
+#endif
+
+
 /* Define if AF_INET6 supported. */
 #ifndef USED_FOR_TARGET
 #undef HAVE_AF_INET6
index a26971e0ded0e09d8850ad7817f8e0a2fcd76e9c..b708db893d8867371bb4ca040f3575db2f19fcdf 100755 (executable)
@@ -10485,6 +10485,40 @@ $as_echo "#define HAVE_INTTYPES_H 1" >>confdefs.h
 
 fi
 
+# Use <afunix.h> only if it exists,
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for afunix.h" >&5
+$as_echo_n "checking for afunix.h... " >&6; }
+if ${gcc_cv_header_afunix_h+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <winsock2.h>
+#include <afunix.h>
+int
+main ()
+{
+SOCKADDR_UN addr;
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_compile "$LINENO"; then :
+  gcc_cv_header_afunix_h=yes
+else
+  gcc_cv_header_afunix_h=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_header_afunix_h" >&5
+$as_echo "$gcc_cv_header_afunix_h" >&6; }
+if test $gcc_cv_header_afunix_h = yes; then
+
+$as_echo "#define HAVE_AFUNIX_H 1" >>confdefs.h
+
+fi
+
 # Look for the ZSTD package.
 ZSTD_INCLUDE=
 ZSTD_LIB=
@@ -21954,7 +21988,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 21957 "configure"
+#line 21991 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -22060,7 +22094,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 22063 "configure"
+#line 22097 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
index 3f6a6a171ca1356e5ed61e51b6407271e4451804..a638d7cb0b6d41e96af997b4521ec4fa4508c25b 100644 (file)
@@ -1484,6 +1484,21 @@ if test $gcc_cv_header_inttypes_h = yes; then
        [Define if you have a working <inttypes.h> header file.])
 fi
 
+# Use <afunix.h> only if it exists,
+AC_MSG_CHECKING(for afunix.h)
+AC_CACHE_VAL(gcc_cv_header_afunix_h,
+[AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
+[[#include <winsock2.h>
+#include <afunix.h>]],
+  [[SOCKADDR_UN addr;]])],
+  [gcc_cv_header_afunix_h=yes],
+  [gcc_cv_header_afunix_h=no])])
+AC_MSG_RESULT($gcc_cv_header_afunix_h)
+if test $gcc_cv_header_afunix_h = yes; then
+  AC_DEFINE(HAVE_AFUNIX_H, 1,
+       [Define if you have a working <afunix.h> header file.])
+fi
+
 # Look for the ZSTD package.
 ZSTD_INCLUDE=
 ZSTD_LIB=
index 94db35ca864de2b098f2cd0b582a6d38b4de0f4c..8e8947aa026a18a3098233a3d6dfae5fee85cfdc 100644 (file)
@@ -22,8 +22,15 @@ along with GCC; see the file COPYING3.  If not see
 
 #ifdef __MINGW32__
 #include <winsock2.h>
+#ifdef HAVE_AFUNIX_H
 #include <afunix.h>
 #else
+struct sockaddr_un {
+  ADDRESS_FAMILY sun_family;
+  char sun_path[108];
+};
+#endif
+#else
 #include <sys/un.h>
 #include <sys/socket.h>
 #endif