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: [basic-improvements] try/finally support for c/c++ - more tests


On Fri, Nov 08, 2002 at 04:26:58AM -0800, Richard Henderson wrote:
> On Fri, Nov 08, 2002 at 04:07:09AM -0200, Alexandre Oliva wrote:
> > I fail to see how longjmp_unwind could possibly be implemented without
> > EH frame information for all frames, C ones included.
> 
> The idea I has was that it unwound frames until (1) we arrive at
> the destination frame or (2) we don't find any more EH information,
> at which point it falls back to just longjmp.

But that's the same what would be needed for __try/__finally based
thread cancellation, there is no difference if libpthread cancellation
calls _Unwind_ForcedUnwind directly with a stop_fn which checks for
__libc_start_main resp. pthread_start_thread, or if pthread cancellation
calls longjmp_unwind with a jmp_buf set up in __libc_start_main resp.
pthread_start_thread.

Even there we don't want to abort() in:

  if (exc->private_1 == 0)
    code = _Unwind_RaiseException_Phase2 (exc, &cur_context);
  else
    code = _Unwind_ForcedUnwind_Phase2 (exc, &cur_context);

  if (code != _URC_INSTALL_CONTEXT)
    abort ();

but to let either the stop_fn, or some other hook decide what to do,
such as do the longjmp.

The question is more what will each function having cleanups have to do:

Is it something like:
...
extern __thread jmp_buf *__youngest_jmp_buf;
...
	{
	  jmp_buf __buf;
	  jmp_buf *__previous = __youngest_jmp_buf;
	  int __cleanup;
	  __youngest_jmp_buf = &__buf;
	  __cleanup = setjmp (__buf);
	  if (!__cleanup)
	    {
	      try block;
	    }
	  {
	    finally block;
	  }
	  __youngest_jmp_buf = __previous;
	  if (__cleanup)
	    longjmp_unwind (__youngest_jmp_buf);
	}

?
If __thread is not supported on particular target, it would have to
do a call to pthread library to find address of (resp. get and set)
__youngest_jmp_buf instead.

	Jakub


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