]> git.ipfire.org Git - thirdparty/glibc.git/blobdiff - nptl/sysdeps/pthread/unwind-forcedunwind.c
Use glibc_likely instead __builtin_expect.
[thirdparty/glibc.git] / nptl / sysdeps / pthread / unwind-forcedunwind.c
index ae43f335e7823804a2fe991f7a0043e675a1546f..9d7bdc5b90d015388da5ad1995dc15dec6358995 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2003, 2005, 2006, 2009 Free Software Foundation, Inc.
+/* Copyright (C) 2003-2014 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Jakub Jelinek <jakub@redhat.com>.
 
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; see the file COPYING.LIB.  If not,
-   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-   Boston, MA 02111-1307, USA.  */
+   License along with the GNU C Library; see the file COPYING.LIB.  If
+   not, see <http://www.gnu.org/licenses/>.  */
 
 #include <dlfcn.h>
 #include <stdio.h>
 #include <unwind.h>
 #include <pthreadP.h>
 #include <sysdep.h>
-#include <libgcc_s.h>
+#include <gnu/lib-names.h>
 
 static void *libgcc_s_handle;
 static void (*libgcc_s_resume) (struct _Unwind_Exception *exc);
@@ -43,7 +42,7 @@ pthread_cancel_init (void)
   void *getcfa;
   void *handle;
 
-  if (__builtin_expect (libgcc_s_handle != NULL, 1))
+  if (__glibc_likely (libgcc_s_handle != NULL))
     {
       /* Force gcc to reload all values.  */
       asm volatile ("" ::: "memory");
@@ -94,8 +93,10 @@ __unwind_freeres (void)
 void
 _Unwind_Resume (struct _Unwind_Exception *exc)
 {
-  if (__builtin_expect (libgcc_s_handle == NULL, 0))
+  if (__glibc_unlikely (libgcc_s_handle == NULL))
     pthread_cancel_init ();
+  else
+    atomic_read_barrier ();
 
   void (*resume) (struct _Unwind_Exception *exc) = libgcc_s_resume;
   PTR_DEMANGLE (resume);
@@ -105,11 +106,13 @@ _Unwind_Resume (struct _Unwind_Exception *exc)
 _Unwind_Reason_Code
 __gcc_personality_v0 (int version, _Unwind_Action actions,
                      _Unwind_Exception_Class exception_class,
-                      struct _Unwind_Exception *ue_header,
-                      struct _Unwind_Context *context)
+                     struct _Unwind_Exception *ue_header,
+                     struct _Unwind_Context *context)
 {
-  if (__builtin_expect (libgcc_s_handle == NULL, 0))
+  if (__glibc_unlikely (libgcc_s_handle == NULL))
     pthread_cancel_init ();
+  else
+    atomic_read_barrier ();
 
   _Unwind_Reason_Code (*personality)
     (int, _Unwind_Action, _Unwind_Exception_Class, struct _Unwind_Exception *,
@@ -122,8 +125,10 @@ _Unwind_Reason_Code
 _Unwind_ForcedUnwind (struct _Unwind_Exception *exc, _Unwind_Stop_Fn stop,
                      void *stop_argument)
 {
-  if (__builtin_expect (libgcc_s_handle == NULL, 0))
+  if (__glibc_unlikely (libgcc_s_handle == NULL))
     pthread_cancel_init ();
+  else
+    atomic_read_barrier ();
 
   _Unwind_Reason_Code (*forcedunwind)
     (struct _Unwind_Exception *, _Unwind_Stop_Fn, void *)
@@ -135,8 +140,10 @@ _Unwind_ForcedUnwind (struct _Unwind_Exception *exc, _Unwind_Stop_Fn stop,
 _Unwind_Word
 _Unwind_GetCFA (struct _Unwind_Context *context)
 {
-  if (__builtin_expect (libgcc_s_handle == NULL, 0))
+  if (__glibc_unlikely (libgcc_s_handle == NULL))
     pthread_cancel_init ();
+  else
+    atomic_read_barrier ();
 
   _Unwind_Word (*getcfa) (struct _Unwind_Context *) = libgcc_s_getcfa;
   PTR_DEMANGLE (getcfa);