summaryrefslogtreecommitdiff
path: root/libpthread
diff options
context:
space:
mode:
Diffstat (limited to 'libpthread')
-rw-r--r--libpthread/linuxthreads.old/cancel.c12
-rw-r--r--libpthread/linuxthreads.old/internals.h1
2 files changed, 13 insertions, 0 deletions
diff --git a/libpthread/linuxthreads.old/cancel.c b/libpthread/linuxthreads.old/cancel.c
index f354c2a38..25b098dd5 100644
--- a/libpthread/linuxthreads.old/cancel.c
+++ b/libpthread/linuxthreads.old/cancel.c
@@ -26,6 +26,14 @@
extern void __rpc_thread_destroy(void);
#endif
+#ifdef _STACK_GROWS_DOWN
+# define FRAME_LEFT(frame, other) ((char *) frame >= (char *) other)
+#elif _STACK_GROWS_UP
+# define FRAME_LEFT(frame, other) ((char *) frame <= (char *) other)
+#else
+# error "Define either _STACK_GROWS_DOWN or _STACK_GROWS_UP"
+#endif
+
int pthread_setcancelstate(int state, int * oldstate)
{
@@ -128,6 +136,8 @@ void _pthread_cleanup_push(struct _pthread_cleanup_buffer * buffer,
buffer->__routine = routine;
buffer->__arg = arg;
buffer->__prev = THREAD_GETMEM(self, p_cleanup);
+ if (buffer->__prev != NULL && FRAME_LEFT (buffer, buffer->__prev))
+ buffer->__prev = NULL;
THREAD_SETMEM(self, p_cleanup, buffer);
}
@@ -147,6 +157,8 @@ void _pthread_cleanup_push_defer(struct _pthread_cleanup_buffer * buffer,
buffer->__arg = arg;
buffer->__canceltype = THREAD_GETMEM(self, p_canceltype);
buffer->__prev = THREAD_GETMEM(self, p_cleanup);
+ if (buffer->__prev != NULL && FRAME_LEFT (buffer, buffer->__prev))
+ buffer->__prev = NULL;
THREAD_SETMEM(self, p_canceltype, PTHREAD_CANCEL_DEFERRED);
THREAD_SETMEM(self, p_cleanup, buffer);
}
diff --git a/libpthread/linuxthreads.old/internals.h b/libpthread/linuxthreads.old/internals.h
index f1d5db16b..bd4d8ae13 100644
--- a/libpthread/linuxthreads.old/internals.h
+++ b/libpthread/linuxthreads.old/internals.h
@@ -24,6 +24,7 @@
#include <setjmp.h>
#include <signal.h>
#include <unistd.h>
+#include <bits/stackinfo.h>
#include <sys/types.h>
#include <sys/wait.h>
#include "pt-machine.h"