emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master fa4dd8d: Port VECTOR_ELTS_MAX to older GCC etc.


From: Paul Eggert
Subject: [Emacs-diffs] master fa4dd8d: Port VECTOR_ELTS_MAX to older GCC etc.
Date: Sun, 9 Dec 2018 01:54:15 -0500 (EST)

branch: master
commit fa4dd8dd01b87b751abd74408ddd581263d6b839
Author: Paul Eggert <address@hidden>
Commit: Paul Eggert <address@hidden>

    Port VECTOR_ELTS_MAX to older GCC etc.
    
    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 | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/src/alloc.c b/src/alloc.c
index 3bc9277..d34b34f 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]