Back to index

glibc  2.9
unwind-resume.c
Go to the documentation of this file.
00001 /* Copyright (C) 2003 Free Software Foundation, Inc.
00002    This file is part of the GNU C Library.
00003    Contributed by Jakub Jelinek <jakub@redhat.com>.
00004 
00005    The GNU C Library is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Lesser General Public License as
00007    published by the Free Software Foundation; either version 2.1 of the
00008    License, or (at your option) any later version.
00009 
00010    The GNU C Library is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013    Lesser General Public License for more details.
00014 
00015    You should have received a copy of the GNU Lesser General Public
00016    License along with the GNU C Library; see the file COPYING.LIB.  If not,
00017    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00018    Boston, MA 02111-1307, USA.  */
00019 
00020 #include <dlfcn.h>
00021 #include <stdio.h>
00022 #include <unwind.h>
00023 
00024 static void (*libgcc_s_resume) (struct _Unwind_Exception *exc);
00025 static _Unwind_Reason_Code (*libgcc_s_personality)
00026   (int, _Unwind_Action, _Unwind_Exception_Class, struct _Unwind_Exception *,
00027    struct _Unwind_Context *);
00028 
00029 static void
00030 init (void)
00031 {
00032   void *resume, *personality;
00033   void *handle;
00034 
00035   handle = __libc_dlopen ("libgcc_s.so.1");
00036 
00037   if (handle == NULL
00038       || (resume = __libc_dlsym (handle, "_Unwind_Resume")) == NULL
00039       || (personality = __libc_dlsym (handle, "__gcc_personality_v0")) == NULL)
00040     __libc_fatal ("libgcc_s.so.1 must be installed for pthread_cancel to work\n");
00041 
00042   libgcc_s_resume = resume;
00043   libgcc_s_personality = personality;
00044 }
00045 
00046 void
00047 _Unwind_Resume (struct _Unwind_Exception *exc)
00048 {
00049   if (__builtin_expect (libgcc_s_resume == NULL, 0))
00050     init ();
00051   libgcc_s_resume (exc);
00052 }
00053 
00054 _Unwind_Reason_Code
00055 __gcc_personality_v0 (int version, _Unwind_Action actions,
00056                     _Unwind_Exception_Class exception_class,
00057                       struct _Unwind_Exception *ue_header,
00058                       struct _Unwind_Context *context)
00059 {
00060   if (__builtin_expect (libgcc_s_personality == NULL, 0))
00061     init ();
00062   return libgcc_s_personality (version, actions, exception_class,
00063                             ue_header, context);
00064 }