Permalink
Browse files

Add WIP boehm-gc update.

needs more work in pthread_stop_world.c, currently the regress tests hang.
since pthread_{resume,suspend}_np() have been removed this code should
probably be rewritten..
  • Loading branch information...
1 parent a72f5af commit 9c16b47f8ac0fc492272a1e492833ffbda7ec3e0 @jasperla committed Jul 4, 2012
View
@@ -0,0 +1,62 @@
+# $OpenBSD: Makefile,v 1.45 2012/04/30 15:33:16 kurt Exp $
+
+COMMENT-main= garbage collection and memory leak detection for C and C++
+COMMENT-atomic= access to hardware provided atomic memory operations
+
+VERSION= 7.2c
+DISTNAME= gc-${VERSION}
+PKGNAME-atomic= libatomic_ops-1.2
+PKGNAME-main= boehm-gc-${VERSION}
+
+MULTI_PACKAGES= -main -atomic
+
+SHARED_LIBS += gc 4.0 # .1.3
+SHARED_LIBS += cord 3.0 # .1.3
+
+CATEGORIES= devel
+
+MASTER_SITES= ${HOMEPAGE}gc_source/
+
+HOMEPAGE= http://www.hpl.hp.com/personal/Hans_Boehm/gc/
+
+MAINTAINER= Todd T. Fries <todd@openbsd.org>
+
+# currently works only on most ELF archs
+NOT_FOR_ARCHS= m68k m88k vax mips64 mips64el
+
+# X11-like: http://www.hpl.hp.com/personal/Hans_Boehm/gc/license.txt
+PERMIT_PACKAGE_CDROM= Yes
+PERMIT_PACKAGE_FTP= Yes
+PERMIT_DISTFILES_CDROM= Yes
+PERMIT_DISTFILES_FTP= Yes
+
+USE_LIBTOOL= Yes
+
+CONFIGURE_STYLE=gnu
+
+CONFIGURE_ARGS= ${CONFIGURE_SHARED} \
+ --enable-threads=pthreads
+
+WRKDIST= ${WRKDIR}/gc-7.2
+
+pre-configure:
+ ${SUBST_CMD} ${WRKSRC}/doc/gc.man
+
+# clean distributed objects and libs and rebuild
+pre-build:
+ @cd ${WRKBUILD}/libatomic_ops && ${SETENV} ${MAKE_ENV} \
+ ${MAKE_PROGRAM} ${MAKE_FLAGS} clean all
+
+aliases= malloc malloc_atomic free realloc enable_incremental \
+ register_finalizer malloc_ignore_off_page \
+ malloc_atomic_ignore_off_page set_warn_proc
+
+post-install:
+ @cd ${WRKBUILD}/libatomic_ops && ${SETENV} ${MAKE_ENV} \
+ ${MAKE_PROGRAM} ${ALL_FAKE_FLAGS} install
+ ${INSTALL_DATA} ${WRKSRC}/doc/gc.man ${PREFIX}/man/man3/gc.3
+.for i in ${aliases}
+ ln -s gc.3 ${PREFIX}/man/man3/GC_$i.3
+.endfor
+
+.include <bsd.port.mk>
View
@@ -0,0 +1,5 @@
+MD5 (gc-7.2c.tar.gz) = 7dmcZBdKHzsQpHSz5MdGNA==
+RMD160 (gc-7.2c.tar.gz) = 5+QhmH+MrCQHgb/WW589RBe/ZxE=
+SHA1 (gc-7.2c.tar.gz) = GMWxqpKJoS/q087tqP3IH07QiWQ=
+SHA256 (gc-7.2c.tar.gz) = UQnAuzhZHXL4OHsrC+NF9P5Oks+ojhU0MdtaTdEQgXw=
+SIZE (gc-7.2c.tar.gz) = 1262215
@@ -0,0 +1,177 @@
+$OpenBSD$
+--- pthread_stop_world.c.orig Fri May 11 19:09:00 2012
++++ pthread_stop_world.c Wed Jul 4 13:08:33 2012
+@@ -17,6 +17,10 @@
+
+ #include "private/pthread_support.h"
+
++#ifdef GC_OPENBSD_THREADS
++#include <sys/errno.h>
++#endif
++
+ #if defined(GC_PTHREADS) && !defined(GC_WIN32_THREADS) && \
+ !defined(GC_DARWIN_THREADS)
+
+@@ -35,7 +39,7 @@ GC_INNER __thread GC_thread GC_nacl_gc_thread_self = N
+ int GC_nacl_thread_parked[MAX_NACL_GC_THREADS];
+ int GC_nacl_thread_used[MAX_NACL_GC_THREADS];
+
+-#elif !defined(GC_OPENBSD_THREADS)
++#else
+
+ #include <signal.h>
+ #include <semaphore.h>
+@@ -218,6 +222,7 @@ STATIC void GC_suspend_handler_inner(ptr_t sig_arg, vo
+ /* of a thread which holds the allocation lock in order */
+ /* to stop the world. Thus concurrent modification of the */
+ /* data structure is impossible. */
++#ifndef GC_OPENBSD_THREADS
+ if (me -> stop_info.last_stop_count == my_stop_count) {
+ /* Duplicate signal. OK if we are retrying. */
+ if (!GC_retry_signals) {
+@@ -226,6 +231,7 @@ STATIC void GC_suspend_handler_inner(ptr_t sig_arg, vo
+ RESTORE_CANCEL(cancel_state);
+ return;
+ }
++#endif
+ # ifdef SPARC
+ me -> stop_info.stack_ptr = GC_save_regs_in_stack();
+ # else
+@@ -239,8 +245,9 @@ STATIC void GC_suspend_handler_inner(ptr_t sig_arg, vo
+ /* thread has been stopped. Note that sem_post() is */
+ /* the only async-signal-safe primitive in LinuxThreads. */
+ sem_post(&GC_suspend_ack_sem);
++#ifndef GC_OPENBSD_THREADS
+ me -> stop_info.last_stop_count = my_stop_count;
+-
++#endif
+ /* Wait until that thread tells us to restart by sending */
+ /* this thread a SIG_THR_RESTART signal. */
+ /* SIG_THR_RESTART should be masked at this point. Thus */
+@@ -298,7 +305,7 @@ STATIC void GC_restart_handler(int sig)
+ # endif
+ }
+
+-#endif /* !GC_OPENBSD_THREADS && !NACL */
++#endif /* !NACL */
+
+ #ifdef IA64
+ # define IF_IA64(x) x
+@@ -422,9 +429,7 @@ STATIC int GC_suspend_all(void)
+
+ # ifndef NACL
+ GC_thread p;
+-# ifndef GC_OPENBSD_THREADS
+- int result;
+-# endif
++ int result;
+ pthread_t self = pthread_self();
+
+ # ifdef DEBUG_THREADS
+@@ -436,26 +441,15 @@ STATIC int GC_suspend_all(void)
+ if (!THREAD_EQUAL(p -> id, self)) {
+ if (p -> flags & FINISHED) continue;
+ if (p -> thread_blocked) /* Will wait */ continue;
+-# ifndef GC_OPENBSD_THREADS
+- if (p -> stop_info.last_stop_count == GC_stop_count) continue;
+- n_live_threads++;
+-# endif
++#ifndef GC_OPENBSD_THREADS
++ if (p -> stop_info.last_stop_count == GC_stop_count) continue;
++#endif
++ n_live_threads++;
+ # ifdef DEBUG_THREADS
+ GC_log_printf("Sending suspend signal to 0x%x\n",
+ (unsigned)(p -> id));
+ # endif
+
+-# ifdef GC_OPENBSD_THREADS
+- if (pthread_suspend_np(p -> id) != 0)
+- ABORT("pthread_suspend_np failed");
+- /* This will only work for userland pthreads. It will */
+- /* fail badly on rthreads. Perhaps we should consider */
+- /* a pthread_sp_np() function that returns the stack */
+- /* pointer for a suspended thread and implement in both */
+- /* pthreads and rthreads. */
+- p -> stop_info.stack_ptr =
+- *(ptr_t *)((char *)p -> id + UTHREAD_SP_OFFSET);
+-# else
+ # ifndef PLATFORM_ANDROID
+ result = pthread_kill(p -> id, SIG_SUSPEND);
+ # else
+@@ -471,7 +465,6 @@ STATIC int GC_suspend_all(void)
+ default:
+ ABORT("pthread_kill failed");
+ }
+-# endif
+ }
+ }
+ }
+@@ -524,7 +517,7 @@ STATIC int GC_suspend_all(void)
+
+ GC_INNER void GC_stop_world(void)
+ {
+-# if !defined(GC_OPENBSD_THREADS) && !defined(NACL)
++# if !defined(NACL)
+ int i;
+ int n_live_threads;
+ int code;
+@@ -546,7 +539,7 @@ GC_INNER void GC_stop_world(void)
+ }
+ # endif /* PARALLEL_MARK */
+
+-# if defined(GC_OPENBSD_THREADS) || defined(NACL)
++# if defined(NACL)
+ (void)GC_suspend_all();
+ # else
+ AO_store(&GC_stop_count, GC_stop_count+1);
+@@ -738,10 +731,8 @@ GC_INNER void GC_start_world(void)
+ pthread_t self = pthread_self();
+ register int i;
+ register GC_thread p;
+-# ifndef GC_OPENBSD_THREADS
+- register int n_live_threads = 0;
+- register int result;
+-# endif
++ register int n_live_threads = 0;
++ register int result;
+ # ifdef GC_NETBSD_THREADS_WORKAROUND
+ int code;
+ # endif
+@@ -750,26 +741,18 @@ GC_INNER void GC_start_world(void)
+ GC_log_printf("World starting\n");
+ # endif
+
+-# ifndef GC_OPENBSD_THREADS
+- AO_store(&GC_world_is_stopped, FALSE);
+-# endif
++ AO_store(&GC_world_is_stopped, FALSE);
+ for (i = 0; i < THREAD_TABLE_SZ; i++) {
+ for (p = GC_threads[i]; p != 0; p = p -> next) {
+ if (!THREAD_EQUAL(p -> id, self)) {
+ if (p -> flags & FINISHED) continue;
+ if (p -> thread_blocked) continue;
+-# ifndef GC_OPENBSD_THREADS
+- n_live_threads++;
+-# endif
++ n_live_threads++;
+ # ifdef DEBUG_THREADS
+ GC_log_printf("Sending restart signal to 0x%x\n",
+ (unsigned)(p -> id));
+ # endif
+
+-# ifdef GC_OPENBSD_THREADS
+- if (pthread_resume_np(p -> id) != 0)
+- ABORT("pthread_resume_np failed");
+-# else
+ # ifndef PLATFORM_ANDROID
+ result = pthread_kill(p -> id, SIG_THR_RESTART);
+ # else
+@@ -785,7 +768,6 @@ GC_INNER void GC_start_world(void)
+ default:
+ ABORT("pthread_kill failed");
+ }
+-# endif
+ }
+ }
+ }
@@ -0,0 +1,10 @@
+$OpenBSD: patch-bdw-gc_pc_in,v 1.1 2009/12/09 20:36:49 sthen Exp $
+--- bdw-gc.pc.in.orig Mon Dec 7 10:57:34 2009
++++ bdw-gc.pc.in Mon Dec 7 10:57:46 2009
+@@ -6,5 +6,5 @@ includedir=@includedir@
+ Name: Boehm-Demers-Weiser Conservative Garbage Collector
+ Description: A garbage collector for C and C++
+ Version: @PACKAGE_VERSION@
+-Libs: -L${libdir} -lgc
++Libs: -L${libdir} -lgc -pthread
+ Cflags: -I${includedir}
@@ -0,0 +1,58 @@
+$OpenBSD: patch-doc_gc_man,v 1.5 2008/04/01 17:41:13 kurt Exp $
+--- doc/gc.man.orig Wed Jul 4 11:47:56 2012
++++ doc/gc.man Wed Jul 4 11:49:02 2012
+@@ -1,4 +1,4 @@
+-.TH GC_MALLOC 1L "2 October 2003"
++.TH GC_MALLOC 3 "2 October 2003"
+ .SH NAME
+ GC_malloc, GC_malloc_atomic, GC_free, GC_realloc, GC_enable_incremental, GC_register_finalizer, GC_malloc_ignore_off_page, GC_malloc_atomic_ignore_off_page, GC_set_warn_proc \- Garbage collecting malloc replacement
+ .SH SYNOPSIS
+@@ -87,6 +87,48 @@ GC_enable_incremental.
+ This may temporarily write protect pages in the heap. See the README file for more information on how this interacts with system calls that write to the heap.
+ .LP
+ Other facilities not discussed here include limited facilities to support incremental collection on machines without appropriate VM support, provisions for providing more explicit object layout information to the garbage collector, more direct support for ``weak'' pointers, support for ``abortable'' garbage collections during idle time, etc.
++.LP
++.SH "PORT INFORMATION"
++.LP
++In this (OpenBSD package) installation,
++.I gc.h
++and
++.I gc_cpp.h
++will be found in
++.I ${PREFIX}/include ,
++and the libraries in
++.I ${PREFIX}/lib.
++.LP
++These libraries have been compiled as drop-in replacements
++for malloc and free (which is to say, all malloc
++calls will allocate garbage-collectable data).
++There is no need to include "gc.h" in your C files unless you want
++access to the debugging (and other) functions defined there,
++or unless you want to explicitly use
++.I GC_malloc_uncollectable
++for some allocations.
++Just link against them whenever you want either garbage
++collection or leak detection.
++.LP
++The C++ header file, "gc_cpp.h",
++.I is
++necessary for C++ programs, to obtain the appropriate
++definitions of the
++.I new
++and
++.I delete
++operators.
++The comments in both of these header files presently
++provide far better documentation
++for the package than this man page;
++look there for more information.
++.LP
++Both libraries are compiled without (explicit) support
++for the experimental
++.I gc
++extension of
++.I g++.
++This may or may not make a difference.
+ .LP
+ .SH "SEE ALSO"
+ The README and gc.h files in the distribution. More detailed definitions of the functions exported by the collector are given there. (The above list is not complete.)
@@ -0,0 +1,12 @@
+$OpenBSD: patch-dyn_load_c,v 1.6 2008/04/01 17:41:13 kurt Exp $
+--- dyn_load.c.orig Wed Jul 4 11:50:24 2012
++++ dyn_load.c Wed Jul 4 11:52:39 2012
+@@ -88,7 +88,7 @@ STATIC GC_has_static_roots_func GC_has_static_roots =
+ || defined(NETBSD) || defined(OPENBSD)))
+ # include <stddef.h>
+ # if !defined(OPENBSD) && !defined(PLATFORM_ANDROID)
+- /* FIXME: Why we exclude it for OpenBSD? */
++ /* Exclude OpenBSD because elf.h doesn't exist. */
+ /* Exclude Android because linker.h below includes its own version. */
+ # include <elf.h>
+ # endif
@@ -0,0 +1,11 @@
+$OpenBSD: patch-include_gc_config_macros_h,v 1.1 2007/07/14 22:16:17 kili Exp $
+--- include/gc_config_macros.h.orig Wed Jul 4 11:53:33 2012
++++ include/gc_config_macros.h Wed Jul 4 11:55:54 2012
+@@ -95,6 +95,7 @@
+ # define GC_DARWIN_THREADS
+ # elif defined(__OpenBSD__)
+ # define GC_OPENBSD_THREADS
++# define GC_PTHREADS
+ # elif !defined(GC_LINUX_THREADS) && !defined(GC_HPUX_THREADS) \
+ && !defined(GC_OSF1_THREADS) && !defined(GC_IRIX_THREADS)
+ /* FIXME: Should we really need for FreeBSD and NetBSD to check */
Oops, something went wrong.

0 comments on commit 9c16b47

Please sign in to comment.