]> 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>
Fri, 2 May 2014 20:40:21 +0000 (00:40 +0400)
(Apply commit 36aa13d from 'master' branch.)

* 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.

Conflicts:

    dbg_mlc.c
    mallocx.c

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

index a0423e97e58849020b4921aa142520278ec4675c..f805473f6e14c852a7bada60a75e9eae1fc30c61 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);
 
@@ -607,7 +608,8 @@ GC_API void * GC_CALL GC_debug_malloc_atomic_ignore_off_page(size_t lb,
 #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);
 
@@ -656,7 +658,8 @@ GC_API void * GC_CALL GC_debug_malloc_atomic_ignore_off_page(size_t lb,
 
 #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);
   }
@@ -668,7 +671,8 @@ GC_API void * GC_CALL GC_debug_malloc_atomic_ignore_off_page(size_t lb,
                                 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);
 
@@ -684,7 +688,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;
@@ -706,8 +711,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  */
@@ -728,7 +733,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);
@@ -743,8 +749,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);
 
@@ -761,8 +767,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);
@@ -1207,7 +1213,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 0dad28a629a51e7dbe2681184415d71b0a80d8d4..84b4eda68abf0b84a417e7ba8ca9e33d20b45421 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
 {
@@ -127,7 +127,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 78950e25f13f230c53a3f9fc6e6bd9e7ec80d24a..9be948b9b9d4b4bc7479fc89c3ef26fac76432c9 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
 {
@@ -206,7 +206,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;
@@ -234,7 +234,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 4983cdfe11531eba25e639980b534a99b181492f..8405faf62341f7d9590115af3c387a511f9442b7 100644 (file)
--- a/malloc.c
+++ b/malloc.c
@@ -168,7 +168,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;
@@ -226,7 +226,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;
@@ -256,7 +256,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;
@@ -289,7 +289,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;
     void **opp;
index 7fcaa5c26f42d7658c9b57dda085528bee904002..6a183f386b5cfbe4ef4ad3fb42697ba568a31725 100644 (file)
--- a/mallocx.c
+++ b/mallocx.c
@@ -134,8 +134,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);
@@ -167,7 +166,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;
@@ -218,12 +218,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((void *)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((void *)GC_generic_malloc_ignore_off_page(lb, PTRFREE));
 }
@@ -433,7 +434,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;
     GC_generic_malloc_many((lb + EXTRA_BYTES + GRANULE_BYTES-1)
@@ -446,7 +447,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;
@@ -505,7 +506,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;
     void **opp;
@@ -557,7 +559,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;
@@ -573,7 +575,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  */
@@ -594,7 +596,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 00f78ce569f3c0b57049d46c2f966f7904c9ad00..b164f522f517eed362f349e5021456cf7bab485d 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;
     ptr_t * opp;
@@ -617,8 +618,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;
     ptr_t * opp;
@@ -654,8 +655,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;
     ptr_t * opp;