]> Savannah Git Hosting - gnulib.git/commitdiff
diffseq: backward compatibility for OFFSET_MAX
authorPaul Eggert <eggert@cs.ucla.edu>
Sat, 20 May 2023 19:11:54 +0000 (12:11 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Sat, 20 May 2023 19:12:41 +0000 (12:12 -0700)
* lib/diffseq.h (OFFSET_MAX): Define only if not already defined.

ChangeLog
NEWS
lib/diffseq.h

index a0db8442292a552a8760e5109bae43e9a5158bb3..51a88b03f1e51632c6432fb9f8c555dd400a09db 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2023-05-20  Paul Eggert  <eggert@cs.ucla.edu>
+
+       diffseq: backward compatibility for OFFSET_MAX
+       * lib/diffseq.h (OFFSET_MAX): Define only if not already defined.
+
 2023-05-19  Bruno Haible  <bruno@clisp.org>
 
        careadlinkat: Silence gcc warning for GCC ≥ 12.
diff --git a/NEWS b/NEWS
index 8bc86311e9e77aa6b2151f6ff9f30c6d52b63745..1457cb1413f8b8904852bae15ac1df1e183f1342 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -74,8 +74,6 @@ User visible incompatible changes
 
 Date        Modules         Changes
 
-2023-05-19  diffseq         Includers should now also define OFFSET_MAX.
-
 2023-04-28  largefile-required
             year2038-required
                             Modules removed, for consistency with Autoconf
index ea45d9f89215d3a382b71f12923c58f9d7490bf0..c9375cd69674a4ea83dc4d3791b13dda895ba369 100644 (file)
      OFFSET                  A signed integer type sufficient to hold the
                              difference between two indices.  Usually
                              something like ptrdiff_t.
-     OFFSET_MAX              The maximum value of OFFSET (e.g., PTRDIFF_MAX).
+     OFFSET_MAX              (Optional) The maximum value of OFFSET (e.g.,
+                             PTRDIFF_MAX).  If omitted, it is inferred in a
+                             way portable to the vast majority of C platforms,
+                             as they lack padding bits.
      EXTRA_CONTEXT_FIELDS    Declarations of fields for 'struct context'.
      NOTE_DELETE(ctxt, xoff) Record the removal of the object xvec[xoff].
      NOTE_INSERT(ctxt, yoff) Record the insertion of the object yvec[yoff].
      #include "minmax.h"
  */
 
+/* Maximum value of type OFFSET.  */
+#ifndef OFFSET_MAX
+# define OFFSET_MAX \
+   ((((OFFSET) 1 << (sizeof (OFFSET) * CHAR_BIT - 2)) - 1) * 2 + 1)
+#endif
+
 /* Default to no early abort.  */
 #ifndef EARLY_ABORT
 # define EARLY_ABORT(ctxt) false