[System.Web] Clean up assembly level attributes.
[mono.git] / libgc / include / gc.h
index 970c5b5b2b674f09928ebdb12a2dc94505f2cbd7..123d6cce0893b3860763a68d3726739e6298791d 100644 (file)
@@ -32,7 +32,7 @@
 
 # include "gc_config_macros.h"
 
-# if defined(__STDC__) || defined(__cplusplus)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_AIX)
 #   define GC_PROTO(args) args
     typedef void * GC_PTR;
 #   define GC_CONST const
@@ -61,8 +61,9 @@
   /* 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;
+  #include <stdint.h>
+  typedef unsigned __int64 GC_word;
+  typedef __int64 GC_signed_word;
 #endif
 
 /* Public read-only variables */
@@ -98,7 +99,11 @@ typedef enum {
        GC_EVENT_MARK_END,
        GC_EVENT_RECLAIM_START,
        GC_EVENT_RECLAIM_END,
-       GC_EVENT_END
+       GC_EVENT_END,
+       GC_EVENT_PRE_STOP_WORLD,
+       GC_EVENT_POST_STOP_WORLD,
+       GC_EVENT_PRE_START_WORLD,
+       GC_EVENT_POST_START_WORLD
 } GCEventType;
 
 GC_API void (*GC_notify_event) GC_PROTO((GCEventType event_type));
@@ -207,7 +212,7 @@ GC_API GC_word GC_free_space_divisor;
                        /* least N/GC_free_space_divisor bytes between  */
                        /* collections, where N is the heap size plus   */
                        /* a rough estimate of the root set size.       */
-                       /* Initially, GC_free_space_divisor = 4.        */
+                       /* Initially, GC_free_space_divisor = 3.        */
                        /* Increasing its value will use less space     */
                        /* but more collection time.  Decreasing it     */
                        /* will appreciably decrease collection time    */
@@ -324,6 +329,9 @@ GC_API void GC_end_stubborn_change GC_PROTO((GC_PTR));
 /* the base of the user object.                                                */
 /* Return 0 if displaced_pointer doesn't point to within a valid       */
 /* object.                                                             */
+/* Note that a deallocated object in the garbage collected heap                */
+/* may be considered valid, even if it has been deallocated with       */
+/* GC_free.                                                            */
 GC_API GC_PTR GC_base GC_PROTO((GC_PTR displaced_pointer));
 
 /* Given a pointer to the base of an object, return its size in bytes. */
@@ -417,6 +425,10 @@ GC_API size_t GC_get_bytes_since_gc GC_PROTO((void));
 /* Never decreases, except due to wrapping.                            */
 GC_API size_t GC_get_total_bytes GC_PROTO((void));
 
+/* Return the signal used by the gc to suspend threads on posix platforms. */
+/* Return -1 otherwise. */
+int GC_get_suspend_signal GC_PROTO((void));
+
 /* Disable garbage collection.  Even GC_gcollect calls will be                 */
 /* ineffective.                                                                */
 GC_API void GC_disable GC_PROTO((void));
@@ -589,6 +601,8 @@ GC_API GC_PTR GC_debug_realloc_replacement
 #   define GC_END_STUBBORN_CHANGE(p) GC_debug_end_stubborn_change(p)
 #   define GC_GENERAL_REGISTER_DISAPPEARING_LINK(link, obj) \
        GC_general_register_disappearing_link(link, GC_base(obj))
+#   define GC_REGISTER_LONG_LINK(link, obj) \
+       GC_register_long_link(link, GC_base(obj))
 #   define GC_REGISTER_DISPLACEMENT(n) GC_debug_register_displacement(n)
 # else
 #   define GC_MALLOC(sz) GC_malloc(sz)
@@ -611,6 +625,8 @@ GC_API GC_PTR GC_debug_realloc_replacement
 #   define GC_END_STUBBORN_CHANGE(p) GC_end_stubborn_change(p)
 #   define GC_GENERAL_REGISTER_DISAPPEARING_LINK(link, obj) \
        GC_general_register_disappearing_link(link, obj)
+#   define GC_REGISTER_LONG_LINK(link, obj) \
+       GC_register_long_link(link, obj)
 #   define GC_REGISTER_DISPLACEMENT(n) GC_register_displacement(n)
 # endif
 /* The following are included because they are often convenient, and   */
@@ -750,6 +766,9 @@ GC_API int GC_unregister_disappearing_link GC_PROTO((GC_PTR * /* link */));
        /* Undoes a registration by either of the above two     */
        /* routines.                                            */
 
