[Gc] GC API: addition of calling conventions. Part 3/4

Ivan Maidanski ivmai at mail.ru
Fri Oct 17 13:04:57 PDT 2008


Part 3.

-------------- next part --------------
diff -ru bdwgc/include/gc_config_macros.h updated/bdwgc/include/gc_config_macros.h
--- bdwgc/include/gc_config_macros.h	2008-10-11 11:13:54.000000000 +0400
+++ updated/bdwgc/include/gc_config_macros.h	2008-10-16 16:34:41.000000000 +0400
@@ -179,3 +179,10 @@
 #define GC_API extern
 #endif
 
+#ifndef GC_CALL
+#define GC_CALL
+#endif
+
+#ifndef GC_CALLBACK
+#define GC_CALLBACK GC_CALL
+#endif
diff -ru bdwgc/include/gc_cpp.h updated/bdwgc/include/gc_cpp.h
--- bdwgc/include/gc_cpp.h	2008-07-26 04:51:34.000000000 +0400
+++ updated/bdwgc/include/gc_cpp.h	2008-10-16 18:37:31.000000000 +0400
@@ -141,7 +141,7 @@
 #include "gc.h"
 
 #ifndef THINK_CPLUS
-#  define GC_cdecl
+#  define GC_cdecl GC_CALLBACK
 #else
 #  define GC_cdecl _cdecl
 #endif
@@ -212,7 +212,9 @@
     member derived from "gc_cleanup", its destructors will be
     invoked. */
 
-extern "C" {typedef void (*GCCleanUpFunc)( void* obj, void* clientData );}
+extern "C" {
+    typedef void (GC_CALLBACK * GCCleanUpFunc)( void* obj, void* clientData );
+}
 
 #ifdef _MSC_VER
   // Disable warning that "no matching operator delete found; memory will
@@ -339,7 +341,7 @@
 inline gc_cleanup::~gc_cleanup() {
     GC_register_finalizer_ignore_self( GC_base(this), 0, 0, 0, 0 );}
 
