* .cvsignore (initsecondarythread, test_cpp): Add.
* os_dep.c (GC_linux_stack_base): Rename to
GC_linux_main_stack_base.
* os_dep.c (GC_freebsd_stack_base): Rename to
GC_freebsd_main_stack_base; adjust error message.
* pthread_stop_world.c (GC_stop_init): Use GC_SEM_INIT_PSHARED
as an argument for sem_init().
* pthread_support.c (pthread_create): Ditto.
* pthread_support.c (pthread_create): Abort in case sem_init()
fails.
* include/private/gc_priv.h (GC_SEM_INIT_PSHARED): Define.
* tests/initsecondarythread.c: Include gcconfig.h; call GC_INIT
from main() if it should be done from the primordial thread only.
config.status
gctest
hugetest
+initsecondarythread
leaktest
libcord.la
libgc.la
smashtest
staticrootstest
threadleaktest
+test_cpp
2011-04-26 Ivan Maidanski <ivmai@mail.ru>
+ * .cvsignore (initsecondarythread, test_cpp): Add.
+ * os_dep.c (GC_linux_stack_base): Rename to
+ GC_linux_main_stack_base.
+ * os_dep.c (GC_freebsd_stack_base): Rename to
+ GC_freebsd_main_stack_base; adjust error message.
+ * pthread_stop_world.c (GC_stop_init): Use GC_SEM_INIT_PSHARED
+ as an argument for sem_init().
+ * pthread_support.c (pthread_create): Ditto.
+ * pthread_support.c (pthread_create): Abort in case sem_init()
+ fails.
+ * include/private/gc_priv.h (GC_SEM_INIT_PSHARED): Define.
+ * tests/initsecondarythread.c: Include gcconfig.h; call GC_INIT
+ from main() if it should be done from the primordial thread only.
+
+2011-04-26 Ivan Maidanski <ivmai@mail.ru>
+
* alloc.c: Don't include sys/types.h for ArmCC.
* dyn_load.c: Ditto.
* os_dep.c: Ditto.
# endif
#endif /* GC_PTHREADS && !SIG_SUSPEND */
+#if defined(GC_PTHREADS) && !defined(GC_SEM_INIT_PSHARED)
+# define GC_SEM_INIT_PSHARED 0
+#endif
+
/* Some macros for setjmp that works across signal handlers */
/* were possible, and a couple of routines to facilitate */
/* catching accesses to bad addresses when that's */
}
# endif /* IA64 */
- STATIC ptr_t GC_linux_stack_base(void)
+ STATIC ptr_t GC_linux_main_stack_base(void)
{
/* We read the stack base value from /proc/self/stat. We do this */
/* using direct I/O system calls in order to avoid calling malloc */
# include <sys/types.h>
# include <sys/sysctl.h>
- STATIC ptr_t GC_freebsd_stack_base(void)
+ STATIC ptr_t GC_freebsd_main_stack_base(void)
{
int nm[2] = {CTL_KERN, KERN_USRSTACK};
ptr_t base;
size_t len = sizeof(ptr_t);
int r = sysctl(nm, 2, &base, &len, NULL, 0);
-
- if (r) ABORT("Error getting stack base");
-
+ if (r) ABORT("Error getting main stack base");
return base;
}
#endif /* FREEBSD_STACKBOTTOM */
# endif
# endif /* HEURISTIC1 */
# ifdef LINUX_STACKBOTTOM
- result = GC_linux_stack_base();
+ result = GC_linux_main_stack_base();
# endif
# ifdef FREEBSD_STACKBOTTOM
- result = GC_freebsd_stack_base();
+ result = GC_freebsd_main_stack_base();
# endif
# ifdef HEURISTIC2
# ifdef STACK_GROWS_DOWN
*/
#ifndef SIG_THR_RESTART
-# if defined(GC_HPUX_THREADS) || defined(GC_OSF1_THREADS) || defined(GC_NETBSD_THREADS)
+# if defined(GC_HPUX_THREADS) || defined(GC_OSF1_THREADS) \
+ || defined(GC_NETBSD_THREADS)
# ifdef _SIGRTMIN
# define SIG_THR_RESTART _SIGRTMIN + 5
# else
# if !defined(GC_OPENBSD_THREADS) && !defined(NACL)
struct sigaction act;
- if (sem_init(&GC_suspend_ack_sem, 0, 0) != 0)
+ if (sem_init(&GC_suspend_ack_sem, GC_SEM_INIT_PSHARED, 0) != 0)
ABORT("sem_init failed");
# ifdef GC_NETBSD_THREADS_WORKAROUND
- if (sem_init(&GC_restart_ack_sem, 0, 0) != 0)
+ if (sem_init(&GC_restart_ack_sem, GC_SEM_INIT_PSHARED, 0) != 0)
ABORT("sem_init failed");
# endif
(si = (struct start_info *)
(*GC_get_oom_fn())(sizeof(struct start_info))) == 0)
return(ENOMEM);
- sem_init(&(si -> registered), 0, 0);
+ if (sem_init(&(si -> registered), GC_SEM_INIT_PSHARED, 0) != 0)
+ ABORT("sem_init failed");
+
si -> start_routine = start_routine;
si -> arg = arg;
LOCK();
static void *thread(void *arg)
{
- GC_INIT ();
- GC_MALLOC (123);
- GC_MALLOC (12345);
- return NULL;
+ GC_INIT();
+ GC_MALLOC(123);
+ GC_MALLOC(12345);
+ return NULL;
}
+#include "private/gcconfig.h"
+
int main(void)
{
- pthread_t t;
- pthread_create (&t, NULL, thread, NULL);
- pthread_join (t, NULL);
- return 0;
+ pthread_t t;
+# if !(defined(BEOS) || defined(MSWIN32) || defined(MSWINCE) \
+ || defined(CYGWIN32) || defined(GC_OPENBSD_THREADS) \
+ || (defined(DARWIN) && !defined(NO_PTHREAD_GET_STACKADDR_NP)) \
+ || (defined(LINUX) && !defined(NACL)) \
+ || (defined(GC_SOLARIS_THREADS) && !defined(_STRICT_STDC)) \
+ || (!defined(STACKBOTTOM) && (defined(HEURISTIC1) \
+ || (!defined(LINUX_STACKBOTTOM) && !defined(FREEBSD_STACKBOTTOM)))))
+ /* GC_INIT() must be called from main thread only. */
+ GC_INIT();
+# endif
+ pthread_create (&t, NULL, thread, NULL);
+ pthread_join (t, NULL);
+ return 0;
}