+GC_API int GC_register_long_link GC_PROTO((GC_PTR * /* link */, GC_PTR obj));
+GC_API int GC_unregister_long_link GC_PROTO((GC_PTR * /* link */));
+
 /* Returns !=0  if GC_invoke_finalizers has something to do.           */
 GC_API int GC_should_invoke_finalizers GC_PROTO((void));
 
@@ -830,6 +849,12 @@ GC_API GC_PTR GC_is_valid_displacement GC_PROTO((GC_PTR    p));
 /* Returns 1 if the calling thread is registered with the GC, 0 otherwise */
 GC_API int GC_thread_is_registered GC_PROTO((void));
 
+/* Notify the collector about the stack and the altstack of the current thread */
+/* STACK/STACK_SIZE is used to determine the stack dimensions when a thread is
+ * suspended while it is on an altstack.
+ */
+GC_API void GC_register_altstack GC_PROTO((void *stack, int stack_size, void *altstack, int altstack_size));
+
 /* Safer, but slow, pointer addition.  Probably useful mainly with     */
 /* a preprocessor.  Useful only for heap pointers.                     */
 #ifdef GC_DEBUG
@@ -864,7 +889,7 @@ GC_API int GC_thread_is_registered GC_PROTO((void));
 
 /* Safer assignment of a pointer to a nonstack location.       */
 #ifdef GC_DEBUG
-# ifdef __STDC__
+# if defined(__STDC__) || defined(_AIX)
 #   define GC_PTR_STORE(p, q) \
        (*(void **)GC_is_visible(p) = GC_is_valid_displacement(q))
 # else
@@ -884,14 +909,11 @@ GC_API void (*GC_is_valid_displacement_print_proc)
 GC_API void (*GC_is_visible_print_proc)
        GC_PROTO((GC_PTR p));
 
-#define _IN_LIBGC_GC_H
-#include "libgc-mono-debugger.h"
-
 /* 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))
+    (defined(GC_PTHREADS) || defined(GC_SOLARIS_THREADS) || defined(GC_DARWIN_THREADS) || defined(GC_MACOSX_THREADS))
 #if defined(_IN_LIBGC) || defined(USE_INCLUDED_LIBGC)
 # include "gc_pthread_redirects.h"
 #else
@@ -918,6 +940,8 @@ extern void GC_thr_init(void);      /* Needed for Solaris/X86       */
 #if defined(GC_WIN32_THREADS) && !defined(__CYGWIN32__) && !defined(__CYGWIN__)
 # include <windows.h>
 
+   BOOL WINAPI GC_DllMain(HINSTANCE inst, ULONG reason, LPVOID reserved);
+
   /*
    * All threads must be created using GC_CreateThread, so that they will be
    * recorded in the thread table.  For backwards compatibility, this is not
@@ -955,7 +979,7 @@ extern void GC_thr_init(void);      /* Needed for Solaris/X86       */
   * no-op and the collector self-initializes.  But a number of platforms
   * make that too hard.
   */
-#if defined(sparc) || defined(__sparc)
+#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()
@@ -965,12 +989,32 @@ extern void GC_thr_init(void);    /* Needed for Solaris/X86       */
 #   define GC_INIT() { extern end, etext; \
                       GC_noop(&end, &etext); }
 #else
-# if defined(__CYGWIN32__) && defined(GC_DLL) || defined (_AIX)
+# if defined(__CYGWIN32__) || defined (_AIX)
     /*
      * Similarly gnu-win32 DLLs need explicit initialization from
      * the main program, as does AIX.
      */
-#   define GC_INIT() { GC_add_roots(DATASTART, DATAEND); }
+#   ifdef __CYGWIN32__
+      extern int _data_start__[];
+      extern int _data_end__[];
+      extern int _bss_start__[];
+      extern int _bss_end__[];
+#     define GC_MAX(x,y) ((x) > (y) ? (x) : (y))
+#     define GC_MIN(x,y) ((x) < (y) ? (x) : (y))
+#     define GC_DATASTART ((GC_PTR) GC_MIN(_data_start__, _bss_start__))
+#     define GC_DATAEND         ((GC_PTR) GC_MAX(_data_end__, _bss_end__))
+#     ifdef GC_DLL
+#       define GC_INIT() { GC_add_roots(GC_DATASTART, GC_DATAEND); }
+#     else
+#       define GC_INIT()
+#     endif
+#   endif
+#   if defined(_AIX)
+      extern int _data[], _end[];
+#     define GC_DATASTART ((GC_PTR)((ulong)_data))
+#     define GC_DATAEND ((GC_PTR)((ulong)_end))
+#     define GC_INIT() { GC_add_roots(GC_DATASTART, GC_DATAEND); }
+#   endif
 # else
 #  if defined(__APPLE__) && defined(__MACH__) || defined(GC_WIN32_THREADS)
 #   define GC_INIT() { GC_init(); }