]> granicus.if.org Git - gc/commitdiff
FreeBSD New ports collection for boehm-gc v7.2d
authorVitaly Magerya <vmagerya@gmail.com>
Sun, 21 Jul 2013 12:53:31 +0000 (16:53 +0400)
committerIvan Maidanski <ivmai@mail.ru>
Sun, 21 Jul 2013 12:53:31 +0000 (16:53 +0400)
* Makefile.in (pkgdatadir): Move to "doc" folder.
* configure (Configuration of machine-dependent code): Handle
sparc64-*-freebsd*.
* dbg_mlc.c (GC_caller_func_offset): New function (empty unless
FreeBSD).
* dbg_mlc.c (GC_debug_malloc): Invoke GC_caller_func_offset if
GC_ADD_CALLER.
* dbg_mlc.c (GC_debug_malloc_replacement,
GC_debug_realloc_replacement): Pass NULL (instead of "unknown") to
GC_debug_malloc/realloc.
* doc/gc.man: Add "PORT INFORMATION".
* dyn_load.c (ElfW): Define for __FreeBSD__.
* include/gc.h (GC_RETURN_ADDR_PARENT): New macro.
* include/private/gc_priv.h (RA): Define to "GC_RETURN_ADDR_PARENT,"
if GC_RETURN_ADDR_PARENT defined.
* include/private/gcconfig.h (IA64, ARM32,
ALIGNMENT, OS_TYPE, DYNAMIC_LOADING, HEURISTIC2,
etext, SEARCH_FOR_DATA_START): Define for FreeBSD.
* os_dep.c (GC_set_and_save_fault_handler): Invoke sigaction(SIGBUS)
for FreeBSD.
* os_dep.c (AIM): Define before include machine/trap.h if FreeBSD/ppc.
* os_dep.c (CODE_OK): Define to test "code" against EXC_DSI (instead
of BUS_PAGE_FAULT) if FreeBSD/ppc.

Makefile.in
configure
dbg_mlc.c
doc/gc.man
dyn_load.c
include/gc_config_macros.h
include/private/gc_priv.h
include/private/gcconfig.h
os_dep.c

index 1b57147438b1c685e955a2ff2e022f69b6b34d5e..1b27719f9fbb50977641ffee3ec9e2e393be6dd7 100644 (file)
@@ -73,7 +73,7 @@
 
 
 VPATH = @srcdir@
-pkgdatadir = $(datadir)/@PACKAGE@
+pkgdatadir = $(datadir)/doc/@PACKAGE@
 pkgincludedir = $(includedir)/@PACKAGE@
 pkglibdir = $(libdir)/@PACKAGE@
 pkglibexecdir = $(libexecdir)/@PACKAGE@
index f9d7626d7b1b6db916af1c7c999eb405f7386764..f862779dbef6794d0806be652ed1af09efb83143 100755 (executable)
--- a/configure
+++ b/configure
@@ -5508,6 +5508,9 @@ $as_echo "#define SOLARIS25_PROC_VDB_BUG_FIXED 1" >>confdefs.h
  sparc*-*-openbsd*)
     machdep="mach_dep.lo sparc_mach_dep.lo"
     ;;
+ sparc64-*-freebsd*)
+    machdep="mach_dep.lo sparc_mach_dep.lo"
+    ;;
  sparc-sun-solaris2.3)
     machdep="mach_dep.lo sparc_mach_dep.lo"
 
index 6f51c0303abd65794895a2b6430fff8d5fda9326..18b50907a84e13babe43856b6126da6c3d62bc0e 100644 (file)
--- a/dbg_mlc.c
+++ b/dbg_mlc.c
@@ -455,6 +455,23 @@ GC_API void GC_CALL GC_debug_register_displacement(size_t offset)
     GC_register_displacement((word)sizeof(oh) + offset);
 }
 
