It appears that NPTL uses a new system for dealing with cleanup
handlers when a thread is cancelled which has the side effect that
programs linked with librt fail on Fedora Core 2 due to librt having
been built against the NPTL header instead of the old pthread headers.

This change extends valgrind's libpthread.so to handle both the old
and new style cleanup handlers in a similar way to NPTL and seems to
be sufficient to get programs linked with librt working again.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2405 a5019735-40e9-0310-863c-91ae7b9d1cf9
diff --git a/coregrind/vg_include.h b/coregrind/vg_include.h
index 50f486d..19fae44 100644
--- a/coregrind/vg_include.h
+++ b/coregrind/vg_include.h
@@ -705,11 +705,34 @@
    }
    ThreadStatus;
 
+typedef
+   enum CleanupType {
+      VgCt_None,       /* this cleanup entry is not initialised */
+      VgCt_Function,   /* an old-style function pointer cleanup */
+      VgCt_Longjmp     /* a new-style longjmp based cleanup */
+   }
+   CleanupType;
+
+/* A thread unwind buffer */
+typedef
+   struct {
+      jmp_buf jb;
+   } ThreadUnwindBuf;
+
 /* An entry in a threads's cleanup stack. */
 typedef
    struct {
-      void (*fn)(void*);
-      void* arg;
+      CleanupType type;
+      union {
+         struct {
+            void (*fn)(void*);
+            void* arg;
+         } function;
+         struct {
+            ThreadUnwindBuf *ub;
+            int ctype;
+         } longjmp;
+      } data;
    }
    CleanupEntry;