]> granicus.if.org Git - gc/commitdiff
Fix MS VC redefinition warning for functions declared with GC_ATTR_MALLOC
authorIvan Maidanski <ivmai@mail.ru>
Tue, 22 Apr 2014 21:28:32 +0000 (01:28 +0400)
committerIvan Maidanski <ivmai@mail.ru>
Tue, 22 Apr 2014 21:28:32 +0000 (01:28 +0400)
* dbg_mlc.c (GC_debug_malloc, GC_debug_malloc_ignore_off_page,
GC_debug_malloc_atomic_ignore_off_page, GC_debug_malloc_stubborn,
GC_debug_malloc_atomic, GC_debug_strdup, GC_debug_strndup,
GC_debug_wcsdup, GC_debug_malloc_uncollectable,
GC_debug_malloc_atomic_uncollectable,
GC_debug_generic_or_special_malloc, GC_debug_malloc_replacement): Add
GC_ATTR_MALLOC attribute to API function definition (to avoid MS VC
warning about redefinition of a symbol previously declared with
__declspec).
* fnlz_mlc.c (GC_finalized_malloc): Likewise.
* gcj_mlc.c (GC_gcj_malloc, GC_debug_gcj_malloc,
GC_gcj_malloc_ignore_off_page): Likewise.
* malloc.c (GC_generic_malloc, GC_malloc_atomic, GC_malloc,
GC_malloc_uncollectable): Likewise.
* mallocx.c (GC_generic_or_special_malloc,
GC_generic_malloc_ignore_off_page, GC_malloc_ignore_off_page,
GC_malloc_atomic_ignore_off_page, GC_malloc_many, GC_memalign,
GC_malloc_atomic_uncollectable, GC_strdup, GC_strndup, GC_wcsdup):
Likewise.
* stubborn.c (GC_malloc_stubborn): Likewise.
* thread_local_alloc.c (GC_malloc, GC_malloc_atomic, GC_gcj_malloc):
Likewise.
* typd_mlc.c (GC_malloc_explicitly_typed,
GC_malloc_explicitly_typed_ignore_off_page,
GC_calloc_explicitly_typed): Likewise.

dbg_mlc.c
fnlz_mlc.c
gcj_mlc.c
malloc.c
mallocx.c
stubborn.c
thread_local_alloc.c
typd_mlc.c

index da4b86f34758b9816ee9d5f5fb3c23fa7f832581..fef1a251de93dc06eb9164ac1df5fda20ed19483 100644 (file)
--- a/dbg_mlc.c
+++ b/dbg_mlc.c
@@ -506,7 +506,8 @@ GC_API void GC_CALL GC_debug_register_displacement(size_t offset)
 # endif
 #endif /* GC_ADD_CALLER */
 
-GC_API void * GC_CALL GC_debug_malloc(size_t lb, GC_EXTRA_PARAMS)
+GC_API GC_ATTR_MALLOC void * GC_CALL GC_debug_malloc(size_t lb,
+                                                     GC_EXTRA_PARAMS)
 {
     void * result;
 
@@ -531,8 +532,8 @@ GC_API void * GC_CALL GC_debug_malloc(size_t lb, GC_EXTRA_PARAMS)
     return (GC_store_debug_info(result, (word)lb, s, i));
 }
 
