OSDN Git Service

2006-01-24 David Ayers <d.ayers@inode.at>
[pf3gnuchains/gcc-fork.git] / boehm-gc / include / gc.h
index d49cd9d..9da5b2c 100644 (file)
 
 # define _GC_H
 
+/* 
+ * As this header includes gc_config.h, preprocessor conflicts can occur with 
+ * clients that include their own autoconf headers. The following #undef's 
+ * work around some likely conflicts.
+ */
+
+# ifdef PACKAGE_NAME
+#   undef PACKAGE_NAME
+# endif
+# ifdef PACKAGE_BUGREPORT
+#  undef PACKAGE_BUGREPORT
+# endif
+# ifdef PACKAGE_STRING
+#  undef PACKAGE_STRING
+# endif
+# ifdef PACKAGE_TARNAME
+#  undef PACKAGE_TARNAME
+# endif
+# ifdef PACKAGE_VERSION
+#  undef PACKAGE_VERSION
+# endif
+
+# include <gc_config.h>
 # include "gc_config_macros.h"
 
 # if defined(__STDC__) || defined(__cplusplus)
 /* even semi-portably.  The following is probably no better/worse      */
 /* than almost anything else.                                          */
 /* The ANSI standard suggests that size_t and ptr_diff_t might be      */
-/* better choices.  But those appear to have incorrect definitions     */
-/* on may systems.  Notably "typedef int size_t" seems to be both      */
-/* frequent and WRONG.                                                 */
-typedef unsigned long GC_word;
-typedef long GC_signed_word;
+/* better choices.  But those had incorrect definitions on some older  */
+/* systems.  Notably "typedef int size_t" is WRONG.                    */
+#ifndef _WIN64
+  typedef unsigned long GC_word;
+  typedef long GC_signed_word;
+#else
+  /* Win64 isn't really supported yet, but this is the first step. And */
+  /* it might cause error messages to show up in more plausible places.        */
+  /* This needs basetsd.h, which is included by windows.h.             */
+  typedef ULONG_PTR GC_word;
+  typedef LONG_PTR GC_word;
+#endif
 
 /* Public read-only variables */
 
@@ -122,7 +152,7 @@ GC_API int GC_java_finalization;
                        /* ordered finalization.  Default value is      */
                        /* determined by JAVA_FINALIZATION macro.       */
 
-GC_API void (* GC_finalizer_notifier)();
+GC_API void (* GC_finalizer_notifier) GC_PROTO((void));
                        /* Invoked by the collector when there are      */
                        /* objects to be finalized.  Invoked at most    */
                        /* once per GC cycle.  Never invoked unless     */
@@ -247,6 +277,7 @@ GC_API unsigned long GC_time_limit;
  * allocation, since unlike the regular allocation routines, GC_local_malloc
  * is not self-initializing.  If you use GC_local_malloc you should arrange
  * to call this somehow (e.g. from a constructor) before doing any allocation.
+ * For win32 threads, it needs to be called explicitly.
  */
 GC_API void GC_init GC_PROTO((void));
 
@@ -470,14 +501,19 @@ GC_API GC_PTR GC_malloc_atomic_ignore_off_page GC_PROTO((size_t lb));
 # include <features.h>
 # if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1 || __GLIBC__ > 2) \
      && !defined(__ia64__)
-#   define GC_HAVE_BUILTIN_BACKTRACE
-#   define GC_CAN_SAVE_CALL_STACKS
+#   ifndef GC_HAVE_BUILTIN_BACKTRACE
+#     define GC_HAVE_BUILTIN_BACKTRACE
+#   endif
 # endif
 # if defined(__i386__) || defined(__x86_64__)
 #   define GC_CAN_SAVE_CALL_STACKS
 # endif
 #endif
 
+#if defined(GC_HAVE_BUILTIN_BACKTRACE) && !defined(GC_CAN_SAVE_CALL_STACKS)
+# define GC_CAN_SAVE_CALL_STACKS
+#endif
+
 #if defined(__sparc__)
 #   define GC_CAN_SAVE_CALL_STACKS
 #endif
@@ -604,7 +640,7 @@ GC_API GC_PTR GC_debug_realloc_replacement
 
 /* Finalization.  Some of these primitives are grossly unsafe.         */
 /* The idea is to make them both cheap, and sufficient to build                */
