Back to index

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