Subject: Re: [bug-diffutils] bug#24300: intprops.h GL_INT_OP_WRAPV_LONGISH one too many ")"
From: Paul Eggert <[email-masked]>
To: "John E. Malmberg" <[email-masked]>, [email-masked]
Date: Wed, 24 Aug 2016 20:53:28 -0700
List-Id: <debbugs-submit.debbugs.gnu.org>

John E. Malmberg wrote:
> I am currently working around this issue by adding:
>
> #define LLONG_MAX __INT64_MAX
> #define LLONG_MIN __INT64_MIN

Thanks, I installed into Gnulib the attached patch, which should be equivalent.
From 336a88239dbe436105d1c182e4ecb4495a4a6f83 Mon Sep 17 00:00:00 2001
From: Paul Eggert <[email-masked]>
Date: Wed, 24 Aug 2016 20:48:32 -0700
Subject: [PATCH] intprops: port to OpenVMS

Problem reported by John E. Malmberg in: https://bugs.gnu.org/24300
* doc/posix-headers/limits.texi: Document the problem.
* lib/intprops.h (LLONG_MAX, LLONG_MIN) [__INT64_MAX]:
Define if not already defined.
---
 ChangeLog                     | 8 ++++++++
 doc/posix-headers/limits.texi | 2 +-
 lib/intprops.h                | 6 ++++++
 3 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index e842a33..7cfd244 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2016-08-24  Paul Eggert  <[email-masked]>
+
+	intprops: port to OpenVMS
+	Problem reported by John E. Malmberg in: https://bugs.gnu.org/24300
+	* doc/posix-headers/limits.texi: Document the problem.
+	* lib/intprops.h (LLONG_MAX, LLONG_MIN) [__INT64_MAX]:
+	Define if not already defined.
+
 2016-08-19  Assaf Gordon  <[email-masked]>
 
 	parse-datetime: improve debug implementation
diff --git a/doc/posix-headers/limits.texi b/doc/posix-headers/limits.texi
index 9f4ffa5..31207ac 100644
--- a/doc/posix-headers/limits.texi
+++ b/doc/posix-headers/limits.texi
@@ -18,7 +18,7 @@ Portability problems not fixed by Gnulib:
 @item
 The macros @code{LLONG_MIN}, @code{LLONG_MAX}, @code{ULLONG_MAX} are not
 defined on some platforms:
-AIX 5.1, HP-UX 11, IRIX 6.5, OSF/1 5.1 with gcc.
+AIX 5.1, HP-UX 11, IRIX 6.5, OpenVMS, OSF/1 5.1 with gcc.
 @item
 The macros @code{WORD_BIT}, @code{LONG_BIT} are not defined on some platforms:
 glibc 2.11 without @code{-D_GNU_SOURCE}, Cygwin, mingw, MSVC 9.
diff --git a/lib/intprops.h b/lib/intprops.h
index feb02c3..fe6c789 100644
--- a/lib/intprops.h
+++ b/lib/intprops.h
@@ -67,6 +67,12 @@
 #define _GL_SIGNED_INT_MAXIMUM(e)                                       \
   (((_GL_INT_CONVERT (e, 1) << (sizeof ((e) + 0) * CHAR_BIT - 2)) - 1) * 2 + 1)
 
+/* Work around OpenVMS incompatibility with C99.  */
+#if !defined LLONG_MAX && defined __INT64_MAX
+# define LLONG_MAX __INT64_MAX
+# define LLONG_MIN __INT64_MIN
+#endif
+
 /* This include file assumes that signed types are two's complement without
    padding bits; the above macros have undefined behavior otherwise.
    If this is a problem for you, please let us know how to fix it for your host.
-- 
2.7.4