diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2014-09-17 22:40:17 -0700 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2014-09-17 22:40:17 -0700 |
commit | e8be4f442baaf84a0d1c9e39b573a77ea9cda908 (patch) | |
tree | 785c4af97b66f4e2a5830a3be838ec886fe94dfb /src | |
parent | bb95ed98f4ef667609d7b0990933f9f4095c8b6a (diff) | |
download | emacs-e8be4f442baaf84a0d1c9e39b573a77ea9cda908.tar.gz |
Port USE_LOCAL_ALLOCATORS code to clang 3.4 x86-64.
Revert previous lisp.h change, and install the following instead.
* lisp.h (USE_LOCAL_ALLOCATORS): Define only if __GNUC__ &&
!__clang__. This works with GCC and with clang and is safer for
compilers we don't know about.
Diffstat (limited to 'src')
-rw-r--r-- | src/ChangeLog | 6 | ||||
-rw-r--r-- | src/lisp.h | 36 |
2 files changed, 17 insertions, 25 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index b91221ef8f3..010f5fd95dd 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,9 +1,9 @@ 2014-09-18 Paul Eggert <eggert@cs.ucla.edu> 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. + * lisp.h (USE_LOCAL_ALLOCATORS): Define only if __GNUC__ && + !__clang__. This works with GCC and with clang and is safer for + compilers we don't know about. (local_cons): Rename parameter to make capture less likely. 2014-09-17 Samuel Bronson <naesten@gmail.com> diff --git a/src/lisp.h b/src/lisp.h index 7a3e0d6a8a3..c5e698cc7c7 100644 --- a/src/lisp.h +++ b/src/lisp.h @@ -4599,30 +4599,22 @@ verify (sizeof (struct Lisp_Cons) == sizeof (union Aligned_Cons)); # define scoped_list3(x, y, z) list3 (x, y, z) #endif -#if USE_STACK_LISP_OBJECTS && HAVE_STATEMENT_EXPRESSIONS - +/* Local allocators require both statement expressions and a + GCALIGNMENT-aligned alloca. clang's alloca isn't properly aligned + in some cases. In the absence of solid information, play it safe + for other non-GCC compilers. */ +#if (USE_STACK_LISP_OBJECTS && HAVE_STATEMENT_EXPRESSIONS \ + && __GNUC__ && !__clang__) # define USE_LOCAL_ALLOCATORS +#endif -/* Alignment fixup needed for alloca. GCC aligns alloca properly already, - Clang sometimes doesn't, and play it safe for other random compilers. */ -# if __GNUC__ && !__clang__ -enum { ALLOCA_FIXUP = 0 }; -# else -enum { ALLOCA_FIXUP = GCALIGNMENT - 1 }; -# endif - -/* Declare a void * variable PTR and set it to a properly-aligned array of - N newly allocated bytes with function lifetime. */ -# define LOCAL_ALLOCA(ptr, n) \ - void *ptr = alloca ((n) + ALLOCA_FIXUP); \ - ptr = (void *) ((intptr_t) ptr_ & ~(ALLOCA_FIXUP)) +#ifdef USE_LOCAL_ALLOCATORS /* Return a function-scoped cons whose car is X and cdr is Y. */ # define local_cons(x, y) \ ({ \ - LOCAL_ALLOCA (ptr_, sizeof (struct Lisp_Cons)); \ - struct Lisp_Cons *c_ = ptr_; \ + struct Lisp_Cons *c_ = alloca (sizeof (struct Lisp_Cons)); \ c_->car = (x); \ c_->u.cdr = (y); \ make_lisp_ptr (c_, Lisp_Cons); \ @@ -4640,9 +4632,9 @@ enum { ALLOCA_FIXUP = GCALIGNMENT - 1 }; ptrdiff_t size_ = size; \ Lisp_Object init_ = init; \ Lisp_Object vec_; \ - if (size_ <= (MAX_ALLOCA - ALLOCA_FIXUP - header_size) / word_size) \ + if (size_ <= (MAX_ALLOCA - header_size) / word_size) \ { \ - LOCAL_ALLOCA (ptr_, size_ * word_size + header_size); \ + void *ptr_ = alloca (size_ * word_size + header_size); \ vec_ = local_vector_init (ptr_, size_, init_); \ } \ else \ @@ -4657,10 +4649,10 @@ enum { ALLOCA_FIXUP = GCALIGNMENT - 1 }; char const *data_ = data; \ ptrdiff_t nbytes_ = nbytes; \ Lisp_Object string_; \ - if (nbytes_ \ - <= MAX_ALLOCA - ALLOCA_FIXUP - sizeof (struct Lisp_String) - 1) \ + if (nbytes_ <= MAX_ALLOCA - sizeof (struct Lisp_String) - 1) \ { \ - LOCAL_ALLOCA (ptr_, sizeof (struct Lisp_String) + 1 + bytes_); \ + struct Lisp_String *ptr_ \ + = alloca (sizeof (struct Lisp_String) + 1 + nbytes_); \ string_ = local_string_init (ptr_, data_, nbytes_); \ } \ else \ |