From f6b391b679c9a821488feadfa348b94d5f410345 Mon Sep 17 00:00:00 2001
From: Simon Atanasyan <simon@atanasyan.com>
Date: Thu, 23 Oct 2014 11:35:00 -0700
Subject: [PATCH] Fix intermittent failures of Lrs-race test case

After the following change the Lrs-race test case starts to intermittently
fails:

eac65dc Add basic support for the QNX operating system

When we include "config.h" into the "libunwind_i.h" we undefine
the HAVE___THREAD macro in a few lines below in #include "config.h"
pragma. The change eac65dc includes "config.h" into the "dwarf.h"
but forgets to undefine HAVE___THREAD. So now this macro has inconsistent
state among the code. Somewhere it is defined, somewhere not. In particular
it becomes defined in the mi/Gset_caching_policy.c and we do not replace
UNW_CACHE_PER_THREAD caching policy by the UNW_CACHE_GLOBAL.

The fix is rather dirty. It adds the code to undefine HAVE___THREAD in
the "dwarf.h" like we do that in the "libunwind_i.h". Probably the ideal
solution should fix per-thread caching implementation or turned it off
at all on platforms where it is not completely and correctly supported.

Signed-off-by: Simon Atanasyan <simon@atanasyan.com>
---
 include/dwarf.h |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/include/dwarf.h b/include/dwarf.h
index 71e9df6..169f739 100644
--- a/include/dwarf.h
+++ b/include/dwarf.h
@@ -37,6 +37,13 @@ struct elf_dyn_info;
 # include "config.h"
 #endif
 
+#ifdef HAVE___THREAD
+  /* For now, turn off per-thread caching.  It uses up too much TLS
+     memory per thread even when the thread never uses libunwind at
+     all.  */
+# undef HAVE___THREAD
+#endif
+
 #ifndef UNW_REMOTE_ONLY
   #if defined(HAVE_LINK_H)
     #include <link.h>
-- 
1.7.2.5

