aboutsummaryrefslogtreecommitdiffstats
path: root/src/lisp.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/lisp.h')
-rw-r--r--src/lisp.h33
1 files changed, 24 insertions, 9 deletions
diff --git a/src/lisp.h b/src/lisp.h
index 9cbc7473fc1..7a3e0d6a8a3 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -4603,14 +4603,29 @@ verify (sizeof (struct Lisp_Cons) == sizeof (union Aligned_Cons));
4603 4603
4604# define USE_LOCAL_ALLOCATORS 4604# define USE_LOCAL_ALLOCATORS
4605 4605
4606/* Alignment fixup needed for alloca. GCC aligns alloca properly already,
4607 Clang sometimes doesn't, and play it safe for other random compilers. */
4608# if __GNUC__ && !__clang__
4609enum { ALLOCA_FIXUP = 0 };
4610# else
4611enum { ALLOCA_FIXUP = GCALIGNMENT - 1 };
4612# endif
4613
4614/* Declare a void * variable PTR and set it to a properly-aligned array of
4615 N newly allocated bytes with function lifetime. */
4616# define LOCAL_ALLOCA(ptr, n) \
4617 void *ptr = alloca ((n) + ALLOCA_FIXUP); \
4618 ptr = (void *) ((intptr_t) ptr_ & ~(ALLOCA_FIXUP))
4619
4606/* Return a function-scoped cons whose car is X and cdr is Y. */ 4620/* Return a function-scoped cons whose car is X and cdr is Y. */
4607 4621
4608# define local_cons(x, y) \ 4622# define local_cons(x, y) \
4609 ({ \ 4623 ({ \
4610 struct Lisp_Cons *c = alloca (sizeof (struct Lisp_Cons)); \ 4624 LOCAL_ALLOCA (ptr_, sizeof (struct Lisp_Cons)); \
4611 c->car = (x); \ 4625 struct Lisp_Cons *c_ = ptr_; \
4612 c->u.cdr = (y); \ 4626 c_->car = (x); \
4613 make_lisp_ptr (c, Lisp_Cons); \ 4627 c_->u.cdr = (y); \
4628 make_lisp_ptr (c_, Lisp_Cons); \
4614 }) 4629 })
4615 4630
4616# define local_list1(x) local_cons (x, Qnil) 4631# define local_list1(x) local_cons (x, Qnil)
@@ -4625,9 +4640,9 @@ verify (sizeof (struct Lisp_Cons) == sizeof (union Aligned_Cons));
4625 ptrdiff_t size_ = size; \ 4640 ptrdiff_t size_ = size; \
4626 Lisp_Object init_ = init; \ 4641 Lisp_Object init_ = init; \
4627 Lisp_Object vec_; \ 4642 Lisp_Object vec_; \
4628 if (size_ <= (MAX_ALLOCA - header_size) / word_size) \ 4643 if (size_ <= (MAX_ALLOCA - ALLOCA_FIXUP - header_size) / word_size) \
4629 { \ 4644 { \
4630 void *ptr_ = alloca (size_ * word_size + header_size); \ 4645 LOCAL_ALLOCA (ptr_, size_ * word_size + header_size); \
4631 vec_ = local_vector_init (ptr_, size_, init_); \ 4646 vec_ = local_vector_init (ptr_, size_, init_); \
4632 } \ 4647 } \
4633 else \ 4648 else \
@@ -4642,10 +4657,10 @@ verify (sizeof (struct Lisp_Cons) == sizeof (union Aligned_Cons));
4642 char const *data_ = data; \ 4657 char const *data_ = data; \
4643 ptrdiff_t nbytes_ = nbytes; \ 4658 ptrdiff_t nbytes_ = nbytes; \
4644 Lisp_Object string_; \ 4659 Lisp_Object string_; \
4645 if (nbytes_ <= MAX_ALLOCA - sizeof (struct Lisp_String) - 1) \ 4660 if (nbytes_ \
4661 <= MAX_ALLOCA - ALLOCA_FIXUP - sizeof (struct Lisp_String) - 1) \
4646 { \ 4662 { \
4647 struct Lisp_String *ptr_ \ 4663 LOCAL_ALLOCA (ptr_, sizeof (struct Lisp_String) + 1 + bytes_); \
4648 = alloca (sizeof (struct Lisp_String) + 1 + nbytes_); \
4649 string_ = local_string_init (ptr_, data_, nbytes_); \ 4664 string_ = local_string_init (ptr_, data_, nbytes_); \
4650 } \ 4665 } \
4651 else \ 4666 else \