]> Savannah Git Hosting - gnulib.git/commitdiff
sys_un: New module.
authorCollin Funk <collin.funk1@gmail.com>
Thu, 25 Jul 2024 03:14:49 +0000 (20:14 -0700)
committerCollin Funk <collin.funk1@gmail.com>
Thu, 25 Jul 2024 03:14:49 +0000 (20:14 -0700)
* doc/posix-headers/sys_un.texi (sys/un.h): Mention it.
* lib/sys_un.in.h: New file.
* m4/sys_un_h.m4: New file.
* modules/sys_un: New file.

ChangeLog
doc/posix-headers/sys_un.texi
lib/sys_un.in.h [new file with mode: 0644]
m4/sys_un_h.m4 [new file with mode: 0644]
modules/sys_un [new file with mode: 0644]

index f7fcead6a420a2193f65f1020021ba90b23e72ef..6342a6ce7fdfd6aaf2095be90eed3ee9e3a24aec 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2024-07-24  Collin Funk  <collin.funk1@gmail.com>
+
+       sys_un: New module.
+       * doc/posix-headers/sys_un.texi (sys/un.h): Mention it.
+       * lib/sys_un.in.h: New file.
+       * m4/sys_un_h.m4: New file.
+       * modules/sys_un: New file.
+
 2024-07-24  Bruno Haible  <bruno@clisp.org>
 
        Avoid false select_used_without_requesting_gnulib_module_select.
index 48ecf3753f3842ff29e6b598f453f838f438a877..61affda2c61c51aa264ba76347a0ecd004e3d9e6 100644 (file)
@@ -3,18 +3,21 @@
 
 POSIX specification:@* @url{https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/sys_un.h.html}
 
-Gnulib module: ---
+Gnulib module: sys_un
 
 Portability problems fixed by Gnulib:
 @itemize
+@item
+@c Added in Windows 10 Insider Build 17063:
+@c <https://devblogs.microsoft.com/commandline/af_unix-comes-to-windows/>
+@c <https://blogs.windows.com/windows-insider/2017/12/19/announcing-windows-10-insider-preview-build-17063-pc/>
+This header file is missing on some platforms:
+mingw, MSVC 14.
 @end itemize
 
 Portability problems not fixed by Gnulib:
 @itemize
 @item
-This header file is missing on some platforms:
-mingw, MSVC 14.
-@item
 This header requires <code>sys/socket.h</code> to be included first on
 some platforms:
 Cygwin 1.7.18.
diff --git a/lib/sys_un.in.h b/lib/sys_un.in.h
new file mode 100644 (file)
index 0000000..52993d6
--- /dev/null
@@ -0,0 +1,34 @@
+/* sys/un.h - definitions for UNIX domain sockets
+
+   Copyright 2024 Free Software Foundation, Inc.
+
+   This file is free software: you can redistribute it and/or modify
+   it under the terms of the GNU Lesser General Public License as
+   published by the Free Software Foundation; either version 2.1 of the
+   License, or (at your option) any later version.
+
+   This file is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public License
+   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
+
+/* Written by Collin Funk.  */
+
+#ifndef _@GUARD_PREFIX@_SYS_UN_H
+#define _@GUARD_PREFIX@_SYS_UN_H 1
+
+/* Windows requires <winsock2.h> to be included before <afunix.h>.  */
+#if @HAVE_WINSOCK2_H@
+# include <winsock2.h>
+#endif
+#if @HAVE_AFUNIX_H@
+# include <afunix.h>
+#endif
+
+/* If a platform does not support AF_UNIX sockets 'struct sockaddr_un' will
+   not be defined.  You may use HAVE_UNIXSOCKET after including <config.h>.  */
+
+#endif
diff --git a/m4/sys_un_h.m4 b/m4/sys_un_h.m4
new file mode 100644 (file)
index 0000000..ed19b70
--- /dev/null
@@ -0,0 +1,32 @@
+# sys_un_h.m4
+# serial 1
+dnl Copyright 2024 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+AC_DEFUN_ONCE([gl_SYS_UN_H],
+[
+  dnl Check if UNIX domain sockets are supported.
+  AC_REQUIRE([gl_SOCKET_FAMILY_UNIX])
+
+  GL_GENERATE_SYS_UN_H=false
+
+  if test $gl_cv_socket_unix = yes; then
+
+    dnl Check if using a Windows version that supports AF_UNIX.
+    dnl See <https://devblogs.microsoft.com/commandline/af_unix-comes-to-windows/>.
+    if test "$ac_cv_header_winsock2_h" = yes \
+       && test "$ac_cv_header_afunix_h" = yes; then
+      GL_GENERATE_SYS_UN_H=true
+    fi
+  fi
+
+  dnl Checked in gl_SOCKET_FAMILY_UNIX.
+  if test "$ac_cv_header_afunix_h" = yes; then
+    HAVE_AFUNIX_H=1
+  else
+    HAVE_AFUNIX_H=0
+  fi
+  AC_SUBST([HAVE_AFUNIX_H])
+])
diff --git a/modules/sys_un b/modules/sys_un
new file mode 100644 (file)
index 0000000..af72a80
--- /dev/null
@@ -0,0 +1,44 @@
+Description:
+A POSIX-like <sys/un.h>.
+
+Files:
+lib/sys_un.in.h
+m4/sys_un_h.m4
+
+Depends-on:
+gen-header
+sys_socket
+
+configure.ac:
+gl_SYS_UN_H
+gl_CONDITIONAL_HEADER([sys/un.h])
+AC_PROG_MKDIR_P
+
+Makefile.am:
+BUILT_SOURCES += $(SYS_UN_H)
+
+# We need the following in order to create <sys/un.h> when the system
+# doesn't have one.
+if GL_GENERATE_SYS_UN_H
+sys/un.h: sys_un.in.h $(top_builddir)/config.status
+@NMD@  $(AM_V_GEN)$(MKDIR_P) '%reldir%'
+       $(gl_V_at)$(SED_HEADER_STDOUT) \
+             -e 's|@''GUARD_PREFIX''@|${gl_include_guard_prefix}|g' \
+             -e 's|@''HAVE_WINSOCK2_H''@|$(HAVE_WINSOCK2_H)|g' \
+             -e 's|@''HAVE_AFUNIX_H''@|$(HAVE_AFUNIX_H)|g' \
+       $(srcdir)/sys_un.in.h > $@-t
+       $(AM_V_at)mv $@-t $@
+else
+sys/un.h: $(top_builddir)/config.status
+       rm -f $@
+endif
+MOSTLYCLEANFILES += sys/un.h sys/un.h-t
+
+Include:
+<sys/un.h>
+
+License:
+LGPLv2+
+
+Maintainer:
+all