]> git.eshelyaron.com Git - emacs.git/commitdiff
Port VECTOR_ELTS_MAX to older GCC etc.
authorPaul Eggert <eggert@cs.ucla.edu>
Sun, 9 Dec 2018 06:53:15 +0000 (22:53 -0800)
committerPaul Eggert <eggert@cs.ucla.edu>
Sun, 9 Dec 2018 06:54:11 +0000 (22:54 -0800)
Problem reported by Eli Zaretskii in:
https://lists.gnu.org/r/emacs-devel/2018-12/msg00182.html
* src/alloc.c (VECTOR_ELTS_MAX): Now a macro.
Needed for portability to older GCC and non-GCC.

src/alloc.c

index 3bc9277a7b284937da06d48a580edbc53519ecf2..d34b34f27d85b0a43fde9d6aa66fc4022865064c 100644 (file)
@@ -3336,10 +3336,13 @@ sweep_vectors (void)
     }
 }
 
-static ptrdiff_t const VECTOR_ELTS_MAX
-  = min (((min (PTRDIFF_MAX, SIZE_MAX) - header_size - large_vector_offset)
-         / word_size),
-        MOST_POSITIVE_FIXNUM);
+/* Maximum number of elements in a vector.  This is a macro so that it
+   can be used in an integer constant expression.  */
+
+#define VECTOR_ELTS_MAX \
+  min (((min (PTRDIFF_MAX, SIZE_MAX) - header_size - large_vector_offset) \
+       / word_size), \
+       MOST_POSITIVE_FIXNUM)
 
 /* Value is a pointer to a newly allocated Lisp_Vector structure
    with room for LEN Lisp_Objects.  LEN must be positive and