This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: except.c: fix setjmp buffer size math


> 	* 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]