summaryrefslogtreecommitdiff
path: root/boehm-gc
diff options
context:
space:
mode:
authorbstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4>2012-03-01 10:06:45 +0000
committerbstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4>2012-03-01 10:06:45 +0000
commita79ad0b39b356a82b01dcc061d52b506bdf631e9 (patch)
treef75386ffb541630f9a5648bddd8e39156373c57b /boehm-gc
parentee584ef105d93fbf5b26c76ff37371b58bb3da72 (diff)
downloadgcc-a79ad0b39b356a82b01dcc061d52b506bdf631e9.tar.gz
2012-03-01 Basile Starynkevitch <basile@starynkevitch.net>
MELT branch merged with trunk rev 184686 using svnmerge git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/melt-branch@184689 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'boehm-gc')
-rw-r--r--boehm-gc/ChangeLog16
-rwxr-xr-xboehm-gc/configure11
-rw-r--r--boehm-gc/configure.ac1
-rw-r--r--boehm-gc/include/gc_config.h.in3
-rw-r--r--boehm-gc/include/private/gcconfig.h12
-rw-r--r--boehm-gc/testsuite/boehm-gc.c/thread_leak_test.c55
6 files changed, 85 insertions, 13 deletions
diff --git a/boehm-gc/ChangeLog b/boehm-gc/ChangeLog
index e9d1eb5a6e8..fcefa849157 100644
--- a/boehm-gc/ChangeLog
+++ b/boehm-gc/ChangeLog
@@ -1,3 +1,19 @@
+2012-02-27 Jack Howarth <howarth@bromo.med.uc.edu>
+ Patrick Marlier <patrick.marlier@gmail.com>
+
+ PR boehm-gc/48299
+ * testsuite/boehm-gc.c/thread_leak_test.c: Merge upstream changes.
+
+2012-02-23 Patrick Marlier <patrick.marlier@gmail.com>
+ Jack Howarth <howarth@bromo.med.uc.edu>
+
+ PR boehm-gc/52179
+ * include/gc_config.h.in: Undefine HAVE_PTHREAD_GET_STACKADDR_NP.
+ * include/private/gcconfig.h (DARWIN): Define STACKBOTTOM with
+ pthread_get_stackaddr_np when available.
+ * configure.ac (THREADS): Check availability of pthread_get_stackaddr_np.
+ * configure: Regenerate.
+
2012-02-10 Kai Tietz <ktietz@redhat.com>
PR boehm-gc/48514
diff --git a/boehm-gc/configure b/boehm-gc/configure
index a901e505b73..c76ea447af5 100755
--- a/boehm-gc/configure
+++ b/boehm-gc/configure
@@ -15141,6 +15141,17 @@ _ACEOF
fi
done
+for ac_func in pthread_get_stackaddr_np
+do :
+ ac_fn_c_check_func "$LINENO" "pthread_get_stackaddr_np" "ac_cv_func_pthread_get_stackaddr_np"
+if test "x$ac_cv_func_pthread_get_stackaddr_np" = x""yes; then :
+ cat >>confdefs.h <<_ACEOF
+#define HAVE_PTHREAD_GET_STACKADDR_NP 1
+_ACEOF
+
+fi
+done
+
LIBS="$oldLIBS"
# Configuration of machine-dependent code
diff --git a/boehm-gc/configure.ac b/boehm-gc/configure.ac
index a741ca6d27a..2eddc9fe7ab 100644
--- a/boehm-gc/configure.ac
+++ b/boehm-gc/configure.ac
@@ -380,6 +380,7 @@ esac
oldLIBS="$LIBS"
LIBS="$LIBS $THREADLIBS"
AC_CHECK_FUNCS([pthread_getattr_np])
+AC_CHECK_FUNCS([pthread_get_stackaddr_np])
LIBS="$oldLIBS"
# Configuration of machine-dependent code
diff --git a/boehm-gc/include/gc_config.h.in b/boehm-gc/include/gc_config.h.in
index ea6cb03d22a..6bdd807bcfa 100644
--- a/boehm-gc/include/gc_config.h.in
+++ b/boehm-gc/include/gc_config.h.in
@@ -87,6 +87,9 @@
/* Define to 1 if you have the `pthread_getattr_np' function. */
#undef HAVE_PTHREAD_GETATTR_NP
+/* Define to 1 if you have the `pthread_get_stackaddr_np_np' function. */
+#undef HAVE_PTHREAD_GET_STACKADDR_NP
+
/* Define to 1 if you have the <stdint.h> header file. */
#undef HAVE_STDINT_H
diff --git a/boehm-gc/include/private/gcconfig.h b/boehm-gc/include/private/gcconfig.h
index 25fff6e7e6a..fb09cf73cc0 100644
--- a/boehm-gc/include/private/gcconfig.h
+++ b/boehm-gc/include/private/gcconfig.h
@@ -1331,7 +1331,11 @@
These aren't used when dyld support is enabled (it is by default) */
# define DATASTART ((ptr_t) get_etext())
# define DATAEND ((ptr_t) get_end())
-# define STACKBOTTOM ((ptr_t) 0xc0000000)
+# ifdef HAVE_PTHREAD_GET_STACKADDR_NP
+# define STACKBOTTOM (ptr_t)pthread_get_stackaddr_np(pthread_self())
+# else
+# define STACKBOTTOM ((ptr_t) 0xc0000000)
+# endif
# define USE_MMAP
# define USE_MMAP_ANON
# define USE_ASM_PUSH_REGS
@@ -2014,7 +2018,11 @@
These aren't used when dyld support is enabled (it is by default) */
# define DATASTART ((ptr_t) get_etext())
# define DATAEND ((ptr_t) get_end())
-# define STACKBOTTOM ((ptr_t) 0x7fff5fc00000)
+# ifdef HAVE_PTHREAD_GET_STACKADDR_NP
+# define STACKBOTTOM (ptr_t)pthread_get_stackaddr_np(pthread_self())
+# else
+# define STACKBOTTOM ((ptr_t) 0x7fff5fc00000)
+# endif
# define USE_MMAP
# define USE_MMAP_ANON
# ifdef GC_DARWIN_THREADS
diff --git a/boehm-gc/testsuite/boehm-gc.c/thread_leak_test.c b/boehm-gc/testsuite/boehm-gc.c/thread_leak_test.c
index eb4cb9bd018..89014651261 100644
--- a/boehm-gc/testsuite/boehm-gc.c/thread_leak_test.c
+++ b/boehm-gc/testsuite/boehm-gc.c/thread_leak_test.c
@@ -1,13 +1,22 @@
-#define GC_LINUX_THREADS
+#ifndef GC_THREADS
+# define GC_THREADS
+#endif
#include "leak_detector.h"
-#include <pthread.h>
+#ifdef GC_PTHREADS
+# include <pthread.h>
+#else
+# include <windows.h>
+#endif
#include <stdio.h>
-void * test(void * arg) {
+#ifdef GC_PTHREADS
+ void * test(void * arg)
+#else
+ DWORD WINAPI test(LPVOID arg)
+#endif
+{
int *p[10];
int i;
- GC_find_leak = 1; /* for new collect versions not compiled */
- /* with -DFIND_LEAK. */
for (i = 0; i < 10; ++i) {
p[i] = malloc(sizeof(int)+i);
}
@@ -15,23 +24,47 @@ void * test(void * arg) {
for (i = 1; i < 10; ++i) {
free(p[i]);
}
-}
+#ifdef GC_PTHREADS
+ return arg;
+#else
+ return (DWORD)(GC_word)arg;
+#endif
+}
#define NTHREADS 5
-int main() {
+int main(void) {
int i;
+#ifdef GC_PTHREADS
pthread_t t[NTHREADS];
+#else
+ HANDLE t[NTHREADS];
+ DWORD thread_id;
+#endif
int code;
+ GC_find_leak = 1; /* for new collect versions not compiled */
+ GC_INIT();
for (i = 0; i < NTHREADS; ++i) {
- if ((code = pthread_create(t + i, 0, test, 0)) != 0) {
- printf("Thread creation failed %d\n", code);
+#ifdef GC_PTHREADS
+ code = pthread_create(t + i, 0, test, 0);
+#else
+ t[i] = CreateThread(NULL, 0, test, 0, 0, &thread_id);
+ code = t[i] != NULL ? 0 : (int)GetLastError();
+#endif
+ if (code != 0) {
+ printf("Thread creation failed %d\n", code);
}
}
for (i = 0; i < NTHREADS; ++i) {
- if ((code = pthread_join(t[i], 0)) != 0) {
- printf("Thread join failed %lu\n", code);
+#ifdef GC_PTHREADS
+ code = pthread_join(t[i], 0);
+#else
+ code = WaitForSingleObject(t[i], INFINITE) == WAIT_OBJECT_0 ? 0 :
+ (int)GetLastError();
+#endif
+ if (code != 0) {
+ printf("Thread join failed %d\n", code);
}
}
CHECK_LEAKS();