-/* a safer layer, closer to PCedar finalization.                       */
+/* a safer layer, closer to Modula-3, Java, or PCedar finalization.    */
 /* The interface represents my conclusions from a long discussion      */
 /* with Alan Demers, Dan Greene, Carl Hauser, Barry Hayes,             */
 /* Christian Jacobi, and Russ Atkinson.  It's not perfect, and         */
@@ -774,6 +810,7 @@ GC_API GC_PTR GC_call_with_alloc_lock
 
 /* The following routines are primarily intended for use with a        */
 /* preprocessor which inserts calls to check C pointer arithmetic.     */
+/* They indicate failure by invoking the corresponding _print_proc.    */
 
 /* Check that p and q point to the same object.                */
 /* Fail conspicuously if they don't.                           */
@@ -851,7 +888,7 @@ GC_API GC_PTR GC_is_valid_displacement GC_PROTO((GC_PTR     p));
 #   define GC_PTR_STORE(p, q) *((p) = (q))
 #endif
 
-/* Fynctions called to report pointer checking errors */
+/* Functions called to report pointer checking errors */
 GC_API void (*GC_same_obj_print_proc) GC_PROTO((GC_PTR p, GC_PTR q));
 
 GC_API void (*GC_is_valid_displacement_print_proc)
@@ -881,7 +918,7 @@ GC_API void (*GC_is_visible_print_proc)
 GC_PTR GC_malloc_many(size_t lb);
 #define GC_NEXT(p) (*(GC_PTR *)(p))    /* Retrieve the next element    */
                                        /* in returned list.            */
-extern void GC_thr_init();     /* Needed for Solaris/X86       */
+extern void GC_thr_init GC_PROTO((void));/* Needed for Solaris/X86     */
 
 #endif /* THREADS && !SRC_M3 */
 
@@ -895,7 +932,7 @@ extern void GC_thr_init();  /* Needed for Solaris/X86       */
    * and does then use DllMain to keep track of thread creations.  But new code
    * should be built to call GC_CreateThread.
    */
-  GC_API HANDLE GC_CreateThread(
+   GC_API HANDLE WINAPI GC_CreateThread(
       LPSECURITY_ATTRIBUTES lpThreadAttributes,
       DWORD dwStackSize, LPTHREAD_START_ROUTINE lpStartAddress,
       LPVOID lpParameter, DWORD dwCreationFlags, LPDWORD lpThreadId );
@@ -919,13 +956,19 @@ extern void GC_thr_init();        /* Needed for Solaris/X86       */
 
 #endif /* defined(GC_WIN32_THREADS)  && !cygwin */
 
-/*
- * If you are planning on putting
- * the collector in a SunOS 5 dynamic library, you need to call GC_INIT()
- * from the statically loaded program section.
- * This circumvents a Solaris 2.X (X<=4) linker bug.
- */
-#if defined(sparc) || defined(__sparc)
+ /*
+  * Fully portable code should call GC_INIT() from the main program
+  * before making any other GC_ calls.  On most platforms this is a
+  * no-op and the collector self-initializes.  But a number of platforms
+  * make that too hard.
+  */
+#if (defined(sparc) || defined(__sparc)) && defined(sun)
+    /*
+     * If you are planning on putting
+     * the collector in a SunOS 5 dynamic library, you need to call GC_INIT()
+     * from the statically loaded program section.
+     * This circumvents a Solaris 2.X (X<=4) linker bug.
+     */
 #   define GC_INIT() { extern end, etext; \
                       GC_noop(&end, &etext); }
 #else
@@ -936,13 +979,13 @@ extern void GC_thr_init();        /* Needed for Solaris/X86       */
      */
 #   define GC_INIT() { GC_add_roots(DATASTART, DATAEND); }
 # else
-#  if defined(__APPLE__) && defined(__MACH__)
+#  if defined(__APPLE__) && defined(__MACH__) || defined(GC_WIN32_THREADS)
 #   define GC_INIT() { GC_init(); }
 #  else
 #   define GC_INIT()
-#  endif
-# endif
-#endif
+#  endif /* !__MACH && !GC_WIN32_THREADS */
+# endif /* !AIX && !cygwin */
+#endif /* !sparc */
 
 #if !defined(_WIN32_WCE) \
     && ((defined(_MSDOS) || defined(_MSC_VER)) && (_M_IX86 >= 300) \