[Mono-list] gc6.2 & pthreads_vtable (libgc-mono)

Alejandro Mery amery@geeks.cl
Fri, 23 Jan 2004 16:54:33 -0300


--nFreZHaLTZJo0R7j
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

Hi,
i don't like idea of having two different versions of boehm-gc to use mono-debugger, then i tried to isolate what Martin did on libgc-mono (based on boehm-gc-6.1) and i built my global libgc with it.

i would like to know if i miss something and if this (and the symlinks to fake libgc-mono) is the only thing i need to get mono-debuger built... and work.

Best regards,
Alejandro Mery



--nFreZHaLTZJo0R7j
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="install_private_headers.patch"

diff -udNr gc6.2.orig/configure gc6.2-private/configure
--- gc6.2.orig/configure	2004-01-22 11:50:26.000000000 -0300
+++ gc6.2-private/configure	2004-01-23 10:32:15.000000000 -0300
@@ -8880,7 +8880,7 @@
 fi
 
 
-ac_config_files="$ac_config_files Makefile doc/Makefile include/Makefile"
+ac_config_files="$ac_config_files Makefile doc/Makefile include/Makefile include/private/Makefile"
 ac_config_commands="$ac_config_commands default"
 cat >confcache <<\_ACEOF
 # This file is a shell script that caches the results of configure
diff -udNr gc6.2.orig/configure.in gc6.2-private/configure.in
--- gc6.2.orig/configure.in	2004-01-22 11:50:26.000000000 -0300
+++ gc6.2-private/configure.in	2004-01-23 10:08:21.000000000 -0300
@@ -439,7 +439,7 @@
 
 AM_CONDITIONAL(USE_LIBDIR, test -z "$with_cross_host")
 