-GC_API void * GC_CALL GC_debug_malloc_ignore_off_page(size_t lb,
-                                                      GC_EXTRA_PARAMS)
+GC_API GC_ATTR_MALLOC void * GC_CALL
+    GC_debug_malloc_ignore_off_page(size_t lb, GC_EXTRA_PARAMS)
 {
     void * result = GC_malloc_ignore_off_page(lb + DEBUG_BYTES);
 
@@ -548,8 +549,8 @@ GC_API void * GC_CALL GC_debug_malloc_ignore_off_page(size_t lb,
     return (GC_store_debug_info(result, (word)lb, s, i));
 }
 
-GC_API void * GC_CALL GC_debug_malloc_atomic_ignore_off_page(size_t lb,
-                                                             GC_EXTRA_PARAMS)
+GC_API GC_ATTR_MALLOC void * GC_CALL
+    GC_debug_malloc_atomic_ignore_off_page(size_t lb, GC_EXTRA_PARAMS)
 {
     void * result = GC_malloc_atomic_ignore_off_page(lb + DEBUG_BYTES);
 
@@ -624,7 +625,8 @@ STATIC void * GC_debug_generic_malloc(size_t lb, int knd, GC_EXTRA_PARAMS)
 #endif /* DBG_HDRS_ALL */
 
 #ifdef STUBBORN_ALLOC
-  GC_API void * GC_CALL GC_debug_malloc_stubborn(size_t lb, GC_EXTRA_PARAMS)
+  GC_API GC_ATTR_MALLOC void * GC_CALL GC_debug_malloc_stubborn(size_t lb,
+                                                        GC_EXTRA_PARAMS)
   {
     void * result = GC_malloc_stubborn(lb + DEBUG_BYTES);
 
@@ -673,7 +675,8 @@ STATIC void * GC_debug_generic_malloc(size_t lb, int knd, GC_EXTRA_PARAMS)
 
 #else /* !STUBBORN_ALLOC */
 
-  GC_API void * GC_CALL GC_debug_malloc_stubborn(size_t lb, GC_EXTRA_PARAMS)
+  GC_API GC_ATTR_MALLOC void * GC_CALL GC_debug_malloc_stubborn(size_t lb,
+                                                        GC_EXTRA_PARAMS)
   {
     return GC_debug_malloc(lb, OPT_RA s, i);
   }
@@ -685,7 +688,8 @@ STATIC void * GC_debug_generic_malloc(size_t lb, int knd, GC_EXTRA_PARAMS)
                                 const void * p GC_ATTR_UNUSED) {}
 #endif /* !STUBBORN_ALLOC */
 
-GC_API void * GC_CALL GC_debug_malloc_atomic(size_t lb, GC_EXTRA_PARAMS)
+GC_API GC_ATTR_MALLOC void * GC_CALL GC_debug_malloc_atomic(size_t lb,
+                                                            GC_EXTRA_PARAMS)
 {
     void * result = GC_malloc_atomic(lb + DEBUG_BYTES);
 
@@ -701,7 +705,8 @@ GC_API void * GC_CALL GC_debug_malloc_atomic(size_t lb, GC_EXTRA_PARAMS)
     return (GC_store_debug_info(result, (word)lb, s, i));
 }
 
-GC_API char * GC_CALL GC_debug_strdup(const char *str, GC_EXTRA_PARAMS)
+GC_API GC_ATTR_MALLOC char * GC_CALL GC_debug_strdup(const char *str,
+                                                     GC_EXTRA_PARAMS)
 {
   char *copy;
   size_t lb;
@@ -723,8 +728,8 @@ GC_API char * GC_CALL GC_debug_strdup(const char *str, GC_EXTRA_PARAMS)
   return copy;
 }
 
-GC_API char * GC_CALL GC_debug_strndup(const char *str, size_t size,
-                                       GC_EXTRA_PARAMS)
+GC_API GC_ATTR_MALLOC char * GC_CALL GC_debug_strndup(const char *str,
+                                                size_t size, GC_EXTRA_PARAMS)
 {
   char *copy;
   size_t len = strlen(str); /* str is expected to be non-NULL  */
@@ -745,7 +750,8 @@ GC_API char * GC_CALL GC_debug_strndup(const char *str, size_t size,
 #ifdef GC_REQUIRE_WCSDUP
 # include <wchar.h> /* for wcslen() */
 
-  GC_API wchar_t * GC_CALL GC_debug_wcsdup(const wchar_t *str, GC_EXTRA_PARAMS)
+  GC_API GC_ATTR_MALLOC wchar_t * GC_CALL GC_debug_wcsdup(const wchar_t *str,
+                                                          GC_EXTRA_PARAMS)
   {
     size_t lb = (wcslen(str) + 1) * sizeof(wchar_t);
     wchar_t *copy = GC_debug_malloc_atomic(lb, OPT_RA s, i);
@@ -760,8 +766,8 @@ GC_API char * GC_CALL GC_debug_strndup(const char *str, size_t size,
   }
 #endif /* GC_REQUIRE_WCSDUP */
 
-GC_API void * GC_CALL GC_debug_malloc_uncollectable(size_t lb,
-                                                    GC_EXTRA_PARAMS)
+GC_API GC_ATTR_MALLOC void * GC_CALL GC_debug_malloc_uncollectable(size_t lb,
+                                                        GC_EXTRA_PARAMS)
 {
     void * result = GC_malloc_uncollectable(lb + UNCOLLECTABLE_DEBUG_BYTES);
 
@@ -778,8 +784,8 @@ GC_API void * GC_CALL GC_debug_malloc_uncollectable(size_t lb,
 }
 
 #ifdef ATOMIC_UNCOLLECTABLE
-  GC_API void * GC_CALL GC_debug_malloc_atomic_uncollectable(size_t lb,
-                                                             GC_EXTRA_PARAMS)
+  GC_API GC_ATTR_MALLOC void * GC_CALL
+        GC_debug_malloc_atomic_uncollectable(size_t lb, GC_EXTRA_PARAMS)
   {
     void * result =
         GC_malloc_atomic_uncollectable(lb + UNCOLLECTABLE_DEBUG_BYTES);
@@ -941,8 +947,8 @@ GC_API void * GC_CALL GC_debug_realloc(void * p, size_t lb, GC_EXTRA_PARAMS)
     return(result);
 }
 
-GC_API void * GC_CALL GC_debug_generic_or_special_malloc(size_t lb, int knd,
-                                                         GC_EXTRA_PARAMS)
+GC_API GC_ATTR_MALLOC void * GC_CALL
+    GC_debug_generic_or_special_malloc(size_t lb, int knd, GC_EXTRA_PARAMS)
 {
     switch (knd) {
 #     ifdef STUBBORN_ALLOC
@@ -1247,7 +1253,7 @@ GC_API void GC_CALL GC_debug_register_finalizer_ignore_self
 
 #endif /* !GC_NO_FINALIZATION */
 
-GC_API void * GC_CALL GC_debug_malloc_replacement(size_t lb)
+GC_API GC_ATTR_MALLOC void * GC_CALL GC_debug_malloc_replacement(size_t lb)
 {
     return GC_debug_malloc(lb, GC_DBG_EXTRAS);
 }
index 23735bdbb79d3e02563e2c53d5812da3ebbebc07..5eb168a302f06b384eb11774038ed21cd5659fd9 100644 (file)
@@ -81,7 +81,7 @@ GC_API void GC_CALL GC_register_disclaim_proc(int kind, GC_disclaim_proc proc,
   STATIC void * GC_core_finalized_malloc(size_t lb,
                                 const struct GC_finalizer_closure *fclos)
 #else
-  GC_API void * GC_CALL GC_finalized_malloc(size_t lb,
+  GC_API GC_ATTR_MALLOC void * GC_CALL GC_finalized_malloc(size_t lb,
                                 const struct GC_finalizer_closure *fclos)
 #endif
 {
@@ -125,7 +125,7 @@ GC_API void GC_CALL GC_register_disclaim_proc(int kind, GC_disclaim_proc proc,
 }
 
 #ifdef THREAD_LOCAL_ALLOC
-  GC_API void * GC_CALL GC_finalized_malloc(size_t client_lb,
+  GC_API GC_ATTR_MALLOC void * GC_CALL GC_finalized_malloc(size_t client_lb,
                                 const struct GC_finalizer_closure *fclos)
   {
     size_t lb = client_lb + sizeof(void *);
index c2aee253ab90f6bd0759f475e06ccd305534f8b3..195a215ae1227b2e39f7e0db65321c13c368e4c9 100644 (file)
--- a/gcj_mlc.c
+++ b/gcj_mlc.c
@@ -159,7 +159,7 @@ static void maybe_finalize(void)
   GC_INNER void * GC_core_gcj_malloc(size_t lb,
                                      void * ptr_to_struct_containing_descr)
 #else
-  GC_API void * GC_CALL GC_gcj_malloc(size_t lb,
+  GC_API GC_ATTR_MALLOC void * GC_CALL GC_gcj_malloc(size_t lb,
                                       void * ptr_to_struct_containing_descr)
 #endif
 {
@@ -204,7 +204,7 @@ static void maybe_finalize(void)
 
 /* Similar to GC_gcj_malloc, but add debug info.  This is allocated     */
 /* with GC_gcj_debug_kind.                                              */
-GC_API void * GC_CALL GC_debug_gcj_malloc(size_t lb,
+GC_API GC_ATTR_MALLOC void * GC_CALL GC_debug_gcj_malloc(size_t lb,
                 void * ptr_to_struct_containing_descr, GC_EXTRA_PARAMS)
 {
     void * result;
@@ -232,7 +232,7 @@ GC_API void * GC_CALL GC_debug_gcj_malloc(size_t lb,
 }
 
 /* There is no THREAD_LOCAL_ALLOC for GC_gcj_malloc_ignore_off_page().  */
-GC_API void * GC_CALL GC_gcj_malloc_ignore_off_page(size_t lb,
+GC_API GC_ATTR_MALLOC void * GC_CALL GC_gcj_malloc_ignore_off_page(size_t lb,
                                      void * ptr_to_struct_containing_descr)
 {
     ptr_t op;
index 58aa55abda22261847d4dbd8e81f9457249be0da..a4dd437f49114dd021144aed6c792edca1ad042f 100644 (file)
--- a/malloc.c
+++ b/malloc.c
@@ -167,7 +167,7 @@ GC_INNER void * GC_generic_malloc_inner_ignore_off_page(size_t lb, int k)
   size_t GC_dbg_collect_at_malloc_min_lb = (GC_COLLECT_AT_MALLOC);
 #endif
 
-GC_API void * GC_CALL GC_generic_malloc(size_t lb, int k)
+GC_API GC_ATTR_MALLOC void * GC_CALL GC_generic_malloc(size_t lb, int k)
 {
     void * result;
     DCL_LOCK_STATE;
@@ -225,7 +225,7 @@ GC_API void * GC_CALL GC_generic_malloc(size_t lb, int k)
 #ifdef THREAD_LOCAL_ALLOC
   GC_INNER void * GC_core_malloc_atomic(size_t lb)
 #else
-  GC_API void * GC_CALL GC_malloc_atomic(size_t lb)
+  GC_API GC_ATTR_MALLOC void * GC_CALL GC_malloc_atomic(size_t lb)
 #endif
 {
     void *op;
@@ -254,7 +254,7 @@ GC_API void * GC_CALL GC_generic_malloc(size_t lb, int k)
 #ifdef THREAD_LOCAL_ALLOC
   GC_INNER void * GC_core_malloc(size_t lb)
 #else
-  GC_API void * GC_CALL GC_malloc(size_t lb)
+  GC_API GC_ATTR_MALLOC void * GC_CALL GC_malloc(size_t lb)
 #endif
 {
     void *op;
@@ -286,7 +286,7 @@ GC_API void * GC_CALL GC_generic_malloc(size_t lb, int k)
 }
 
 /* Allocate lb bytes of pointerful, traced, but not collectible data.   */
-GC_API void * GC_CALL GC_malloc_uncollectable(size_t lb)
+GC_API GC_ATTR_MALLOC void * GC_CALL GC_malloc_uncollectable(size_t lb)
 {
     void *op;
     size_t lg;
index 6cbcf6c1675013ba3ae09f96b95ffc10c906a829..b559371cd32f038e0d16750c43b4fa3dc862500c 100644 (file)
--- a/mallocx.c
+++ b/mallocx.c
@@ -56,7 +56,8 @@ GC_API int GC_CALL GC_get_kind_and_size(const void * p, size_t * psize)
     return hhdr -> hb_obj_kind;
 }
 
-GC_API void * GC_CALL GC_generic_or_special_malloc(size_t lb, int knd)
+GC_API GC_ATTR_MALLOC void * GC_CALL GC_generic_or_special_malloc(size_t lb,
+                                                                  int knd)
 {
     switch(knd) {
 #     ifdef STUBBORN_ALLOC
@@ -143,8 +144,7 @@ GC_API void * GC_CALL GC_realloc(void * p, size_t lb)
         }
     } else {
         /* grow */
-          void * result =
-                GC_generic_or_special_malloc((word)lb, obj_kind);
+          void * result = GC_generic_or_special_malloc((word)lb, obj_kind);
 
           if (result == 0) return(0);
           BCOPY(p, result, sz);
@@ -176,7 +176,8 @@ void * realloc(void * p, size_t lb)
 /* Allocate memory such that only pointers to near the          */
 /* beginning of the object are considered.                      */
 /* We avoid holding allocation lock while we clear the memory.  */
-GC_API void * GC_CALL GC_generic_malloc_ignore_off_page(size_t lb, int k)
+GC_API GC_ATTR_MALLOC void * GC_CALL
+    GC_generic_malloc_ignore_off_page(size_t lb, int k)
 {
     void *result;
     size_t lg;
@@ -227,12 +228,13 @@ GC_API void * GC_CALL GC_generic_malloc_ignore_off_page(size_t lb, int k)
     }
 }
 
-GC_API void * GC_CALL GC_malloc_ignore_off_page(size_t lb)
+GC_API GC_ATTR_MALLOC void * GC_CALL GC_malloc_ignore_off_page(size_t lb)
 {
     return GC_generic_malloc_ignore_off_page(lb, NORMAL);
 }
 
-GC_API void * GC_CALL GC_malloc_atomic_ignore_off_page(size_t lb)
+GC_API GC_ATTR_MALLOC void * GC_CALL
+    GC_malloc_atomic_ignore_off_page(size_t lb)
 {
     return GC_generic_malloc_ignore_off_page(lb, PTRFREE);
 }
@@ -442,7 +444,7 @@ GC_API void GC_CALL GC_generic_malloc_many(size_t lb, int k, void **result)
 
 /* Note that the "atomic" version of this would be unsafe, since the    */
 /* links would not be seen by the collector.                            */
-GC_API void * GC_CALL GC_malloc_many(size_t lb)
+GC_API GC_ATTR_MALLOC void * GC_CALL GC_malloc_many(size_t lb)
 {
     void *result;
 
@@ -455,7 +457,7 @@ GC_API void * GC_CALL GC_malloc_many(size_t lb)
 /* Debug version is tricky and currently missing.       */
 #include <limits.h>
 
-GC_API void * GC_CALL GC_memalign(size_t align, size_t lb)
+GC_API GC_ATTR_MALLOC void * GC_CALL GC_memalign(size_t align, size_t lb)
 {
     size_t new_lb;
     size_t offset;
@@ -514,7 +516,8 @@ GC_API int GC_CALL GC_posix_memalign(void **memptr, size_t align, size_t lb)
   /* Allocate lb bytes of pointer-free, untraced, uncollectible data    */
   /* This is normally roughly equivalent to the system malloc.          */
   /* But it may be useful if malloc is redefined.                       */
-  GC_API void * GC_CALL GC_malloc_atomic_uncollectable(size_t lb)
+  GC_API GC_ATTR_MALLOC void * GC_CALL
+        GC_malloc_atomic_uncollectable(size_t lb)
   {
     void *op;
     size_t lg;
@@ -564,7 +567,7 @@ GC_API int GC_CALL GC_posix_memalign(void **memptr, size_t align, size_t lb)
 
 /* provide a version of strdup() that uses the collector to allocate the
    copy of the string */
-GC_API char * GC_CALL GC_strdup(const char *s)
+GC_API GC_ATTR_MALLOC char * GC_CALL GC_strdup(const char *s)
 {
   char *copy;
   size_t lb;
@@ -580,7 +583,7 @@ GC_API char * GC_CALL GC_strdup(const char *s)
   return copy;
 }
 
-GC_API char * GC_CALL GC_strndup(const char *str, size_t size)
+GC_API GC_ATTR_MALLOC char * GC_CALL GC_strndup(const char *str, size_t size)
 {
   char *copy;
   size_t len = strlen(str); /* str is expected to be non-NULL  */
@@ -601,7 +604,7 @@ GC_API char * GC_CALL GC_strndup(const char *str, size_t size)
 #ifdef GC_REQUIRE_WCSDUP
 # include <wchar.h> /* for wcslen() */
 
-  GC_API wchar_t * GC_CALL GC_wcsdup(const wchar_t *str)
+  GC_API GC_ATTR_MALLOC wchar_t * GC_CALL GC_wcsdup(const wchar_t *str)
   {
     size_t lb = (wcslen(str) + 1) * sizeof(wchar_t);
     wchar_t *copy = GC_malloc_atomic(lb);
index 82f113896f985f6576c76afe129a4faaee12c369..cc5d08ae5c3e39ee7725e324c50b8221aca0bf0d 100644 (file)
@@ -24,7 +24,7 @@
 
   void GC_dirty(ptr_t p);
 
-  GC_API void * GC_CALL GC_malloc_stubborn(size_t lb)
+  GC_API GC_ATTR_MALLOC void * GC_CALL GC_malloc_stubborn(size_t lb)
   {
     return(GC_malloc(lb));
   }
@@ -40,7 +40,7 @@
 
 #else /* !MANUAL_VDB */
 
-  GC_API void * GC_CALL GC_malloc_stubborn(size_t lb)
+  GC_API GC_ATTR_MALLOC void * GC_CALL GC_malloc_stubborn(size_t lb)
   {
     return(GC_malloc(lb));
   }
index a35b0c3f5ae2552252b1c4c84cc17117d88f3242..8d184f51aacc5f836a1fc877f2e823754b20b8ce 100644 (file)
@@ -144,7 +144,7 @@ GC_INNER void GC_destroy_thread_local(GC_tlfs p)
   GC_bool GC_is_thread_tsd_valid(void *tsd);
 #endif
 
-GC_API void * GC_CALL GC_malloc(size_t bytes)
+GC_API GC_ATTR_MALLOC void * GC_CALL GC_malloc(size_t bytes)
 {
     size_t granules = ROUNDED_UP_GRANULES(bytes);
     void *tsd;
@@ -181,7 +181,7 @@ GC_API void * GC_CALL GC_malloc(size_t bytes)
     return result;
 }
 
-GC_API void * GC_CALL GC_malloc_atomic(size_t bytes)
+GC_API GC_ATTR_MALLOC void * GC_CALL GC_malloc_atomic(size_t bytes)
 {
     size_t granules = ROUNDED_UP_GRANULES(bytes);
     void *tsd;
@@ -237,7 +237,7 @@ GC_API void * GC_CALL GC_malloc_atomic(size_t bytes)
 /* incremental GC should be enabled before we fork a second thread.     */
 /* Unlike the other thread local allocation calls, we assume that the   */
 /* collector has been explicitly initialized.                           */
-GC_API void * GC_CALL GC_gcj_malloc(size_t bytes,
+GC_API GC_ATTR_MALLOC void * GC_CALL GC_gcj_malloc(size_t bytes,
                                     void * ptr_to_struct_containing_descr)
 {
   if (EXPECT(GC_incremental, FALSE)) {
index 1c546ed78f964b793f9db299680010b91ba671c9..30646a48f030dde6d3435d2e53d17fb3b92b42fb 100644 (file)
@@ -581,7 +581,8 @@ GC_API GC_descr GC_CALL GC_make_descriptor(const GC_word * bm, size_t len)
     }
 }
 
-GC_API void * GC_CALL GC_malloc_explicitly_typed(size_t lb, GC_descr d)
+GC_API GC_ATTR_MALLOC void * GC_CALL GC_malloc_explicitly_typed(size_t lb,
+                                                                GC_descr d)
 {
     ptr_t op;
     size_t lg;
@@ -615,8 +616,8 @@ GC_API void * GC_CALL GC_malloc_explicitly_typed(size_t lb, GC_descr d)
    return((void *) op);
 }
 
-GC_API void * GC_CALL GC_malloc_explicitly_typed_ignore_off_page(size_t lb,
-                                                                 GC_descr d)
+GC_API GC_ATTR_MALLOC void * GC_CALL
+    GC_malloc_explicitly_typed_ignore_off_page(size_t lb, GC_descr d)
 {
     ptr_t op;
     size_t lg;
@@ -650,8 +651,8 @@ GC_API void * GC_CALL GC_malloc_explicitly_typed_ignore_off_page(size_t lb,
    return((void *) op);
 }
 
-GC_API void * GC_CALL GC_calloc_explicitly_typed(size_t n, size_t lb,
-                                                 GC_descr d)
+GC_API GC_ATTR_MALLOC void * GC_CALL GC_calloc_explicitly_typed(size_t n,
+                                                        size_t lb, GC_descr d)
 {
     ptr_t op;
     size_t lg;