srcdir = @srcdir@
top_srcdir = @top_srcdir@
VPATH = @srcdir@
-pkgdatadir = $(datadir)/@PACKAGE@
+pkgdatadir = $(datadir)/doc/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
top_builddir = .
sparc-*-netbsd*)
machdep="mach_dep.lo sparc_netbsd_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"
cat >>confdefs.h <<\_ACEOF
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
+
void * GC_debug_malloc(size_t lb, GC_EXTRA_PARAMS)
{
void * 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 NIL (",
(unsigned long) lb);
size_t old_sz;
hdr * hhdr;
+#ifdef GC_ADD_CALLER
+ if (s == NULL) {
+ GC_caller_func_offset(ra, &s, &i);
+ if (s == NULL)
+ s = "unknown";
+ }
+#endif
if (p == 0) return(GC_debug_malloc(lb, OPT_RA s, i));
if (base == 0) {
GC_err_printf("Attempt to reallocate invalid pointer %p\n", p);
}
#ifdef GC_ADD_CALLER
-# define RA GC_RETURN_ADDR,
+# ifdef GC_RETURN_ADDR_PARENT
+# define RA GC_RETURN_ADDR_PARENT,
+# else
+# define RA GC_RETURN_ADDR,
+# endif
#else
# define RA
#endif
void * GC_debug_malloc_replacement(size_t lb)
{
- return GC_debug_malloc(lb, RA "unknown", 0);
+ return GC_debug_malloc(lb, RA NULL, 0);
}
void * GC_debug_realloc_replacement(void *p, size_t lb)
{
- return GC_debug_realloc(p, lb, RA "unknown", 0);
+ return GC_debug_realloc(p, lb, RA NULL, 0);
}
void * GC_realloc(void *ptr, size_t size);
.br
.sp
-cc ... gc.a
+cc ... -lgc
.LP
.SH DESCRIPTION
.I GC_malloc
.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
# else
# define ElfW(type) Elf64_##type
# endif
+# elif defined(__FreeBSD__)
+# if __ELF_WORD_SIZE == 32
+# define ElfW(type) Elf32_##type
+# else
+# define ElfW(type) Elf64_##type
+# endif
# else
# if !defined(ELF_CLASS) || ELF_CLASS == ELFCLASS32
# define ElfW(type) Elf32_##type
/* 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
/* Determine the machine type: */
# if defined(__arm__) || defined(__thumb__)
# define ARM32
-# if !defined(LINUX) && !defined(NETBSD)
+# if !defined(LINUX) && !defined(NETBSD) && !defined(FREEBSD)
# define NOSYS
# define mach_type_known
# endif
# define X86_64
# define mach_type_known
# endif
+# if defined(__FreeBSD__) && defined(__amd64__)
+# define X86_64
+# define mach_type_known
+# endif
+# if defined(__FreeBSD__) && defined(__ia64__)
+# define IA64
+# define mach_type_known
+# endif
# if defined(FREEBSD) && defined(__sparc__)
# define SPARC
# define mach_type_known
# endif
+# if defined(FREEBSD) && defined(__powerpc__)
+# define POWERPC
+# define mach_type_known
+# endif
+# if defined(FREEBSD) && defined(__arm__)
+# define ARM32
+# 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
+# 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 NOSYS
/* __data_start is usually defined in the target linker script. */
extern int __data_start[];
# define OS_TYPE "MSWINCE"
# define DATAEND /* not needed */
# endif
+
# ifdef LINUX
# define OS_TYPE "LINUX"
# define LINUX_STACKBOTTOM
|| defined(HURD) || defined(NETBSD)
static struct sigaction old_segv_act;
# if defined(_sigargs) /* !Irix6.x */ || defined(HPUX) \
- || defined(HURD) || defined(NETBSD)
+ || defined(HURD) || defined(NETBSD) || defined(FREEBSD)
static struct sigaction old_bus_act;
# endif
# else
void GC_set_and_save_fault_handler(handler 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;
# else
(void) sigaction(SIGSEGV, &act, &old_segv_act);
# if defined(IRIX5) && defined(_sigargs) /* Irix 5.x, not 6.x */ \
- || defined(HPUX) || defined(HURD) || defined(NETBSD)
+ || defined(HPUX) || defined(HURD) || defined(NETBSD) || defined(FREEBSD)
/* Under Irix 5.x or HP/UX, we may get SIGBUS. */
/* Pthreads doesn't exist under Irix 5.x, so we */
/* don't have to worry in the threads case. */
# include <errno.h>
# if defined(FREEBSD)
# define SIG_OK TRUE
-# define CODE_OK (code == BUS_PAGE_FAULT)
+# if defined(POWERPC)
+# define AIM /* Pretend that we're AIM. */
+# include <machine/trap.h>
+# define CODE_OK (code == EXC_DSI)
+# else
+# define CODE_OK (code == BUS_PAGE_FAULT)
+# endif
# elif defined(OSF1)
# define SIG_OK (sig == SIGSEGV)
# define CODE_OK (code == 2 /* experimentally determined */)