This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: except.c: fix setjmp buffer size math
- From: Eric Botcazou <ebotcazou at adacore dot com>
- To: DJ Delorie <dj at redhat dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Thu, 3 Nov 2011 10:14:41 +0100
- Subject: Re: except.c: fix setjmp buffer size math
- References: <201111030330.pA33USdS029597@greed.delorie.com>
> * except.c (init_eh): Fix setjmp buffer size calculations for
> targets where pointers are not word-sized.
This will shrink the buffer for most such targets though.
> Index: gcc/except.c
> ===================================================================
> --- gcc/except.c (revision 180758)
> +++ gcc/except.c (working copy)
> @@ -253,13 +253,13 @@ init_eh (void)
> also tend to be larger than necessary for most systems, a more
> optimal port will define JMP_BUF_SIZE. */
> tmp = size_int (FIRST_PSEUDO_REGISTER + 2 - 1);
> #endif
> #else
> /* builtin_setjmp takes a pointer to 5 words. */
> - tmp = size_int (5 * BITS_PER_WORD / POINTER_SIZE - 1);
> + tmp = size_int (5 * POINTER_SIZE / BITS_PER_WORD - 1);
> #endif
> tmp = build_index_type (tmp);
> tmp = build_array_type (ptr_type_node, tmp);
> f_jbuf = build_decl (BUILTINS_LOCATION,
> FIELD_DECL, get_identifier ("__jbuf"), tmp);
> #ifdef DONT_USE_BUILTIN_SETJMP
This seems hardly correct, especially if you look at the lines just below:
tmp = build_index_type (tmp);
tmp = build_array_type (ptr_type_node, tmp);
You probably want:
/* builtin_setjmp takes a pointer to 5 words or pointers. */
if (POINTER_SIZE > BITS_PER_WORD)
tmp = size_int (4);
else
tmp = size_int (5 * BITS_PER_WORD / POINTER_SIZE - 1);
--
Eric Botcazou