From: Bruno Haible <bruno@clisp.org>
Date: Mon, 12 Aug 2024 15:11:35 +0000 (+0200)
Subject: errno: Ensure ESOCKTNOSUPPORT gets defined.
X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=32601dbf37935eba9a85b918f477860e7638fc82;p=gnulib.git

errno: Ensure ESOCKTNOSUPPORT gets defined.

* m4/errno_h.m4 (gl_HEADER_ERRNO_H): Test also whether ESOCKTNOSUPPORT
is defined.
* lib/errno.in.h (ESOCKTNOSUPPORT, GNULIB_defined_ESOCKTNOSUPPORT): New
macros.
* lib/strerror-override.h (strerror_override): Declare also if
GNULIB_defined_ESOCKTNOSUPPORT is defined.
* lib/strerror-override.c (strerror_override): Handle ESOCKTNOSUPPORT.
* lib/strerrorname_np.c (strerrorname_np): Move ESOCKTNOSUPPORT code to
the POSIX section.
* doc/posix-headers/errno.texi: Document the Haiku problem.
---

diff --git a/ChangeLog b/ChangeLog
index 16df685b97..c4dda29205 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2024-08-12  Bruno Haible  <bruno@clisp.org>
+
+	errno: Ensure ESOCKTNOSUPPORT gets defined.
+	* m4/errno_h.m4 (gl_HEADER_ERRNO_H): Test also whether ESOCKTNOSUPPORT
+	is defined.
+	* lib/errno.in.h (ESOCKTNOSUPPORT, GNULIB_defined_ESOCKTNOSUPPORT): New
+	macros.
+	* lib/strerror-override.h (strerror_override): Declare also if
+	GNULIB_defined_ESOCKTNOSUPPORT is defined.
+	* lib/strerror-override.c (strerror_override): Handle ESOCKTNOSUPPORT.
+	* lib/strerrorname_np.c (strerrorname_np): Move ESOCKTNOSUPPORT code to
+	the POSIX section.
+	* doc/posix-headers/errno.texi: Document the Haiku problem.
+
 2024-08-12  Bruno Haible  <bruno@clisp.org>
 
 	fdutimensat, utimensat tests: Fix test failures on Cygwin.
diff --git a/doc/posix-headers/errno.texi b/doc/posix-headers/errno.texi
index 83a31f4fb4..4495fbfaee 100644
--- a/doc/posix-headers/errno.texi
+++ b/doc/posix-headers/errno.texi
@@ -51,6 +51,9 @@ some platforms:
 glibc/Linux 2.3.6, glibc/Hurd 2.15, glibc/kFreeBSD 2.15,
 Mac OS X 10.5, FreeBSD 6.0, NetBSD 9.3, OpenBSD 6.0, Minix 3.1.8, AIX 5.1, HP-UX 11, Cygwin, mingw without pthreads-win32, MSVC 9.
 @item
+The macro @code{ESOCKTNOSUPPORT} is not defined on some platforms:
+Haiku.
+@item
 The macro @code{EILSEQ} is not defined on some platforms:
 LynxOS 178 2.2.2.
 @item
diff --git a/lib/errno.in.h b/lib/errno.in.h
index ba927037f6..18eb8a0c58 100644
--- a/lib/errno.in.h
+++ b/lib/errno.in.h
@@ -270,10 +270,17 @@
 #  define GNULIB_defined_ENOTRECOVERABLE 1
 # endif
 
+/* On LynxOS, the macro EILSEQ is not defined.  */
 # ifndef EILSEQ
 #  define EILSEQ 2015
 #  define GNULIB_defined_EILSEQ 1
 # endif
 
+/* On Haiku, the macro ESOCKTNOSUPPORT is not defined.  */
+# ifndef ESOCKTNOSUPPORT
+#  define ESOCKTNOSUPPORT 2016
+#  define GNULIB_defined_ESOCKTNOSUPPORT 1
+# endif
+
 #endif /* _@GUARD_PREFIX@_ERRNO_H */
 #endif /* _@GUARD_PREFIX@_ERRNO_H */
diff --git a/lib/strerror-override.c b/lib/strerror-override.c
index b9c1c7aba8..2d9560f909 100644
--- a/lib/strerror-override.c
+++ b/lib/strerror-override.c
@@ -298,6 +298,11 @@ strerror_override (int errnum)
       return "Invalid or incomplete multibyte or wide character";
 # endif
 
+# if GNULIB_defined_ESOCKTNOSUPPORT
+    case ESOCKTNOSUPPORT:
+      return "Socket type not supported";
+# endif
+
     default:
       return NULL;
     }
diff --git a/lib/strerror-override.h b/lib/strerror-override.h
index a1734a242e..c496000389 100644
--- a/lib/strerror-override.h
+++ b/lib/strerror-override.h
@@ -57,7 +57,8 @@ extern "C" {
     || GNULIB_defined_ECANCELED \
     || GNULIB_defined_EOWNERDEAD \
     || GNULIB_defined_ENOTRECOVERABLE \
-    || GNULIB_defined_EILSEQ
+    || GNULIB_defined_EILSEQ \
+    || GNULIB_defined_ESOCKTNOSUPPORT
 extern const char *strerror_override (int errnum) _GL_ATTRIBUTE_CONST;
 #else
 # define strerror_override(ignored) NULL
diff --git a/lib/strerrorname_np.c b/lib/strerrorname_np.c
index 5a93906162..f9f7cb702b 100644
--- a/lib/strerrorname_np.c
+++ b/lib/strerrorname_np.c
@@ -34,7 +34,7 @@ strerrorname_np (int errnum)
     case ERANGE:          return "ERANGE";
 
     /* Error codes specified by POSIX.
-       <https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/errno.h.html>  */
+       <https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/errno.h.html>  */
     #if defined E2BIG
     case E2BIG:           return "E2BIG";
     #endif
@@ -245,6 +245,9 @@ strerrorname_np (int errnum)
     #if defined EROFS
     case EROFS:           return "EROFS";
     #endif
+    #if defined ESOCKTNOSUPPORT
+    case ESOCKTNOSUPPORT: return "ESOCKTNOSUPPORT";
+    #endif
     #if defined ESPIPE
     case ESPIPE:          return "ESPIPE";
     #endif
@@ -1279,10 +1282,6 @@ strerrorname_np (int errnum)
     #if defined ESIGPARM
     case ESIGPARM:        return "ESIGPARM";
     #endif
-    /* Linux, Mac OS X, FreeBSD, NetBSD, OpenBSD, AIX, HP-UX, IRIX, OSF/1, Solaris, Minix, Cygwin */
-    #if defined ESOCKTNOSUPPORT
-    case ESOCKTNOSUPPORT: return "ESOCKTNOSUPPORT";
-    #endif
     /* AIX, OSF/1 */
     #if defined ESOFT
     case ESOFT:           return "ESOFT";
diff --git a/m4/errno_h.m4 b/m4/errno_h.m4
index 18bfd7b1c1..920ea6cc65 100644
--- a/m4/errno_h.m4
+++ b/m4/errno_h.m4
@@ -1,5 +1,5 @@
 # errno_h.m4
-# serial 17
+# serial 18
 dnl Copyright (C) 2004, 2006, 2008-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,
@@ -68,6 +68,9 @@ booboo
 #endif
 #if !defined EILSEQ
 booboo
+#endif
+#if !defined ESOCKTNOSUPPORT
+booboo
 #endif
       ],
       [gl_cv_header_errno_h_complete=no],