aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaul Eggert2014-09-17 18:03:40 -0700
committerPaul Eggert2014-09-17 18:03:40 -0700
commitbb95ed98f4ef667609d7b0990933f9f4095c8b6a (patch)
tree3d7b035f89e96d553f08b9a78ce7dbc099c75813 /src
parent5db525e40007b1f0e7f8f6cee070c515c7f6ff11 (diff)
downloademacs-bb95ed98f4ef667609d7b0990933f9f4095c8b6a.tar.gz
emacs-bb95ed98f4ef667609d7b0990933f9f4095c8b6a.zip
Port USE_LOCAL_ALLOCATORS code to clang 3.4 x86-64.
* lisp.h (ALLOCA_FIXUP): New constant. (LOCAL_ALLOCA): New macro. (local_cons, make_local_vector, make_local_string): Use them. (local_cons): Rename parameter to make capture less likely.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog8
-rw-r--r--src/lisp.h33
2 files changed, 32 insertions, 9 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index ff9e6e5778d..b91221ef8f3 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,11 @@
12014-09-18 Paul Eggert <eggert@cs.ucla.edu>
2
3 Port USE_LOCAL_ALLOCATORS code to clang 3.4 x86-64.
4 * lisp.h (ALLOCA_FIXUP): New constant.
5 (LOCAL_ALLOCA): New macro.
6 (local_cons, make_local_vector, make_local_string): Use them.
7 (local_cons): Rename parameter to make capture less likely.
8
12014-09-17 Samuel Bronson <naesten@gmail.com> 92014-09-17 Samuel Bronson <naesten@gmail.com>
2 10
3 * unexmacosx.c (copy_data_segment): Port to GCC 4.6+ (Bug#9927). 11 * unexmacosx.c (copy_data_segment): Port to GCC 4.6+ (Bug#9927).
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 \