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 07:54:04AM -0500, Jakub Jelinek wrote:
> 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.

Note that if something like this is necessary for longjmp_unwind
pthread_cleanup_{push,pop} without __try/__finally, then it will not
work when setjmp/longjmp (expected; the same as __try/__finally based
implementation), but neither with setjmp/longjmp_unwind (because
the jmp_buf pointer chain will be corrupted and of course the cleanups
won't be run) nor C++ exception throwing.

	Jakub


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