|
From: Tom H. <th...@cy...> - 2004-06-12 17:25:30
|
CVS commit by thughes:
Fixed the NPTL cleanup handler support to try and make sure it will
compile on systems with NPTL header files.
M +1 -0 configure.in 1.110
M +1 -7 coregrind/vg_include.h 1.193
M +41 -21 coregrind/vg_libpthread.c 1.155
--- valgrind/configure.in #1.109:1.110
@@ -339,4 +339,5 @@
AC_TYPE_SIZE_T
AC_HEADER_TIME
+AC_CHECK_TYPES(__pthread_unwind_buf_t,,,[#include <pthread.h>])
# Checks for library functions.
--- valgrind/coregrind/vg_include.h #1.192:1.193
@@ -714,10 +714,4 @@ typedef
CleanupType;
-/* A thread unwind buffer */
-typedef
- struct {
- jmp_buf jb;
- } ThreadUnwindBuf;
-
/* An entry in a threads's cleanup stack. */
typedef
@@ -730,5 +724,5 @@ typedef
} function;
struct {
- ThreadUnwindBuf *ub;
+ void *ub;
int ctype;
} longjmp;
--- valgrind/coregrind/vg_libpthread.c #1.154:1.155
@@ -165,4 +165,23 @@ typedef struct
x = 0; // ensure we don't accidentally use x again!
+
+/* ---------------------------------------------------------------------
+ Our own definition of types that only exist in NPTL.
+ ------------------------------------------------------------------ */
+
+#ifndef HAVE___PTHREAD_UNWIND_BUF_T
+
+typedef struct
+{
+ struct
+ {
+ jmp_buf __cancel_jmp_buf;
+ int __mask_was_saved;
+ } __cancel_jmp_buf[1];
+ void *__pad[4];
+} __pthread_unwind_buf_t __attribute__ ((__aligned__));
+
+#endif
+
/* ---------------------------------------------------------------------
Forwardses.
@@ -778,5 +797,5 @@ void thread_wrapper ( NewThreadInfo* inf
void* arg;
void* ret_val;
- ThreadUnwindBuf ub;
+ __pthread_unwind_buf_t ub;
attr__detachstate = info->attr__detachstate;
@@ -834,5 +853,5 @@ void thread_wrapper ( NewThreadInfo* inf
- if (setjmp(ub.jb) == 0) {
+ if (setjmp(ub.__cancel_jmp_buf[0].__cancel_jmp_buf) == 0) {
CleanupEntry cu;
int res;
@@ -950,5 +969,5 @@ void _pthread_cleanup_pop_restore (struc
__attribute ((regparm (1)))
-void __pthread_register_cancel (ThreadUnwindBuf *ub)
+void __pthread_register_cancel (__pthread_unwind_buf_t *__buf)
{
int res;
@@ -956,5 +975,5 @@ void __pthread_register_cancel (ThreadUn
ensure_valgrind("__pthread_register_cancel");
cu.type = VgCt_Longjmp;
- cu.data.longjmp.ub = ub;
+ cu.data.longjmp.ub = __buf;
VALGRIND_MAGIC_SEQUENCE(res, (-1) /* default */,
VG_USERREQ__CLEANUP_PUSH,
@@ -965,5 +984,5 @@ void __pthread_register_cancel (ThreadUn
__attribute ((regparm (1)))
-void __pthread_register_cancel_defer (ThreadUnwindBuf *ub)
+void __pthread_register_cancel_defer (__pthread_unwind_buf_t *__buf)
{
/* As __pthread_register cancel, but save the thread's original
@@ -973,5 +992,5 @@ void __pthread_register_cancel_defer (Th
ensure_valgrind("__pthread_register_cancel_defer");
cu.type = VgCt_Longjmp;
- cu.data.longjmp.ub = ub;
+ cu.data.longjmp.ub = __buf;
/* Set to Deferred, and save the old cancellation type. */
my_assert(-1 != PTHREAD_CANCEL_DEFERRED);
@@ -991,5 +1010,5 @@ void __pthread_register_cancel_defer (Th
__attribute ((regparm (1)))
-void __pthread_unregister_cancel (ThreadUnwindBuf *ub)
+void __pthread_unregister_cancel (__pthread_unwind_buf_t *__buf)
{
int res;
@@ -1001,5 +1020,5 @@ void __pthread_unregister_cancel (Thread
&cu, 0, 0, 0);
my_assert(cu.type == VgCt_Longjmp);
- my_assert(cu.data.longjmp.ub == ub);
+ my_assert(cu.data.longjmp.ub == __buf);
return;
}
@@ -1007,5 +1026,5 @@ void __pthread_unregister_cancel (Thread
__attribute ((regparm (1)))
-void __pthread_unregister_restore (ThreadUnwindBuf *ub)
+void __pthread_unregister_restore (__pthread_unwind_buf_t *__buf)
{
int res;
@@ -1020,5 +1039,5 @@ void __pthread_unregister_restore (Threa
&cu, 0, 0, 0);
my_assert(cu.type == VgCt_Longjmp);
- my_assert(cu.data.longjmp.ub == ub);
+ my_assert(cu.data.longjmp.ub == __buf);
/* Restore the original cancellation type. */
my_assert(cu.data.longjmp.ctype == PTHREAD_CANCEL_DEFERRED
@@ -1035,5 +1054,5 @@ void __pthread_unregister_restore (Threa
__attribute ((regparm (1)))
__attribute ((__noreturn__))
-void __pthread_unwind (ThreadUnwindBuf *ub)
+void __pthread_unwind (__pthread_unwind_buf_t *__buf)
{
int res;
@@ -1050,6 +1069,7 @@ void __pthread_unwind (ThreadUnwindBuf *
}
my_assert(cu.type == VgCt_Longjmp);
- my_assert(ub == NULL || ub == cu.data.longjmp.ub);
- longjmp(cu.data.longjmp.ub->jb, 1);
+ my_assert(__buf == NULL || __buf == cu.data.longjmp.ub);
+ __buf = cu.data.longjmp.ub;
+ longjmp(__buf->__cancel_jmp_buf[0].__cancel_jmp_buf, 1);
/* NOTREACHED */
}
@@ -1058,5 +1078,5 @@ void __pthread_unwind (ThreadUnwindBuf *
__attribute ((regparm (1)))
__attribute ((__noreturn__))
-void __pthread_unwind_next (ThreadUnwindBuf *ub)
+void __pthread_unwind_next (__pthread_unwind_buf_t *__buf)
{
__pthread_unwind(NULL);
|