+#if defined(__FreeBSD__)
+#include <dlfcn.h>
+static void GC_caller_func_offset(ad, symp, offp)
+const GC_word ad;
+const char **symp;
+int *offp;
+{
+    Dl_info caller;
+    if (dladdr((const void *)ad, &caller) && caller.dli_sname != NULL) {
+      *symp = caller.dli_sname;
+      *offp = (const char *)ad - (const char *)caller.dli_saddr;
+    }
+}
+#else
+#define GC_caller_func(ad, symp, offp)
+#endif
+
 GC_API void * GC_CALL GC_debug_malloc(size_t lb, GC_EXTRA_PARAMS)
 {
     void * result;
@@ -463,6 +480,14 @@ GC_API void * GC_CALL GC_debug_malloc(size_t lb, GC_EXTRA_PARAMS)
     /* later be successfully passed to free(). We always do the latter. */
     result = GC_malloc(lb + DEBUG_BYTES);
 
+#ifdef GC_ADD_CALLER
+    if (s == NULL) {
+      GC_caller_func_offset(ra, &s, &i);
+      if (s == NULL)
+        s = "unknown";
+    }
+#endif
+
     if (result == 0) {
         GC_err_printf("GC_debug_malloc(%lu) returning NULL (",
                       (unsigned long) lb);
@@ -1165,10 +1190,10 @@ GC_API void GC_CALL GC_debug_register_finalizer_ignore_self
 
 GC_API void * GC_CALL GC_debug_malloc_replacement(size_t lb)
 {
-    return GC_debug_malloc(lb, GC_DBG_RA "unknown", 0);
+    return GC_debug_malloc(lb, GC_DBG_RA NULL, 0);
 }
 
 GC_API void * GC_CALL GC_debug_realloc_replacement(void *p, size_t lb)
 {
-    return GC_debug_realloc(p, lb, GC_DBG_RA "unknown", 0);
+    return GC_debug_realloc(p, lb, GC_DBG_RA NULL, 0);
 }
index 109aca6cf795bb2ff7f0afac6fb9714eacf0d319..ee7bbdbf19f5e5c89483bd767b87a96610d942c5 100644 (file)
@@ -11,7 +11,7 @@ void GC_free(void *ptr);
 void * GC_realloc(void *ptr, size_t size);
 .br
 .sp
-cc ... gc.a
+cc ... -lgc
 .LP
 .SH DESCRIPTION
 .I GC_malloc
@@ -88,6 +88,48 @@ This may temporarily write protect pages in the heap.  See the README file for m
 .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 (FreeBSD package) installation,
+.I gc.h
+and
+.I gc_cpp.h
+will probably be found in
+.I %%PREFIX%%/include,
+and the library in
+.I %%PREFIX%%/lib.
+.LP
+This library has 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
+This library is 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.)
 .LP
index 84fdee89afdab7ea3e6b3b602a8dca514def17c4..a76e7b84880409ae58079af953183a02cb7c9d91 100644 (file)
@@ -105,7 +105,7 @@ STATIC GC_has_static_roots_func GC_has_static_roots = 0;
 /* Newer versions of GNU/Linux define this macro.  We
  * define it similarly for any ELF systems that don't.  */
 #  ifndef ElfW
-#    if defined(FREEBSD)
+#    if defined(FREEBSD) || defined(__FreeBSD__)
 #      if __ELF_WORD_SIZE == 32
 #        define ElfW(type) Elf32_##type
 #      else
index 73db584f87c1a273db1ab6de8afd43ad4de85720..1c1a2ab21105deb1a81c3c54057975eb19bcf8f6 100644 (file)
     /* gcc knows how to retrieve return address, but we don't know      */
     /* how to generate call stacks.                                     */
 #   define GC_RETURN_ADDR (GC_word)__builtin_return_address(0)
+#   define GC_RETURN_ADDR_PARENT (GC_word)__builtin_return_address(1)
 # else
     /* Just pass 0 for gcc compatibility.       */
 #   define GC_RETURN_ADDR 0
index b44347febbf5e05249325306c9273e75ce25522f..669918c6e4469b3be8afe2357aafb69745fc4cfe 100644 (file)
@@ -1716,6 +1716,11 @@ GC_INNER ptr_t GC_allocobj(size_t sz, int kind);
 
 #ifdef GC_ADD_CALLER
 # define GC_DBG_RA GC_RETURN_ADDR,
+# ifdef GC_RETURN_ADDR_PARENT
+#  define RA GC_RETURN_ADDR_PARENT,
+# else
+#  define RA GC_RETURN_ADDR,
+# endif
 #else
 # define GC_DBG_RA /* empty */
 #endif
index 767859c0df41c7316b8d2c0b15d5982dbc3636cf..31f1023beff70b3a743d6be9003f72a16ce27910 100644 (file)
@@ -73,7 +73,8 @@
 # if defined(__arm) || defined(__arm__) || defined(__thumb__)
 #    define ARM32
 #    if !defined(LINUX) && !defined(NETBSD) && !defined(OPENBSD) \
-        && !defined(DARWIN) && !defined(_WIN32) && !defined(__CEGCC__)
+        && !defined(DARWIN) && !defined(_WIN32) && !defined(__CEGCC__) \
+        && !defined(FREEBSD)
 #      define NOSYS
 #      define mach_type_known
 #    endif
 #    define M32R
 #    define mach_type_known
 # endif
-# if defined(FREEBSD) && (defined(powerpc) || defined(__powerpc__))
-#    define POWERPC
-#    define mach_type_known
-# endif
 # if defined(__alpha) || defined(__alpha__)
 #   define ALPHA
 #   if !defined(LINUX) && !defined(NETBSD) && !defined(OPENBSD) \
 #   define OPENBSD
 #   define mach_type_known
 # endif
+# if defined(FREEBSD) && (defined(powerpc) || defined(__powerpc__))
+#    define POWERPC
+#    define mach_type_known
+# endif
 # if defined(FREEBSD) && (defined(i386) || defined(__i386__))
 #   define I386
 #   define mach_type_known
 # endif
-# if defined(FREEBSD) && defined(__x86_64__)
+# if defined(FREEBSD) && defined(__amd64__)
 #   define X86_64
 #   define mach_type_known
 # endif
+# if defined(FREEBSD) && defined(__sparc__)
+#    define SPARC
+#    define mach_type_known
+# endif
+# if defined(FREEBSD) && defined(__ia64__)
+#   define IA64
+#   define mach_type_known
+# endif
+# if defined(FREEBSD) && defined(__arm__)
+#   define ARM32
+#   define mach_type_known
+# endif
 # if defined(__NetBSD__) && (defined(i386) || defined(__i386__))
 #   define I386
 #   define mach_type_known
 #    define X86_64
 #    define mach_type_known
 # endif
-# if defined(FREEBSD) && defined(__sparc__)
-#    define SPARC
-#    define mach_type_known
-# endif
 # if defined(bsdi) && (defined(i386) || defined(__i386__))
 #    define I386
 #    define BSDI
 #     define OS_TYPE "MSWINCE"
 #     define DATAEND /* not needed */
 #   endif
+/* To the future maintainer of this diff: this is the "ifdef ARM32" section */
+#   ifdef FREEBSD
+#   define ALIGNMENT 4
+#       define OS_TYPE "FREEBSD"
+#       ifdef __ELF__
+#           define DYNAMIC_LOADING
+#       endif
+#      define HEURISTIC2
+       extern char etext[];
+#      define SEARCH_FOR_DATA_START
+#   endif
 #   ifdef DARWIN
       /* iPhone */
 #     define OS_TYPE "DARWIN"
index da0f24d737c4b883d2f14838edbcea6a57e9b628..269fe5441af4fbeb0d7c46f5b89debc728e0fbcd 100644 (file)
--- a/os_dep.c
+++ b/os_dep.c
@@ -841,7 +841,7 @@ GC_INNER word GC_page_size = 0;
     GC_INNER void GC_set_and_save_fault_handler(GC_fault_handler_t h)
     {
 #       if defined(SUNOS5SIGS) || defined(IRIX5) \
-           || defined(OSF1) || defined(HURD) || defined(NETBSD)
+           || defined(OSF1) || defined(HURD) || defined(NETBSD) || defined(FREEBSD)
           struct sigaction act;
 
           act.sa_handler = h;
@@ -3073,8 +3073,15 @@ STATIC void GC_default_push_other_roots(void)
 #     ifndef SEGV_ACCERR
 #       define SEGV_ACCERR 2
 #     endif
-#     define CODE_OK (si -> si_code == BUS_PAGE_FAULT \
+#     if defined(POWERPC)
+#      define AIM      /* Pretend that we're AIM. */
+#      include <machine/trap.h>
+#       define CODE_OK (si -> si_code == EXC_DSI \
+          || si -> si_code == SEGV_ACCERR)
+#     else
+#       define CODE_OK (si -> si_code == BUS_PAGE_FAULT \
           || si -> si_code == SEGV_ACCERR)
+#     endif
 #   elif defined(OSF1)
 #     define CODE_OK (si -> si_code == 2 /* experimentally determined */)
 #   elif defined(IRIX5)