summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore2
-rw-r--r--AUTHORS1
-rw-r--r--Makefile.am4
-rw-r--r--Makefile.direct20
-rw-r--r--cord/cord.am5
-rw-r--r--cord/tests/cordtest.c11
-rw-r--r--darwin_stop_world.c46
-rw-r--r--dyn_load.c11
-rw-r--r--ia64_save_regs_in_stack.s (renamed from src/ia64_save_regs_in_stack.s)0
-rw-r--r--include/gc_config_macros.h14
-rw-r--r--include/include.am1
-rw-r--r--include/private/darwin_semaphore.h55
-rw-r--r--include/private/gc_priv.h26
-rw-r--r--include/private/gcconfig.h14
-rw-r--r--include/private/pthread_support.h2
-rw-r--r--misc.c14
-rw-r--r--os_dep.c8
-rw-r--r--pthread_support.c24
-rw-r--r--sparc_mach_dep.S (renamed from src/sparc_mach_dep.S)0
-rw-r--r--sparc_netbsd_mach_dep.s (renamed from src/sparc_netbsd_mach_dep.s)0
-rw-r--r--sparc_sunos4_mach_dep.s (renamed from src/sparc_sunos4_mach_dep.s)0
-rw-r--r--specific.c4
-rw-r--r--tests/test.c12
-rw-r--r--win32_threads.c2
24 files changed, 174 insertions, 102 deletions
diff --git a/.gitignore b/.gitignore
index d8742dbb..498c6673 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,6 +1,6 @@
# Ignored files in bdwgc Git repo.
-# Binary files (in root dir, cord, src, tests):
+# Binary files (in root dir, cord, tests):
*.dll
*.exe
*.gcda
diff --git a/AUTHORS b/AUTHORS
index b7677299..88ef62c8 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -164,6 +164,7 @@ Jacob Navia <jacob.navia@jacob.remcomp.fr>
Jakub Jelinek <jakub@redhat.com>
James Clark <jjc@jclark.com>
James Dominy
+Jan Alexander Steffens <jan.steffens@gmail.com>
Jan Wielemaker <J.Wielemaker@cs.vu.nl>
Jani Kajala <jani@sumea.com>
Jean-Baptiste Nivois
diff --git a/Makefile.am b/Makefile.am
index f8057db6..1688be21 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -100,8 +100,8 @@ libgc_la_LIBADD = @addobjs@ $(THREADDLLIBS) $(UNWINDLIBS) $(ATOMIC_OPS_LIBS)
libgc_la_DEPENDENCIES = @addobjs@
libgc_la_LDFLAGS = $(extra_ldflags_libgc) -version-info 1:3:0 -no-undefined
-EXTRA_libgc_la_SOURCES = src/ia64_save_regs_in_stack.s src/sparc_mach_dep.S \
- src/sparc_netbsd_mach_dep.s src/sparc_sunos4_mach_dep.s
+EXTRA_libgc_la_SOURCES = ia64_save_regs_in_stack.s sparc_mach_dep.S \
+ sparc_netbsd_mach_dep.s sparc_sunos4_mach_dep.s
# C++ Interface
diff --git a/Makefile.direct b/Makefile.direct
index d64598b6..8ab80e8b 100644
--- a/Makefile.direct
+++ b/Makefile.direct
@@ -108,8 +108,8 @@ SRCS= $(CSRCS) \
include/gc_config_macros.h include/private/pthread_support.h \
include/private/pthread_stop_world.h include/private/darwin_semaphore.h \
include/private/darwin_stop_world.h include/private/thread_local_alloc.h \
- src/ia64_save_regs_in_stack.s src/sparc_mach_dep.S \
- src/sparc_netbsd_mach_dep.s src/sparc_sunos4_mach_dep.s $(CORD_SRCS)
+ ia64_save_regs_in_stack.s sparc_mach_dep.S \
+ sparc_netbsd_mach_dep.s sparc_sunos4_mach_dep.s $(CORD_SRCS)
DOC_FILES= README.QUICK TODO doc/README.Mac doc/README.OS2 \
doc/README.amiga doc/README.cords doc/debugging.html \
@@ -309,17 +309,17 @@ dyn_test:
# gcc -shared -Wl,-soname=libgc.so.0 -o libgc.so.0 $(LIBOBJS) dyn_load.lo
# touch liblinuxgc.so
-mach_dep.o: $(srcdir)/mach_dep.c $(srcdir)/src/sparc_mach_dep.S \
- $(srcdir)/src/sparc_sunos4_mach_dep.s \
- $(srcdir)/src/ia64_save_regs_in_stack.s \
- $(srcdir)/src/sparc_netbsd_mach_dep.s $(UTILS)
+mach_dep.o: $(srcdir)/mach_dep.c $(srcdir)/sparc_mach_dep.S \
+ $(srcdir)/sparc_sunos4_mach_dep.s \
+ $(srcdir)/ia64_save_regs_in_stack.s \
+ $(srcdir)/sparc_netbsd_mach_dep.s $(UTILS)
rm -f mach_dep.o
- ./if_mach SPARC SOLARIS $(CC) -c -o mach_dep2.o $(srcdir)/src/sparc_mach_dep.S
- ./if_mach SPARC OPENBSD $(AS) -o mach_dep2.o $(srcdir)/src/sparc_sunos4_mach_dep.s
- ./if_mach SPARC NETBSD $(AS) -o mach_dep2.o $(srcdir)/src/sparc_netbsd_mach_dep.s
+ ./if_mach SPARC SOLARIS $(CC) -c -o mach_dep2.o $(srcdir)/sparc_mach_dep.S
+ ./if_mach SPARC OPENBSD $(AS) -o mach_dep2.o $(srcdir)/sparc_sunos4_mach_dep.s
+ ./if_mach SPARC NETBSD $(AS) -o mach_dep2.o $(srcdir)/sparc_netbsd_mach_dep.s
./if_mach SPARC "" $(CC) -c -o mach_dep1.o $(SPECIALCFLAGS) $(srcdir)/mach_dep.c
./if_mach SPARC "" ld -r -o mach_dep.o mach_dep1.o mach_dep2.o
- ./if_mach IA64 "" as $(AS_ABI_FLAG) -o ia64_save_regs_in_stack.o $(srcdir)/src/ia64_save_regs_in_stack.s
+ ./if_mach IA64 "" as $(AS_ABI_FLAG) -o ia64_save_regs_in_stack.o $(srcdir)/ia64_save_regs_in_stack.s
./if_mach IA64 "" $(CC) -c -o mach_dep1.o $(SPECIALCFLAGS) $(srcdir)/mach_dep.c
./if_mach IA64 "" ld -r -o mach_dep.o mach_dep1.o ia64_save_regs_in_stack.o
./if_not_there mach_dep.o $(CC) -c $(SPECIALCFLAGS) $(srcdir)/mach_dep.c
diff --git a/cord/cord.am b/cord/cord.am
index 7d3fbe55..7793ec8f 100644
--- a/cord/cord.am
+++ b/cord/cord.am
@@ -22,4 +22,7 @@ EXTRA_DIST += \
cord/tests/de_win.h \
cord/tests/de_win.rc
-pkginclude_HEADERS += include/cord.h
+pkginclude_HEADERS += \
+ include/cord.h \
+ include/cord_pos.h \
+ include/ec.h
diff --git a/cord/tests/cordtest.c b/cord/tests/cordtest.c
index 6f14bc00..906f739d 100644
--- a/cord/tests/cordtest.c
+++ b/cord/tests/cordtest.c
@@ -206,8 +206,6 @@ void test_extras(void)
#if defined(__DJGPP__) || defined(__STRICT_ANSI__)
/* snprintf is missing in DJGPP (v2.0.3) */
-# define GC_SNPRINTF sprintf
-# define GC_SNPRINTF_BUFSZ_ARG(bufsz) /* empty */
#else
# if defined(_MSC_VER)
# if defined(_WIN32_WCE)
@@ -219,7 +217,6 @@ void test_extras(void)
# else
# define GC_SNPRINTF snprintf
# endif
-# define GC_SNPRINTF_BUFSZ_ARG(bufsz) (bufsz),
#endif
void test_printf(void)
@@ -244,8 +241,12 @@ void test_printf(void)
x = CORD_cat(x,x);
if (CORD_sprintf(&result, "->%-120.78r!\n", x) != 124)
ABORT("CORD_sprintf failed 3");
- (void)GC_SNPRINTF(result2, GC_SNPRINTF_BUFSZ_ARG(sizeof(result2))
- "->%-120.78s!\n", CORD_to_char_star(x));
+# ifdef GC_SNPRINTF
+ (void)GC_SNPRINTF(result2, sizeof(result2), "->%-120.78s!\n",
+ CORD_to_char_star(x));
+# else
+ (void)sprintf(result2, "->%-120.78s!\n", CORD_to_char_star(x));
+# endif
result2[sizeof(result2) - 1] = '\0';
if (CORD_cmp(result, result2) != 0)ABORT("CORD_sprintf goofed 5");
}
diff --git a/darwin_stop_world.c b/darwin_stop_world.c
index 04e978e1..fc747f53 100644
--- a/darwin_stop_world.c
+++ b/darwin_stop_world.c
@@ -21,6 +21,10 @@
#if defined(GC_DARWIN_THREADS)
+#include <sys/sysctl.h>
+#include <mach/machine.h>
+#include <CoreFoundation/CoreFoundation.h>
+
/* From "Inside Mac OS X - Mach-O Runtime Architecture" published by Apple
Page 49:
"The space beneath the stack pointer, where a new stack frame would normally
@@ -118,6 +122,10 @@ GC_API void GC_CALL GC_use_threads_discovery(void)
# endif
}
+#ifndef kCFCoreFoundationVersionNumber_iOS_8_0
+# define kCFCoreFoundationVersionNumber_iOS_8_0 1140.1
+#endif
+
/* Evaluates the stack range for a given thread. Returns the lower */
/* bound and sets *phi to the upper one. */
STATIC ptr_t GC_stack_range_for(ptr_t *phi, thread_act_t thread, GC_thread p,
@@ -142,13 +150,41 @@ STATIC ptr_t GC_stack_range_for(ptr_t *phi, thread_act_t thread, GC_thread p,
/* everywhere. Hence we use our own version. Alternatively, */
/* we could use THREAD_STATE_MAX (but seems to be not optimal). */
kern_return_t kern_result;
- mach_msg_type_number_t thread_state_count = GC_MACH_THREAD_STATE_COUNT;
GC_THREAD_STATE_T state;
- /* Get the thread state (registers, etc) */
- kern_result = thread_get_state(thread, GC_MACH_THREAD_STATE,
- (natural_t *)&state,
- &thread_state_count);
+# if defined(ARM32) && defined(ARM_THREAD_STATE32)
+ /* Use ARM_UNIFIED_THREAD_STATE on iOS8+ 32-bit targets and on */
+ /* 64-bit H/W (iOS7+ 32-bit mode). */
+ size_t size;
+ static cpu_type_t cputype = 0;
+
+ if (cputype == 0) {
+ sysctlbyname("hw.cputype", &cputype, &size, NULL, 0);
+ }
+ if (cputype == CPU_TYPE_ARM64
+ || kCFCoreFoundationVersionNumber
+ >= kCFCoreFoundationVersionNumber_iOS_8_0) {
+ arm_unified_thread_state_t unified_state;
+ mach_msg_type_number_t unified_thread_state_count
+ = ARM_UNIFIED_THREAD_STATE_COUNT;
+
+ kern_result = thread_get_state(thread, ARM_UNIFIED_THREAD_STATE,
+ (natural_t *)&unified_state,
+ &unified_thread_state_count);
+ if (unified_state.ash.flavor != ARM_THREAD_STATE32) {
+ ABORT("unified_state flavor should be ARM_THREAD_STATE32");
+ }
+ state = unified_state.ts_32;
+ } else
+# endif
+ /* else */ {
+ mach_msg_type_number_t thread_state_count = GC_MACH_THREAD_STATE_COUNT;
+
+ /* Get the thread state (registers, etc) */
+ kern_result = thread_get_state(thread, GC_MACH_THREAD_STATE,
+ (natural_t *)&state,
+ &thread_state_count);
+ }
# ifdef DEBUG_THREADS
GC_log_printf("thread_get_state returns value = %d\n", kern_result);
# endif
diff --git a/dyn_load.c b/dyn_load.c
index 2c866cd2..3b907185 100644
--- a/dyn_load.c
+++ b/dyn_load.c
@@ -687,8 +687,15 @@ GC_FirstDLOpenedLinkMap(void)
if( cachedResult == 0 ) {
# if defined(NETBSD) && defined(RTLD_DI_LINKMAP)
struct link_map *lm = NULL;
- if (!dlinfo(RTLD_SELF, RTLD_DI_LINKMAP, &lm))
- cachedResult = lm;
+ if (!dlinfo(RTLD_SELF, RTLD_DI_LINKMAP, &lm) && lm != NULL) {
+ /* Now lm points link_map object of libgc. Since it */
+ /* might not be the first dynamically linked object, */
+ /* try to find it (object next to the main object). */
+ while (lm->l_prev != NULL) {
+ lm = lm->l_prev;
+ }
+ cachedResult = lm->l_next;
+ }
# else
int tag;
for( dp = _DYNAMIC; (tag = dp->d_tag) != 0; dp++ ) {
diff --git a/src/ia64_save_regs_in_stack.s b/ia64_save_regs_in_stack.s
index 2b81edfa..2b81edfa 100644
--- a/src/ia64_save_regs_in_stack.s
+++ b/ia64_save_regs_in_stack.s
diff --git a/include/gc_config_macros.h b/include/gc_config_macros.h
index db8a40df..d6da7ca2 100644
--- a/include/gc_config_macros.h
+++ b/include/gc_config_macros.h
@@ -242,13 +242,17 @@
#ifndef GC_ATTR_ALLOC_SIZE
/* 'alloc_size' attribute improves __builtin_object_size correctness. */
/* Only single-argument form of 'alloc_size' attribute is used. */
-# if defined(__GNUC__) && (__GNUC__ > 4 \
- || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3 && !defined(__ICC)) \
- || __clang_major__ > 3 \
- || (__clang_major__ == 3 && __clang_minor__ >= 2))
+# ifdef __clang__
+# if __has_attribute(__alloc_size__)
+# define GC_ATTR_ALLOC_SIZE(argnum) __attribute__((__alloc_size__(argnum)))
+# else
+# define GC_ATTR_ALLOC_SIZE(argnum) /* empty */
+# endif
+# elif __GNUC__ > 4 \
+ || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3 && !defined(__ICC))
# define GC_ATTR_ALLOC_SIZE(argnum) __attribute__((__alloc_size__(argnum)))
# else
-# define GC_ATTR_ALLOC_SIZE(argnum)
+# define GC_ATTR_ALLOC_SIZE(argnum) /* empty */
# endif
#endif
diff --git a/include/include.am b/include/include.am
index 1b2a557b..0d957341 100644
--- a/include/include.am
+++ b/include/include.am
@@ -44,6 +44,7 @@ dist_noinst_HEADERS += \
include/private/gc_pmark.h \
include/private/gc_priv.h \
include/private/gcconfig.h \
+ include/private/msvc_dbg.h \
include/private/pthread_stop_world.h \
include/private/pthread_support.h \
include/private/specific.h \
diff --git a/include/private/darwin_semaphore.h b/include/private/darwin_semaphore.h
index da97b39d..62f185d6 100644
--- a/include/private/darwin_semaphore.h
+++ b/include/private/darwin_semaphore.h
@@ -34,50 +34,47 @@ typedef struct {
} sem_t;
GC_INLINE int sem_init(sem_t *sem, int pshared, int value) {
- int ret;
- if(pshared)
- ABORT("sem_init with pshared set");
+ if (pshared != 0) {
+ errno = EPERM; /* unsupported */
+ return -1;
+ }
sem->value = value;
-
- ret = pthread_mutex_init(&sem->mutex,NULL);
- if(ret < 0) return -1;
- ret = pthread_cond_init(&sem->cond,NULL);
- if(ret < 0) return -1;
+ if (pthread_mutex_init(&sem->mutex, NULL) != 0)
+ return -1;
+ if (pthread_cond_init(&sem->cond, NULL) != 0) {
+ (void)pthread_mutex_destroy(&sem->mutex);
+ return -1;
+ }
return 0;
}
GC_INLINE int sem_post(sem_t *sem) {
- if(pthread_mutex_lock(&sem->mutex) < 0)
- return -1;
+ if (pthread_mutex_lock(&sem->mutex) != 0)
+ return -1;
sem->value++;
- if(pthread_cond_signal(&sem->cond) < 0) {
- pthread_mutex_unlock(&sem->mutex);
- return -1;
+ if (pthread_cond_signal(&sem->cond) != 0) {
+ (void)pthread_mutex_unlock(&sem->mutex);
+ return -1;
}
- if(pthread_mutex_unlock(&sem->mutex) < 0)
- return -1;
- return 0;
+ return pthread_mutex_unlock(&sem->mutex) != 0 ? -1 : 0;
}
GC_INLINE int sem_wait(sem_t *sem) {
- if(pthread_mutex_lock(&sem->mutex) < 0)
- return -1;
- while(sem->value == 0) {
- pthread_cond_wait(&sem->cond,&sem->mutex);
+ if (pthread_mutex_lock(&sem->mutex) != 0)
+ return -1;
+ while (sem->value == 0) {
+ if (pthread_cond_wait(&sem->cond, &sem->mutex) != 0) {
+ (void)pthread_mutex_unlock(&sem->mutex);
+ return -1;
+ }
}
sem->value--;
- if(pthread_mutex_unlock(&sem->mutex) < 0)
- return -1;
- return 0;
+ return pthread_mutex_unlock(&sem->mutex) != 0 ? -1 : 0;
}
GC_INLINE int sem_destroy(sem_t *sem) {
- int ret;
- ret = pthread_cond_destroy(&sem->cond);
- if(ret < 0) return -1;
- ret = pthread_mutex_destroy(&sem->mutex);
- if(ret < 0) return -1;
- return 0;
+ return pthread_cond_destroy(&sem->cond) != 0
+ || pthread_mutex_destroy(&sem->mutex) != 0 ? -1 : 0;
}
#endif
diff --git a/include/private/gc_priv.h b/include/private/gc_priv.h
index 113391f2..c4751d9b 100644
--- a/include/private/gc_priv.h
+++ b/include/private/gc_priv.h
@@ -564,8 +564,6 @@ GC_EXTERN GC_warn_proc GC_current_warn_proc;
# if defined(POWERPC)
# if CPP_WORDSZ == 32
# define GC_THREAD_STATE_T ppc_thread_state_t
-# define GC_MACH_THREAD_STATE PPC_THREAD_STATE
-# define GC_MACH_THREAD_STATE_COUNT PPC_THREAD_STATE_COUNT
# else
# define GC_THREAD_STATE_T ppc_thread_state64_t
# define GC_MACH_THREAD_STATE PPC_THREAD_STATE64
@@ -588,20 +586,18 @@ GC_EXTERN GC_warn_proc GC_current_warn_proc;
# define GC_MACH_THREAD_STATE x86_THREAD_STATE64
# define GC_MACH_THREAD_STATE_COUNT x86_THREAD_STATE64_COUNT
# endif
-# else
-# if defined(ARM32) && defined(ARM_UNIFIED_THREAD_STATE)
-# define GC_THREAD_STATE_T arm_unified_thread_state_t
-# define GC_MACH_THREAD_STATE ARM_UNIFIED_THREAD_STATE
-# define GC_MACH_THREAD_STATE_COUNT ARM_UNIFIED_THREAD_STATE_COUNT
-# elif defined(ARM32)
-# define GC_THREAD_STATE_T arm_thread_state_t
-# ifdef ARM_MACHINE_THREAD_STATE_COUNT
-# define GC_MACH_THREAD_STATE ARM_MACHINE_THREAD_STATE
-# define GC_MACH_THREAD_STATE_COUNT ARM_MACHINE_THREAD_STATE_COUNT
-# endif
-# else
-# error define GC_THREAD_STATE_T
+# elif defined(ARM32) && defined(ARM_UNIFIED_THREAD_STATE)
+# define GC_THREAD_STATE_T arm_unified_thread_state_t
+# define GC_MACH_THREAD_STATE ARM_UNIFIED_THREAD_STATE
+# define GC_MACH_THREAD_STATE_COUNT ARM_UNIFIED_THREAD_STATE_COUNT
+# elif defined(ARM32)
+# define GC_THREAD_STATE_T arm_thread_state_t
+# ifdef ARM_MACHINE_THREAD_STATE_COUNT
+# define GC_MACH_THREAD_STATE ARM_MACHINE_THREAD_STATE
+# define GC_MACH_THREAD_STATE_COUNT ARM_MACHINE_THREAD_STATE_COUNT
# endif
+# else
+# error define GC_THREAD_STATE_T
# endif
# ifndef GC_MACH_THREAD_STATE
# define GC_MACH_THREAD_STATE MACHINE_THREAD_STATE
diff --git a/include/private/gcconfig.h b/include/private/gcconfig.h
index 72bef854..989a7343 100644
--- a/include/private/gcconfig.h
+++ b/include/private/gcconfig.h
@@ -1375,6 +1375,11 @@
# define PREFETCH_FOR_WRITE(x) \
__asm__ __volatile__ ("prefetchw %0" : : "m"(*(char *)(x)))
# endif
+# if defined(__GLIBC__)
+ /* Workaround lock elision implementation for some glibc. */
+# define GLIBC_2_19_TSX_BUG
+# include <gnu/libc-version.h> /* for gnu_get_libc_version() */
+# endif
# endif
# ifdef CYGWIN32
# define OS_TYPE "CYGWIN32"
@@ -2015,9 +2020,14 @@
# endif
# ifdef AARCH64
-# define CPP_WORDSZ 64
# define MACH_TYPE "AARCH64"
-# define ALIGNMENT 8
+# ifdef __ILP32__
+# define CPP_WORDSZ 32
+# define ALIGNMENT 4
+# else
+# define CPP_WORDSZ 64
+# define ALIGNMENT 8
+# endif
# ifndef HBLKSIZE
# define HBLKSIZE 4096
# endif
diff --git a/include/private/pthread_support.h b/include/private/pthread_support.h
index 017f1941..525a9aac 100644
--- a/include/private/pthread_support.h
+++ b/include/private/pthread_support.h
@@ -148,8 +148,6 @@ GC_INNER_PTHRSTART GC_thread GC_start_rtn_prepare_thread(
struct GC_stack_base *sb, void *arg);
GC_INNER_PTHRSTART void GC_thread_exit_proc(void *);
-GC_INNER void GC_setup_mark_lock(void);
-
#endif /* GC_PTHREADS && !GC_WIN32_THREADS */
#endif /* GC_PTHREAD_SUPPORT_H */
diff --git a/misc.c b/misc.c
index 32cbe249..6c01404e 100644
--- a/misc.c
+++ b/misc.c
@@ -866,9 +866,14 @@ GC_API void GC_CALL GC_init(void)
# ifdef SN_TARGET_PS3
{
pthread_mutexattr_t mattr;
- pthread_mutexattr_init(&mattr);
- pthread_mutex_init(&GC_allocate_ml, &mattr);
- pthread_mutexattr_destroy(&mattr);
+
+ if (0 != pthread_mutexattr_init(&mattr)) {
+ ABORT("pthread_mutexattr_init failed");
+ }
+ if (0 != pthread_mutex_init(&GC_allocate_ml, &mattr)) {
+ ABORT("pthread_mutex_init failed");
+ }
+ (void)pthread_mutexattr_destroy(&mattr);
}
# endif
# endif /* THREADS */
@@ -888,9 +893,6 @@ GC_API void GC_CALL GC_init(void)
/* else */ InitializeCriticalSection (&GC_allocate_ml);
}
# endif /* GC_WIN32_THREADS */
-# if defined(GC_PTHREADS) && !defined(GC_WIN32_THREADS)
- GC_setup_mark_lock();
-# endif /* GC_PTHREADS */
# if (defined(MSWIN32) || defined(MSWINCE)) && defined(THREADS)
InitializeCriticalSection(&GC_write_cs);
# endif
diff --git a/os_dep.c b/os_dep.c
index 98e2af98..a362498a 100644
--- a/os_dep.c
+++ b/os_dep.c
@@ -1201,13 +1201,13 @@ GC_INNER word GC_page_size = 0;
if (pthread_getattr_np(pthread_self(), &attr) == 0) {
if (pthread_attr_getstack(&attr, &stackaddr, &size) == 0
&& stackaddr != NULL) {
- pthread_attr_destroy(&attr);
+ (void)pthread_attr_destroy(&attr);
# ifdef STACK_GROWS_DOWN
stackaddr = (char *)stackaddr + size;
# endif
return (ptr_t)stackaddr;
}
- pthread_attr_destroy(&attr);
+ (void)pthread_attr_destroy(&attr);
}
WARN("pthread_getattr_np or pthread_attr_getstack failed"
" for main thread\n", 0);
@@ -1284,7 +1284,7 @@ GC_INNER word GC_page_size = 0;
if (pthread_attr_getstack(&attr, &(b -> mem_base), &size) != 0) {
ABORT("pthread_attr_getstack failed");
}
- pthread_attr_destroy(&attr);
+ (void)pthread_attr_destroy(&attr);
# ifdef STACK_GROWS_DOWN
b -> mem_base = (char *)(b -> mem_base) + size;
# endif
@@ -4185,7 +4185,7 @@ GC_INNER void GC_dirty_init(void)
/* This will call the real pthread function, not our wrapper */
if (pthread_create(&thread, &attr, GC_mprotect_thread, NULL) != 0)
ABORT("pthread_create failed");
- pthread_attr_destroy(&attr);
+ (void)pthread_attr_destroy(&attr);
/* Setup the sigbus handler for ignoring the meaningless SIGBUSs */
# ifdef BROKEN_EXCEPTION_HANDLING
diff --git a/pthread_support.c b/pthread_support.c
index db86ec84..2fca3602 100644
--- a/pthread_support.c
+++ b/pthread_support.c
@@ -445,7 +445,7 @@ start_mark_threads(void)
}
}
GC_markers_m1 = i;
- pthread_attr_destroy(&attr);
+ (void)pthread_attr_destroy(&attr);
GC_COND_LOG_PRINTF("Started %d mark helper threads\n", GC_markers_m1);
}
@@ -1031,6 +1031,10 @@ static void fork_child_proc(void)
ptr_t *startp, ptr_t *endp);
#endif
+#ifdef PARALLEL_MARK
+ static void setup_mark_lock(void);
+#endif
+
/* We hold the allocation lock. */
GC_INNER void GC_thr_init(void)
{
@@ -1143,6 +1147,7 @@ GC_INNER void GC_thr_init(void)
} else {
/* Disable true incremental collection, but generational is OK. */
GC_time_limit = GC_TIME_UNLIMITED;
+ setup_mark_lock();
/* If we are using a parallel marker, actually start helper threads. */
start_mark_threads();
}
@@ -1701,14 +1706,17 @@ GC_API int WRAP_FUNC(pthread_create)(pthread_t *new_thread,
{
size_t stack_size = 0;
if (NULL != attr) {
- pthread_attr_getstacksize(attr, &stack_size);
+ if (pthread_attr_getstacksize(attr, &stack_size) != 0)
+ ABORT("pthread_attr_getstacksize failed");
}
if (0 == stack_size) {
pthread_attr_t my_attr;
- pthread_attr_init(&my_attr);
- pthread_attr_getstacksize(&my_attr, &stack_size);
- pthread_attr_destroy(&my_attr);
+ if (pthread_attr_init(&my_attr) != 0)
+ ABORT("pthread_attr_init failed");
+ if (pthread_attr_getstacksize(&my_attr, &stack_size) != 0)
+ ABORT("pthread_attr_getstacksize failed");
+ (void)pthread_attr_destroy(&my_attr);
}
/* On Solaris 10, with default attr initialization, */
/* stack_size remains 0. Fudge it. */
@@ -2010,7 +2018,7 @@ static pthread_cond_t builder_cv = PTHREAD_COND_INITIALIZER;
}
#endif /* GLIBC_2_19_TSX_BUG */
-GC_INNER void GC_setup_mark_lock(void)
+static void setup_mark_lock(void)
{
# ifdef GLIBC_2_19_TSX_BUG
pthread_mutexattr_t mattr;
@@ -2023,13 +2031,13 @@ GC_INNER void GC_setup_mark_lock(void)
if (0 != pthread_mutexattr_init(&mattr)) {
ABORT("pthread_mutexattr_init failed");
}
- if (0 != pthread_mutexattr_settype(&mattr, PTHREAD_MUTEX_ERRORCHECK)) {
+ if (0 != pthread_mutexattr_settype(&mattr, PTHREAD_MUTEX_NORMAL)) {
ABORT("pthread_mutexattr_settype failed");
}
if (0 != pthread_mutex_init(&mark_mutex, &mattr)) {
ABORT("pthread_mutex_init failed");
}
- pthread_mutexattr_destroy(&mattr);
+ (void)pthread_mutexattr_destroy(&mattr);
}
# endif
}
diff --git a/src/sparc_mach_dep.S b/sparc_mach_dep.S
index d204dc43..d204dc43 100644
--- a/src/sparc_mach_dep.S
+++ b/sparc_mach_dep.S
diff --git a/src/sparc_netbsd_mach_dep.s b/sparc_netbsd_mach_dep.s
index 14feb15e..14feb15e 100644
--- a/src/sparc_netbsd_mach_dep.s
+++ b/sparc_netbsd_mach_dep.s
diff --git a/src/sparc_sunos4_mach_dep.s b/sparc_sunos4_mach_dep.s
index 923f5eaa..923f5eaa 100644
--- a/src/sparc_sunos4_mach_dep.s
+++ b/sparc_sunos4_mach_dep.s
diff --git a/specific.c b/specific.c
index 3657fbad..ba23e47d 100644
--- a/specific.c
+++ b/specific.c
@@ -26,12 +26,14 @@ static const tse invalid_tse = {INVALID_QTID, 0, 0, INVALID_THREADID};
GC_INNER int GC_key_create_inner(tsd ** key_ptr)
{
int i;
+ int ret;
tsd * result = (tsd *)MALLOC_CLEAR(sizeof(tsd));
/* A quick alignment check, since we need atomic stores */
GC_ASSERT((word)(&invalid_tse.next) % sizeof(tse *) == 0);
if (0 == result) return ENOMEM;
- pthread_mutex_init(&(result -> lock), NULL);
+ ret = pthread_mutex_init(&result->lock, NULL);
+ if (ret != 0) return ret;
for (i = 0; i < TS_CACHE_SIZE; ++i) {
result -> cache[i] = (/* no const */ tse *)&invalid_tse;
}
diff --git a/tests/test.c b/tests/test.c
index 6f412c8f..446a6b88 100644
--- a/tests/test.c
+++ b/tests/test.c
@@ -1874,11 +1874,17 @@ int main(void)
# endif
GC_COND_INIT();
- pthread_attr_init(&attr);
+ if ((code = pthread_attr_init(&attr)) != 0) {
+ GC_printf("pthread_attr_init failed, error=%d\n", code);
+ FAIL;
+ }
# if defined(GC_IRIX_THREADS) || defined(GC_FREEBSD_THREADS) \
|| defined(GC_DARWIN_THREADS) || defined(GC_AIX_THREADS) \
|| defined(GC_OPENBSD_THREADS)
- pthread_attr_setstacksize(&attr, 1000000);
+ if ((code = pthread_attr_setstacksize(&attr, 1000 * 1024)) != 0) {
+ GC_printf("pthread_attr_setstacksize failed, error=%d\n", code);
+ FAIL;
+ }
# endif
n_tests = 0;
# if (defined(MPROTECT_VDB)) && !defined(REDIRECT_MALLOC) \
@@ -1916,7 +1922,7 @@ int main(void)
}
check_heap_stats();
(void)fflush(stdout);
- pthread_attr_destroy(&attr);
+ (void)pthread_attr_destroy(&attr);
# ifdef PTW32_STATIC_LIB
pthread_win32_thread_detach_np ();
pthread_win32_process_detach_np ();
diff --git a/win32_threads.c b/win32_threads.c
index fc65743a..31d33b65 100644
--- a/win32_threads.c
+++ b/win32_threads.c
@@ -1776,7 +1776,7 @@ GC_INNER void GC_get_next_stack(char *start, char *limit,
}
}
GC_markers_m1 = i;
- pthread_attr_destroy(&attr);
+ (void)pthread_attr_destroy(&attr);
GC_COND_LOG_PRINTF("Started %d mark helper threads\n", GC_markers_m1);
}