-inline void gc_cleanup::cleanup( void* obj, void* displ ) {
+inline void GC_CALLBACK gc_cleanup::cleanup( void* obj, void* displ ) {
     ((gc_cleanup*) ((char*) obj + (ptrdiff_t) displ))->~gc_cleanup();}
 
 inline gc_cleanup::gc_cleanup() {
diff -ru bdwgc/include/gc_gcj.h updated/bdwgc/include/gc_gcj.h
--- bdwgc/include/gc_gcj.h	2008-07-26 04:51:34.000000000 +0400
+++ updated/bdwgc/include/gc_gcj.h	2008-10-16 16:35:54.000000000 +0400
@@ -58,21 +58,23 @@
 /* detect the presence or absence of the debug header.			*/
 /* Mp is really of type mark_proc, as defined in gc_mark.h.  We don't 	*/
 /* want to include that here for namespace pollution reasons.		*/
-GC_API void GC_init_gcj_malloc(int mp_index, void * /* really mark_proc */mp);
+GC_API void GC_CALL GC_init_gcj_malloc(int mp_index,
+				void * /* really mark_proc */mp);
 
 /* Allocate an object, clear it, and store the pointer to the	*/
 /* type structure (vtable in gcj).				*/
 /* This adds a byte at the end of the object if GC_malloc would.*/
-GC_API void * GC_gcj_malloc(size_t lb, void * ptr_to_struct_containing_descr);
+GC_API void * GC_CALL GC_gcj_malloc(size_t lb,
+				void * ptr_to_struct_containing_descr);
 /* The debug versions allocate such that the specified mark_proc	*/
 /* is always invoked.							*/
-GC_API void * GC_debug_gcj_malloc(size_t lb,
+GC_API void * GC_CALL GC_debug_gcj_malloc(size_t lb,
 				  void * ptr_to_struct_containing_descr,
 				  GC_EXTRA_PARAMS);
 
 /* Similar to GC_gcj_malloc, but assumes that a pointer to near the	*/
 /* beginning of the resulting object is always maintained.		*/
-GC_API void * GC_gcj_malloc_ignore_off_page(size_t lb,
+GC_API void  * GC_CALL GC_gcj_malloc_ignore_off_page(size_t lb,
 				void * ptr_to_struct_containing_descr);
 
 /* The kind numbers of normal and debug gcj objects.		*/
diff -ru bdwgc/include/gc_mark.h updated/bdwgc/include/gc_mark.h
--- bdwgc/include/gc_mark.h	2008-10-11 13:04:49.000000000 +0400
+++ updated/bdwgc/include/gc_mark.h	2008-10-16 23:04:41.000000000 +0400
@@ -180,7 +180,7 @@
 /* cause a GC crash if they are accidentally traced.			*/
 void * GC_generic_malloc(size_t lb, int k);
 
-typedef void (*GC_describe_type_fn) (void *p, char *out_buf);
+typedef void (GC_CALLBACK * GC_describe_type_fn) (void *p, char *out_buf);
 				/* A procedure which			*/
 				/* produces a human-readable 		*/
 				/* description of the "type" of object	*/
@@ -194,7 +194,7 @@
 				/* global free list.			*/
 #	define GC_TYPE_DESCR_LEN 40
 
-void GC_register_describe_type_fn(int kind, GC_describe_type_fn knd);
+void GC_CALL GC_register_describe_type_fn(int kind, GC_describe_type_fn knd);
 				/* Register a describe_type function	*/
 				/* to be used when printing objects	*/
 				/* of a particular kind.		*/
diff -ru bdwgc/include/gc_typed.h updated/bdwgc/include/gc_typed.h
--- bdwgc/include/gc_typed.h	2008-10-11 11:51:32.000000000 +0400
+++ updated/bdwgc/include/gc_typed.h	2008-10-16 16:38:10.000000000 +0400
@@ -47,7 +47,7 @@
 
 typedef GC_word GC_descr;
 
-GC_API GC_descr GC_make_descriptor(GC_bitmap bm, size_t len);
+GC_API GC_descr GC_CALL GC_make_descriptor(GC_bitmap bm, size_t len);
 		/* Return a type descriptor for the object whose layout	*/
 		/* is described by the argument.			*/
 		/* The least significant bit of the first word is one	*/
@@ -74,15 +74,16 @@
 /* ...									*/
 /* T_descr = GC_make_descriptor(T_bitmap, GC_WORD_LEN(T));		*/
 
-GC_API void * GC_malloc_explicitly_typed(size_t size_in_bytes, GC_descr d);
+GC_API void * GC_CALL GC_malloc_explicitly_typed(size_t size_in_bytes,
+						GC_descr d);
 		/* Allocate an object whose layout is described by d.	*/
 		/* The resulting object MAY NOT BE PASSED TO REALLOC.	*/
 		/* The returned object is cleared.			*/
 
-GC_API void * GC_malloc_explicitly_typed_ignore_off_page
+GC_API void * GC_CALL GC_malloc_explicitly_typed_ignore_off_page
                         (size_t size_in_bytes, GC_descr d);
 		
-GC_API void * GC_calloc_explicitly_typed(size_t nelements,
+GC_API void * GC_CALL GC_calloc_explicitly_typed(size_t nelements,
   				         size_t element_size_in_bytes,
   				         GC_descr d);
   	/* Allocate an array of nelements elements, each of the	*/
diff -ru bdwgc/include/javaxfc.h updated/bdwgc/include/javaxfc.h
--- bdwgc/include/javaxfc.h	2008-10-11 11:52:52.000000000 +0400
+++ updated/bdwgc/include/javaxfc.h	2008-10-16 16:38:21.000000000 +0400
@@ -20,7 +20,7 @@
  *    probably unlikely.
  * Thus this is not recommended for general use.
  */
-GC_API void GC_finalize_all(void);
+GC_API void GC_CALL GC_finalize_all(void);
 
 # ifdef __cplusplus
     }  /* end of extern "C" */
diff -ru bdwgc/include/private/gc_locks.h updated/bdwgc/include/private/gc_locks.h
--- bdwgc/include/private/gc_locks.h	2008-10-11 14:25:01.000000000 +0400
+++ updated/bdwgc/include/private/gc_locks.h	2008-10-17 10:52:15.000000000 +0400
@@ -29,7 +29,7 @@
 # ifdef THREADS
 #  include <atomic_ops.h>
 
-   void GC_noop1(word);
+   GC_API void GC_CALL GC_noop1(word);
 #  ifdef PCR
 #    include <base/PCR_Base.h>
 #    include <th/PCR_Th.h>
diff -ru bdwgc/include/private/gc_priv.h updated/bdwgc/include/private/gc_priv.h
--- bdwgc/include/private/gc_priv.h	2008-10-11 12:40:16.000000000 +0400
+++ updated/bdwgc/include/private/gc_priv.h	2008-10-17 10:52:28.000000000 +0400
@@ -1649,7 +1649,7 @@
 				/* reclaimed bytes to *count.		*/
 GC_bool GC_block_empty(hdr * hhdr);
  				/* Block completely unmarked? 	*/
-GC_bool GC_never_stop_func(void);
+GC_bool GC_CALLBACK GC_never_stop_func(void);
 				/* Returns FALSE.		*/
 GC_bool GC_try_to_collect_inner(GC_stop_func f);
 
@@ -1760,7 +1760,7 @@
 			/* this procedure yet this GC cycle.		*/
 
 GC_API void * GC_make_closure(GC_finalization_proc fn, void * data);
-GC_API void GC_debug_invoke_finalizer(void * obj, void * data);
+GC_API void GC_CALLBACK GC_debug_invoke_finalizer(void * obj, void * data);
 			/* Auxiliary fns to make finalization work	*/
 			/* correctly with displaced pointers introduced	*/
 			/* by the debugging allocators.			*/
@@ -1923,7 +1923,7 @@
 #   endif
 # endif
 
-void GC_noop1(word);
+GC_API void GC_CALL GC_noop1(word);
 
 /* Logging and diagnostic output: 	*/
 GC_API void GC_printf (const char * format, ...);
diff -ru bdwgc/malloc.c updated/bdwgc/malloc.c
--- bdwgc/malloc.c	2008-10-14 17:37:54.000000000 +0400
+++ updated/bdwgc/malloc.c	2008-10-16 16:23:24.000000000 +0400
@@ -206,7 +206,7 @@
 #ifdef THREAD_LOCAL_ALLOC
   void * GC_core_malloc_atomic(size_t lb)
 #else
-  GC_API void * GC_malloc_atomic(size_t lb)
+  GC_API void * GC_CALL GC_malloc_atomic(size_t lb)
 #endif
 {
     void *op;
@@ -233,7 +233,7 @@
 
 /* provide a version of strdup() that uses the collector to allocate the
    copy of the string */
-GC_API char *GC_strdup(const char *s)
+GC_API char * GC_CALL GC_strdup(const char *s)
 {
   char *copy;
 
@@ -250,7 +250,7 @@
 #ifdef THREAD_LOCAL_ALLOC
   void * GC_core_malloc(size_t lb)
 #else
-  GC_API void * GC_malloc(size_t lb)
+  GC_API void * GC_CALL GC_malloc(size_t lb)
 #endif
 {
     void *op;
@@ -386,7 +386,7 @@
 # endif /* REDIRECT_MALLOC */
 
 /* Explicitly deallocate an object p.				*/
-GC_API void GC_free(void * p)
+GC_API void GC_CALL GC_free(void * p)
 {
     struct hblk *h;
     hdr *hhdr;
diff -ru bdwgc/mallocx.c updated/bdwgc/mallocx.c
--- bdwgc/mallocx.c	2008-10-14 17:38:48.000000000 +0400
+++ updated/bdwgc/mallocx.c	2008-10-16 16:24:30.000000000 +0400
@@ -64,7 +64,7 @@
 /* lb bytes.  The object may be (and quite likely will be) moved.     */
 /* The kind (e.g. atomic) is the same as that of the old.	      */
 /* Shrinking of large blocks is not implemented well.                 */
-GC_API void * GC_realloc(void * p, size_t lb)
+GC_API void * GC_CALL GC_realloc(void * p, size_t lb)
 {
     struct hblk * h;
     hdr * hhdr;
@@ -210,12 +210,12 @@
     }
 }
 
-GC_API void * GC_malloc_ignore_off_page(size_t lb)
+GC_API void * GC_CALL GC_malloc_ignore_off_page(size_t lb)
 {
     return((void *)GC_generic_malloc_ignore_off_page(lb, NORMAL));
 }
 
-GC_API void * GC_malloc_atomic_ignore_off_page(size_t lb)
+GC_API void * GC_CALL GC_malloc_atomic_ignore_off_page(size_t lb)
 {
     return((void *)GC_generic_malloc_ignore_off_page(lb, PTRFREE));
 }
@@ -420,7 +420,7 @@
     (void) GC_clear_stack(0);
 }
 
-GC_API void * GC_malloc_many(size_t lb)
+GC_API void * GC_CALL GC_malloc_many(size_t lb)
 {
     void *result;
     GC_generic_malloc_many(((lb + EXTRA_BYTES + GRANULE_BYTES-1)
@@ -434,7 +434,7 @@
 # endif
 
 /* Allocate lb bytes of pointerful, traced, but not collectable data */
-GC_API void * GC_malloc_uncollectable(size_t lb)
+GC_API void * GC_CALL GC_malloc_uncollectable(size_t lb)
 {
     void *op;
     void **opp;
@@ -522,7 +522,7 @@
 /* Allocate lb bytes of pointerfree, untraced, uncollectable data 	*/
 /* This is normally roughly equivalent to the system malloc.		*/
 /* But it may be useful if malloc is redefined.				*/
-GC_API void * GC_malloc_atomic_uncollectable(size_t lb)
+GC_API void * GC_CALL GC_malloc_atomic_uncollectable(size_t lb)
 {
     void *op;
     void **opp;
diff -ru bdwgc/mark.c updated/bdwgc/mark.c
--- bdwgc/mark.c	2008-10-14 17:39:42.000000000 +0400
+++ updated/bdwgc/mark.c	2008-10-16 16:25:01.000000000 +0400
@@ -32,7 +32,7 @@
 #endif
 
 /* Single argument version, robust against whole program analysis. */
-GC_API void GC_noop1(word x)
+GC_API void GC_CALL GC_noop1(word x)
 {
     static volatile word sink;
 
diff -ru bdwgc/mark_rts.c updated/bdwgc/mark_rts.c
--- bdwgc/mark_rts.c	2008-10-11 13:16:08.000000000 +0400
+++ updated/bdwgc/mark_rts.c	2008-10-16 16:25:34.000000000 +0400
@@ -142,7 +142,7 @@
 
 word GC_root_size = 0;
 
-GC_API void GC_add_roots(void *b, void *e)
+GC_API void GC_CALL GC_add_roots(void *b, void *e)
 {
     DCL_LOCK_STATE;
     
@@ -242,7 +242,7 @@
 
 static GC_bool roots_were_cleared = FALSE;
 
-GC_API void GC_clear_roots (void)
+GC_API void GC_CALL GC_clear_roots (void)
 {
     DCL_LOCK_STATE;
     
@@ -303,7 +303,7 @@
 #endif
 
 #if !defined(MSWIN32) && !defined(MSWINCE)
-GC_API void GC_remove_roots(void *b, void *e)
+GC_API void GC_CALL GC_remove_roots(void *b, void *e)
 {
     DCL_LOCK_STATE;
     
@@ -406,7 +406,7 @@
     return GC_excl_table + low;
 }
 
-GC_API void GC_exclude_static_roots(void *start, void *finish)
+GC_API void GC_CALL GC_exclude_static_roots(void *start, void *finish)
 {
     struct exclusion * next;
     size_t next_index, i;
diff -ru bdwgc/misc.c updated/bdwgc/misc.c
--- bdwgc/misc.c	2008-10-14 17:42:02.000000000 +0400
+++ updated/bdwgc/misc.c	2008-10-16 18:58:00.000000000 +0400
@@ -123,7 +123,7 @@
 	/* Number of warnings suppressed so far.	*/
 
 /*ARGSUSED*/
-STATIC void * GC_default_oom_fn(size_t bytes_requested)
+STATIC void * GC_CALLBACK GC_default_oom_fn(size_t bytes_requested)
 {
     return(0);
 }
@@ -324,7 +324,7 @@
 
 /* Return a pointer to the base address of p, given a pointer to a	*/
 /* an address within an object.  Return 0 o.w.				*/
-GC_API void * GC_base(void * p)
+GC_API void * GC_CALL GC_base(void * p)
 {
     ptr_t r;
     struct hblk *h;
@@ -367,29 +367,29 @@
 /* Return the size of an object, given a pointer to its base.		*/
 /* (For small objects this also happens to work from interior pointers,	*/
 /* but that shouldn't be relied upon.)					*/
-GC_API size_t GC_size(void * p)
+GC_API size_t GC_CALL GC_size(void * p)
 {
     hdr * hhdr = HDR(p);
     GC_ASSERT(hhdr != NULL);
     return hhdr -> hb_sz;
 }
 
-GC_API size_t GC_get_heap_size(void)
+GC_API size_t GC_CALL GC_get_heap_size(void)
 {
     return GC_heapsize;
 }
 
-GC_API size_t GC_get_free_bytes(void)
+GC_API size_t GC_CALL GC_get_free_bytes(void)
 {
     return GC_large_free_bytes;
 }
 
-GC_API size_t GC_get_bytes_since_gc(void)
+GC_API size_t GC_CALL GC_get_bytes_since_gc(void)
 {
     return GC_bytes_allocd;
 }
 
-GC_API size_t GC_get_total_bytes(void)
+GC_API size_t GC_CALL GC_get_total_bytes(void)
 {
     return GC_bytes_allocd+GC_bytes_allocd_before_gc;
 }
@@ -401,7 +401,7 @@
 # endif /* PARALLEL_MARK || THREAD_LOCAL_ALLOC */
 
 /* FIXME: The GC_init/GC_init_inner distinction should go away. */
-GC_API void GC_init(void)
+GC_API void GC_CALL GC_init(void)
 {
     /* LOCK(); -- no longer does anything this early. */
     GC_init_inner();
@@ -769,7 +769,7 @@
 #   endif
 }
 
-GC_API void GC_enable_incremental(void)
+GC_API void GC_CALL GC_enable_incremental(void)
 {
 # if !defined(SMALL_CONFIG) && !defined(KEEP_BACK_PTRS)
   /* If we are keeping back pointers, the GC itself dirties all	*/
@@ -1017,14 +1017,14 @@
 }
 #endif
 
-STATIC void GC_default_warn_proc(char *msg, GC_word arg)
+STATIC void GC_CALLBACK GC_default_warn_proc(char *msg, GC_word arg)
 {
     GC_err_printf(msg, arg);
 }
 
 GC_warn_proc GC_current_warn_proc = GC_default_warn_proc;
 
-GC_API GC_warn_proc GC_set_warn_proc(GC_warn_proc p)
+GC_API GC_warn_proc GC_CALL GC_set_warn_proc(GC_warn_proc p)
 {
     GC_warn_proc result;
 
@@ -1039,7 +1039,7 @@
     return(result);
 }
 
-GC_API GC_word GC_set_free_space_divisor (GC_word value)
+GC_API GC_word GC_CALL GC_set_free_space_divisor (GC_word value)
 {
     GC_word old = GC_free_space_divisor;
     if (value != ~(GC_word)0)
@@ -1070,14 +1070,14 @@
 }
 #endif
 
-GC_API void GC_enable(void)
+GC_API void GC_CALL GC_enable(void)
 {
     LOCK();
     GC_dont_gc--;
     UNLOCK();
 }
 
-GC_API void GC_disable(void)
+GC_API void GC_CALL GC_disable(void)
 {
     LOCK();
     GC_dont_gc++;
@@ -1143,7 +1143,7 @@
     return result;
 }
 
-GC_API void * GC_call_with_stack_base(GC_stack_base_func fn, void *arg)
+GC_API void * GC_CALL GC_call_with_stack_base(GC_stack_base_func fn, void *arg)
 {
     int dummy;
     struct GC_stack_base base;
@@ -1159,7 +1159,7 @@
 
 #if !defined(NO_DEBUGGING)
 
-GC_API void GC_dump(void)
+GC_API void GC_CALL GC_dump(void)
 {
     GC_printf("***Static roots:\n");
     GC_print_static_roots();
@@ -1175,17 +1175,17 @@
 
 #endif /* NO_DEBUGGING */
 
-GC_API GC_word GC_get_gc_no(void)
+GC_API GC_word GC_CALL GC_get_gc_no(void)
 {
     return GC_gc_no;
 }
 
-GC_API int GC_get_parallel(void)
+GC_API int GC_CALL GC_get_parallel(void)
 {
     return GC_parallel;
 }
 
-GC_API GC_oom_func GC_set_oom_fn(GC_oom_func fn)
+GC_API GC_oom_func GC_CALL GC_set_oom_fn(GC_oom_func fn)
 {
     GC_oom_func ofn = GC_oom_fn;
     if (fn != (GC_oom_func)0)
@@ -1193,7 +1193,7 @@
     return ofn;
 }
 
-GC_API GC_finalizer_notifier_proc GC_set_finalizer_notifier(
+GC_API GC_finalizer_notifier_proc GC_CALL GC_set_finalizer_notifier(
 					GC_finalizer_notifier_proc fn)
 {
     GC_finalizer_notifier_proc ofn = GC_finalizer_notifier;
@@ -1202,7 +1202,7 @@
     return ofn;
 }
 
-GC_API int GC_set_finalize_on_demand(int value)
+GC_API int GC_CALL GC_set_finalize_on_demand(int value)
 {
     int ovalue = GC_finalize_on_demand;
     if (value != -1)
@@ -1210,7 +1210,7 @@
     return ovalue;
 }
 
-GC_API int GC_set_java_finalization(int value)
+GC_API int GC_CALL GC_set_java_finalization(int value)
 {
     int ovalue = GC_java_finalization;
     if (value != -1)
@@ -1218,7 +1218,7 @@
     return ovalue;
 }
 
-GC_API int GC_set_dont_expand(int value)
+GC_API int GC_CALL GC_set_dont_expand(int value)
 {
     int ovalue = GC_dont_expand;
     if (value != -1)
@@ -1226,7 +1226,7 @@
     return ovalue;
 }
 
-GC_API int GC_set_no_dls(int value)
+GC_API int GC_CALL GC_set_no_dls(int value)
 {
     int ovalue = GC_no_dls;
     if (value != -1)
@@ -1234,7 +1234,7 @@
     return ovalue;
 }
 
-GC_API GC_word GC_set_max_retries(GC_word value)
+GC_API GC_word GC_CALL GC_set_max_retries(GC_word value)
 {
     GC_word ovalue = GC_max_retries;
     if (value != ~(GC_word)0)
@@ -1242,7 +1242,7 @@
     return ovalue;
 }
 
-GC_API int GC_set_dont_precollect(int value)
+GC_API int GC_CALL GC_set_dont_precollect(int value)
 {
     int ovalue = GC_dont_precollect;
     if (value != -1)
diff -ru bdwgc/obj_map.c updated/bdwgc/obj_map.c
--- bdwgc/obj_map.c	2008-07-26 04:51:34.000000000 +0400
+++ updated/bdwgc/obj_map.c	2008-10-16 16:27:33.000000000 +0400
@@ -24,7 +24,7 @@
 /* Consider pointers that are offset bytes displaced from the beginning */
 /* of an object to be valid.                                            */
 
-GC_API void GC_register_displacement(size_t offset)
+GC_API void GC_CALL GC_register_displacement(size_t offset)
 {
     DCL_LOCK_STATE;
     


More information about the Gc mailing list