-AC_OUTPUT([Makefile doc/Makefile include/Makefile],,
+AC_OUTPUT([Makefile doc/Makefile include/Makefile include/private/Makefile],,
 srcdir=${srcdir}
 host=${host}
 CONFIG_SHELL=${CONFIG_SHELL-/bin/sh}
diff -udNr gc6.2.orig/include/Makefile.am gc6.2-private/include/Makefile.am
--- gc6.2.orig/include/Makefile.am	2004-01-22 11:50:26.000000000 -0300
+++ gc6.2-private/include/Makefile.am	2004-01-23 10:43:49.000000000 -0300
@@ -21,15 +21,7 @@
     gc_allocator.h gc_backptr.h \
     gc_gcj.h gc_local_alloc.h leak_detector.h \
     gc_amiga_redirects.h gc_pthread_redirects.h \
-    gc_config_macros.h
-
-# headers which are not installed
-#
-dist_noinst_HEADERS = private/gc_hdrs.h \
-    private/gc_priv.h private/gcconfig.h \
-    private/gc_pmark.h private/gc_locks.h \
-    private/solaris_threads.h private/dbg_mlc.h \
-    private/specific.h private/cord_pos.h \
-    private/pthread_support.h private/pthread_stop_world.h \
-    private/darwin_semaphore.h private/darwin_stop_world.h \
+    gc_config_macros.h \
     cord.h ec.h javaxfc.h 
+
+SUBDIRS = private
diff -udNr gc6.2.orig/include/private/Makefile.am gc6.2-private/include/private/Makefile.am
--- gc6.2.orig/include/private/Makefile.am	1969-12-31 21:00:00.000000000 -0300
+++ gc6.2-private/include/private/Makefile.am	2004-01-23 11:10:19.000000000 -0300
@@ -0,0 +1,2 @@
+pkgincludedir = $(includedir)/gc/private
+pkginclude_HEADERS = $(srcdir)/*.h

--nFreZHaLTZJo0R7j
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="pthread_vtable.patch"

diff -udNr gc6.2.orig/Makefile.am gc6.2-vtable/Makefile.am
--- gc6.2.orig/Makefile.am	2004-01-22 11:50:26.000000000 -0300
+++ gc6.2-vtable/Makefile.am	2004-01-23 09:37:34.000000000 -0300
@@ -113,7 +113,7 @@
 ## We have our own definition of LTCOMPILE because we want to use our
 ## CFLAGS, not those passed in from the top level make.
 LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) \
-	$(AM_CPPFLAGS) $(CPPFLAGS) \
+	-I$(top_srcdir)/include $(AM_CPPFLAGS) $(CPPFLAGS) \
 	$(AM_CFLAGS) $(MY_CFLAGS) $(GC_CFLAGS) 
 LINK = $(LIBTOOL) --mode=link $(CC) $(AM_CFLAGS) $(MY_CFLAGS) $(LDFLAGS) -o $@
 
diff -udNr gc6.2.orig/configure.in gc6.2-vtable/configure.in
--- gc6.2.orig/configure.in	2004-01-22 11:50:26.000000000 -0300
+++ gc6.2-vtable/configure.in	2004-01-23 09:38:32.000000000 -0300
@@ -437,6 +437,8 @@
     AC_DEFINE(GC_ASSERTIONS)
 fi
 
+AC_DEFINE(_IN_LIBGC)
+
 AM_CONDITIONAL(USE_LIBDIR, test -z "$with_cross_host")
 
 AC_OUTPUT([Makefile doc/Makefile include/Makefile],,
diff -udNr gc6.2.orig/include/gc.h gc6.2-vtable/include/gc.h
--- gc6.2.orig/include/gc.h	2004-01-22 11:50:26.000000000 -0300
+++ gc6.2-vtable/include/gc.h	2004-01-23 09:46:35.000000000 -0300
@@ -851,13 +851,39 @@
 GC_API void (*GC_is_visible_print_proc)
 	GC_PROTO((GC_PTR p));
 
+# include <pthread.h>
+# include <signal.h>
+
+typedef struct
+{
+	void (* initialize) (void);
+
+	int (* thread_create) (pthread_t *new_thread,
+				const pthread_attr_t *attr,
+				void * (*start_routine)(void *),
+				void *arg);
+	int (* thread_join) (pthread_t wait_for, void **status);
+	int (* thread_detach) (pthread_t target_thread);
+	int (* thread_sigmask) (int how, const sigset_t *set, sigset_t *oset);
+
+	void (* stop_world) (void);
+	void (* push_all_stacks) (void);
+	void (* start_world) (void);
+} GCThreadFunctions;
+
+extern GCThreadFunctions *gc_thread_vtable;
 
 /* For pthread support, we generally need to intercept a number of 	*/
 /* thread library calls.  We do that here by macro defining them.	*/
 
 #if !defined(GC_USE_LD_WRAP) && \
     (defined(GC_PTHREADS) || defined(GC_SOLARIS_THREADS))
+#if defined(_IN_LIBGC)
 # include "gc_pthread_redirects.h"
+#else
+# include <gc/gc_pthread_redirects.h>
+#endif
+
 #endif
 
 # if defined(PCR) || defined(GC_SOLARIS_THREADS) || \
diff -udNr gc6.2.orig/include/gc_pthread_redirects.h gc6.2-vtable/include/gc_pthread_redirects.h
--- gc6.2.orig/include/gc_pthread_redirects.h	2004-01-22 11:50:26.000000000 -0300
+++ gc6.2-vtable/include/gc_pthread_redirects.h	2004-01-23 09:43:48.000000000 -0300
@@ -5,69 +5,11 @@
 
 #define GC_PTHREAD_REDIRECTS_H
 
-#if defined(GC_SOLARIS_THREADS)
-/* We need to intercept calls to many of the threads primitives, so 	*/
-/* that we can locate thread stacks and stop the world.			*/
-/* Note also that the collector cannot see thread specific data.	*/
-/* Thread specific data should generally consist of pointers to		*/
-/* uncollectable objects (allocated with GC_malloc_uncollectable,	*/
-/* not the system malloc), which are deallocated using the destructor	*/
-/* facility in thr_keycreate.  Alternatively, keep a redundant pointer	*/
-/* to thread specific data on the thread stack.			        */
-# include <thread.h>
-  int GC_thr_create(void *stack_base, size_t stack_size,
-                    void *(*start_routine)(void *), void *arg, long flags,
-                    thread_t *new_thread);
-  int GC_thr_join(thread_t wait_for, thread_t *departed, void **status);
-  int GC_thr_suspend(thread_t target_thread);
-  int GC_thr_continue(thread_t target_thread);
-  void * GC_dlopen(const char *path, int mode);
-# define thr_create GC_thr_create
-# define thr_join GC_thr_join
-# define thr_suspend GC_thr_suspend
-# define thr_continue GC_thr_continue
-#endif /* GC_SOLARIS_THREADS */
-
-#if defined(GC_SOLARIS_PTHREADS)
-# include <pthread.h>
-# include <signal.h>
-  extern int GC_pthread_create(pthread_t *new_thread,
-    			         const pthread_attr_t *attr,
-          			 void * (*thread_execp)(void *), void *arg);
-  extern int GC_pthread_join(pthread_t wait_for, void **status);
-# define pthread_join GC_pthread_join
-# define pthread_create GC_pthread_create
-#endif
-
-#if defined(GC_SOLARIS_PTHREADS) || defined(GC_SOLARIS_THREADS)
-# define dlopen GC_dlopen
-#endif /* SOLARIS_THREADS || SOLARIS_PTHREADS */
-
-
-#if !defined(GC_USE_LD_WRAP) && defined(GC_PTHREADS) && !defined(GC_SOLARIS_PTHREADS)
-/* We treat these similarly. */
-# include <pthread.h>
-# include <signal.h>
-
-  int GC_pthread_create(pthread_t *new_thread,
-                        const pthread_attr_t *attr,
-		        void *(*start_routine)(void *), void *arg);
-#ifndef GC_DARWIN_THREADS
-  int GC_pthread_sigmask(int how, const sigset_t *set, sigset_t *oset);
-#endif
-  int GC_pthread_join(pthread_t thread, void **retval);
-  int GC_pthread_detach(pthread_t thread);
-
-# define pthread_create GC_pthread_create
-#ifndef GC_DARWIN_THREADS
-# define pthread_sigmask GC_pthread_sigmask
-#endif
-# define pthread_join GC_pthread_join
-# define pthread_detach GC_pthread_detach
-#ifndef GC_DARWIN_THREADS
-# define dlopen GC_dlopen
+#if defined(GC_SOLARIS_PTHREADS) || defined(GC_PTHREADS)
+# define pthread_join gc_thread_vtable->thread_join
+# define pthread_create gc_thread_vtable->thread_create
+# define pthread_detach gc_thread_vtable->thread_detach
+# define pthread_sigmask gc_thread_vtable->thread_sigmask
 #endif
 
-#endif /* GC_xxxxx_THREADS */
-
 #endif /* GC_PTHREAD_REDIRECTS_H */
diff -udNr gc6.2.orig/include/private/gc_priv.h gc6.2-vtable/include/private/gc_priv.h
--- gc6.2.orig/include/private/gc_priv.h	2004-01-22 11:50:26.000000000 -0300
+++ gc6.2-vtable/include/private/gc_priv.h	2004-01-23 09:44:24.000000000 -0300
@@ -415,8 +415,8 @@
 	|| defined(GC_PTHREADS)
       void GC_stop_world();
       void GC_start_world();
-#     define STOP_WORLD() GC_stop_world()
-#     define START_WORLD() GC_start_world()
+#     define STOP_WORLD() gc_thread_vtable->stop_world()
+#     define START_WORLD() gc_thread_vtable->start_world()
 #   else
 #     define STOP_WORLD()
 #     define START_WORLD()
diff -udNr gc6.2.orig/misc.c gc6.2-vtable/misc.c
--- gc6.2.orig/misc.c	2004-01-22 11:50:26.000000000 -0300
+++ gc6.2-vtable/misc.c	2004-01-23 09:44:37.000000000 -0300
@@ -639,7 +639,7 @@
 	GC_init_netbsd_elf();
 #   endif
 #   if defined(GC_PTHREADS) || defined(GC_SOLARIS_THREADS)
-        GC_thr_init();
+	gc_thread_vtable->initialize ();
 #   endif
 #   ifdef GC_SOLARIS_THREADS
 	/* We need dirty bits in order to find live stack sections.	*/
diff -udNr gc6.2.orig/os_dep.c gc6.2-vtable/os_dep.c
--- gc6.2.orig/os_dep.c	2004-01-22 11:50:26.000000000 -0300
+++ gc6.2-vtable/os_dep.c	2004-01-23 09:44:46.000000000 -0300
@@ -1987,7 +1987,7 @@
 
 void GC_default_push_other_roots GC_PROTO((void))
 {
-    GC_push_all_stacks();
+    gc_thread_vtable->push_all_stacks();
 }
 
 # endif /* GC_SOLARIS_THREADS || GC_PTHREADS */
diff -udNr gc6.2.orig/pthread_support.c gc6.2-vtable/pthread_support.c
--- gc6.2.orig/pthread_support.c	2004-01-22 11:50:26.000000000 -0300
+++ gc6.2-vtable/pthread_support.c	2004-01-23 09:44:59.000000000 -0300
@@ -1557,5 +1557,22 @@
 
 #endif /* PARALLEL_MARK */
 
+extern void GC_push_all_stacks();
+
+GCThreadFunctions linux_thread_vtable = {
+	GC_thr_init,
+
+	GC_pthread_create,
+	GC_pthread_join,
+	GC_pthread_detach,
+	GC_pthread_sigmask,
+
+	GC_stop_world,
+	GC_push_all_stacks,
+	GC_start_world
+};
+
+GCThreadFunctions *gc_thread_vtable = &linux_thread_vtable;
+
 # endif /* GC_LINUX_THREADS and friends */
 

--nFreZHaLTZJo0R7j--