* doc/posix-headers/limits.texi (limits.h): Document this.
* lib/limits.in.h (SSIZE_MAX): Define if not already defined.
* m4/limits-h.m4 (gl_LIMITS_H): Also generate limits.h
if <limits.h> does not define SSIZE_MAX.
2023-05-20 Paul Eggert <eggert@cs.ucla.edu>
+ limits-h: define SSIZE_MAX
+ * doc/posix-headers/limits.texi (limits.h): Document this.
+ * lib/limits.in.h (SSIZE_MAX): Define if not already defined.
+ * m4/limits-h.m4 (gl_LIMITS_H): Also generate limits.h
+ if <limits.h> does not define SSIZE_MAX.
+
diffseq: backward compatibility for OFFSET_MAX
* lib/diffseq.h (OFFSET_MAX): Define only if not already defined.
@item
The macro @code{BOOL_MAX} is not defined with some compilers:
clang 15.0.6.
+@item
+The macro @code{SSIZE_MAX} is not defined on some platforms:
+MSVC 14.
@end itemize
Portability problems fixed by Gnulib module @code{gethostname}:
The macro @code{SSIZE_MAX} has the wrong type,
albeit with the correct value:
32-bit glibc 2.24 (on some architectures), Cygwin 2.5.2.
-@item
-The macro @code{SSIZE_MAX} is not defined on some platforms:
-MSVC 14.
@end itemize
For @code{PATH_MAX}, Gnulib provides a module @code{pathmax} with a header
# endif
#endif
+/* Macro specified by POSIX. */
+
+/* The maximal size_t value. Although it might not be of ssize_t type
+ as it should be, it's too much trouble to fix this minor detail. */
+#ifndef SSIZE_MAX
+# ifdef _WIN64
+# define SSIZE_MAX LLONG_MAX
+# else
+# define SSIZE_MAX LONG_MAX
+# endif
+#endif
+
#endif /* _@GUARD_PREFIX@_LIMITS_H */
#endif /* _@GUARD_PREFIX@_LIMITS_H */
#endif
]])],
[gl_cv_header_limits_width=yes],
[gl_cv_header_limits_width=no])])
- if test "$gl_cv_header_limits_width" = yes; then
- GL_GENERATE_LIMITS_H=false
- else
- GL_GENERATE_LIMITS_H=true
- fi
+ GL_GENERATE_LIMITS_H=true
+ AS_IF([test "$gl_cv_header_limits_width" = yes],
+ [AC_CACHE_CHECK([whether limits.h has SSIZE_MAX],
+ [gl_cv_header_limits_ssize_max],
+ [AC_COMPILE_IFELSE(
+ [AC_LANG_SOURCE(
+ [[#include <limits.h>
+ #ifndef SSIZE_MAX
+ #error "SSIZE_MAX is not defined"
+ #endif
+ ]])],
+ [gl_cv_header_limits_ssize_max=yes],
+ [gl_cv_header_limits_ssize_max=no])])
+ if test "$gl_cv_header_limits_ssize_max" = yes; then
+ GL_GENERATE_LIMITS_H=false
+ fi])
])
dnl Unconditionally enables the replacement of <limits.h>.