diff options
author | Ivan Maidanski <ivmai@mail.ru> | 2021-07-25 22:43:44 +0300 |
---|---|---|
committer | Ivan Maidanski <ivmai@mail.ru> | 2021-07-25 22:43:44 +0300 |
commit | 2b3873928304b0dd5b2575092cbc508a91d3ae55 (patch) | |
tree | c55157da455ac36b675d810b5d0e569bab196ca7 | |
parent | 9abc279f49317713cb9bc582eb87d062ad66d4d8 (diff) | |
download | bdwgc-2b3873928304b0dd5b2575092cbc508a91d3ae55.tar.gz |
Remove new_gc_alloc.h file
The removed header was not exported anyway and provided the SGI-style
allocators depending on an ancient STL version.
* Makefile.direct (SRCS): Remove include/new_gc_alloc.h; rename
include/gc_alloc_ptrs.h to include/private/gc_alloc_ptrs.h.
* include/include.am (dist_noinst_HEADERS): Likewise.
* doc/gcinterface.md (STL allocators): Remove information about
SGI-style allocators (defined in new_gc_alloc.h).
* include/new_gc_alloc.h: Remove file.
* include/gc_alloc_ptrs.h: Move to include/private folder.
* include/private/gc_alloc_ptrs.h [!GC_API_PRIV] (GC_API_PRIV): Define.
* include/private/gc_alloc_ptrs.h (GC_objfreelist_ptr,
GC_aobjfreelist_ptr, GC_uobjfreelist_ptr, GC_incr_bytes_allocd,
GC_incr_bytes_freed): Use GC_API_PRIV instead of GC_API.
* include/private/gc_alloc_ptrs.h [GC_ATOMIC_UNCOLLECTABLE]
(GC_auobjfreelist_ptr): Likewise.
* mallocx.c: Include private/gc_alloc_ptrs.h (instead of
gc_alloc_ptrs.h).
* mallocx.c (GC_incr_bytes_allocd, GC_incr_bytes_freed): Remove GC_API.
* tests/test_cpp.cc: Include "gc_allocator.h" (even if
DONT_USE_STD_ALLOCATOR).
* tests/test_cpp.cc (main): Remove code inside ifdef
DONT_USE_STD_ALLOCATOR blocks.
-rw-r--r-- | Makefile.direct | 2 | ||||
-rw-r--r-- | doc/gcinterface.md | 18 | ||||
-rw-r--r-- | include/include.am | 3 | ||||
-rw-r--r-- | include/new_gc_alloc.h | 534 | ||||
-rw-r--r-- | include/private/gc_alloc_ptrs.h (renamed from include/gc_alloc_ptrs.h) | 18 | ||||
-rw-r--r-- | mallocx.c | 6 | ||||
-rw-r--r-- | tests/test_cpp.cc | 39 |
7 files changed, 29 insertions, 591 deletions
diff --git a/Makefile.direct b/Makefile.direct index 84082f3e..fc4db7ef 100644 --- a/Makefile.direct +++ b/Makefile.direct @@ -109,7 +109,7 @@ SRCS= $(CSRCS) \ include/private/gcconfig.h include/private/gc_pmark.h \ include/gc_inline.h include/gc_mark.h include/gc_disclaim.h \ tools/threadlibs.c tools/if_mach.c tools/if_not_there.c gc_badalc.cc \ - gc_cpp.cc include/gc_cpp.h include/new_gc_alloc.h include/gc_alloc_ptrs.h \ + gc_cpp.cc include/gc_cpp.h include/private/gc_alloc_ptrs.h \ include/gc_allocator.h include/javaxfc.h include/gc_backptr.h \ include/gc_gcj.h include/private/gc_locks.h include/private/dbg_mlc.h \ include/private/specific.h include/leak_detector.h \ diff --git a/doc/gcinterface.md b/doc/gcinterface.md index e21efbc9..e2c38cb7 100644 --- a/doc/gcinterface.md +++ b/doc/gcinterface.md @@ -181,24 +181,6 @@ memory. The latter allocates garbage-collected memory. These should work with any fully standard-conforming C++ compiler. -Users of the [SGI extended STL](http://www.sgi.com/tech/stl) or its -derivatives (including most g++ versions) may instead be able to include -`new_gc_alloc.h` before including STL header files. This is increasingly -discouraged. - -This defines SGI-style allocators - - * `traceable_alloc` - * `single_client_traceable_alloc` - * `gc_alloc` - * `single_client_gc_alloc` - -The first two allocate uncollectible but traced memory, while the second two -allocate collectible memory. The `single_client_...` versions are not safe for -concurrent access by multiple threads, but are faster. - -See sample code [here](http://www.hboehm.info/gc/gc_alloc_exC.txt). - ### Class inheritance based interface for new-based allocation Users may include `gc_cpp.h` and then cause members of classes to be allocated diff --git a/include/include.am b/include/include.am index ef1867f8..2ca5d3f4 100644 --- a/include/include.am +++ b/include/include.am @@ -32,11 +32,10 @@ dist_noinst_HEADERS += \ include/cord.h \ include/cord_pos.h \ include/ec.h \ - include/gc_alloc_ptrs.h \ - include/new_gc_alloc.h \ include/private/darwin_semaphore.h \ include/private/darwin_stop_world.h \ include/private/dbg_mlc.h \ + include/private/gc_alloc_ptrs.h \ include/private/gc_atomic_ops.h \ include/private/gc_hdrs.h \ include/private/gc_locks.h \ diff --git a/include/new_gc_alloc.h b/include/new_gc_alloc.h deleted file mode 100644 index 6807787b..00000000 --- a/include/new_gc_alloc.h +++ /dev/null @@ -1,534 +0,0 @@ -/* - * Copyright (c) 1996-1998 by Silicon Graphics. All rights reserved. - * - * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED - * OR IMPLIED. ANY USE IS AT YOUR OWN RISK. - * - * Permission is hereby granted to use or copy this program - * for any purpose, provided the above notices are retained on all copies. - * Permission to modify the code and to distribute modified code is granted, - * provided the above notices are retained, and a notice that the code was - * modified is included with the above copyright notice. - */ - -// -// This is a revision of gc_allocator.h for SGI STL versions > 3.0. -// Unlike earlier versions, it supplements the standard (STL) alloc.h -// instead of replacing it. -// -// This is sloppy about variable names used in header files. -// It also doesn't yet understand the new header file names or -// namespaces. -// -// This assumes the collector has been compiled with -DGC_ATOMIC_UNCOLLECTABLE. -// The user should also consider -DREDIRECT_MALLOC=GC_uncollectable_malloc, -// to ensure that object allocated through malloc are traced. -// -// Some of this could be faster in the explicit deallocation case. -// In particular, we spend too much time clearing objects on the -// free lists. That could be avoided. -// -// This uses template classes with static members, and hence does not work -// with g++ 2.7.2 and earlier. -// -// Unlike its predecessor, this one simply defines -// gc_alloc -// single_client_gc_alloc -// traceable_alloc -// single_client_traceable_alloc -// -// It does not redefine alloc. Nor does it change the default allocator, -// though the user may wish to do so. (The argument against changing -// the default allocator is that it may introduce subtle link compatibility -// problems. The argument for changing it is that the usual default -// allocator is usually a very bad choice for a garbage collected environment.) -// - -#ifndef GC_NEW_ALLOC_H -#define GC_NEW_ALLOC_H - -#include "gc.h" - -#if GC_GNUC_PREREQ(3, 0) -# include <bits/stl_alloc.h> -# ifndef __STL_BEGIN_NAMESPACE -# define __STL_BEGIN_NAMESPACE namespace std { -# define __STL_END_NAMESPACE }; -# endif -# ifndef __STL_USE_STD_ALLOCATORS -# define __STL_USE_STD_ALLOCATORS -# endif -#else -# include <stack> // A more portable way to get stl_alloc.h file. -#endif - -/* A hack to deal with gcc 3.1. If you are using gcc3.1 and later, */ -/* you should probably really use gc_allocator.h instead. */ -#if GC_GNUC_PREREQ(3, 1) -# define simple_alloc __simple_alloc -#endif - -#include <stddef.h> -#include <string.h> - -// We can't include gc_priv.h, since that pulls in way too much stuff. -#include "gc_alloc_ptrs.h" - -#include "gc_mark.h" // for GC_generic_malloc - -#define GC_generic_malloc_words_small(lw, k) \ - GC_generic_malloc((lw) * sizeof(GC_word), k) - -#define GC_ALLOCATOR_THROW_OR_ABORT() GC_abort_on_oom() - -// Object kinds; must match PTRFREE, NORMAL, UNCOLLECTABLE, and -// AUNCOLLECTABLE in gc_priv.h. - -enum { GC_PTRFREE = 0, GC_NORMAL = 1, GC_UNCOLLECTABLE = 2, - GC_AUNCOLLECTABLE = 3 }; - -enum { GC_max_fast_bytes = 255 }; - -enum { GC_byte_alignment = 8 }; - -#if defined(CPPCHECK) - const unsigned GC_bytes_per_word = sizeof(char *); - const unsigned GC_word_alignment = GC_byte_alignment/GC_bytes_per_word; -#else - enum { GC_bytes_per_word = sizeof(char *) }; - enum { GC_word_alignment = GC_byte_alignment/GC_bytes_per_word }; -#endif - -inline void * &GC_obj_link(void * p) -{ return *reinterpret_cast<void **>(p); } - -// Compute a number of words >= n+1 bytes. -// The +1 allows for pointers one past the end. -inline size_t GC_round_up(size_t n) -{ - return ((n + GC_byte_alignment)/GC_byte_alignment)*GC_word_alignment; -} - -// The same but don't allow for extra byte. -inline size_t GC_round_up_uncollectable(size_t n) -{ - return ((n + GC_byte_alignment - 1)/GC_byte_alignment)*GC_word_alignment; -} - -template <int dummy> -class GC_aux_template { -public: - // File local count of allocated words. Occasionally this is - // added into the global count. A separate count is necessary since the - // real one must be updated with a procedure call. - static size_t GC_bytes_recently_allocd; - - // Same for uncollectible memory. Not yet reflected in either - // GC_bytes_recently_allocd or GC_non_gc_bytes. - static size_t GC_uncollectable_bytes_recently_allocd; - - // Similar counter for explicitly deallocated memory. - static size_t GC_bytes_recently_freed; - - // Again for uncollectible memory. - static size_t GC_uncollectable_bytes_recently_freed; - - static void * GC_out_of_line_malloc(size_t nwords, int kind); - -private: - static void * GC_CALLBACK GC_update_byte_counters(void *); -}; - -template <int dummy> -size_t GC_aux_template<dummy>::GC_bytes_recently_allocd = 0; - -template <int dummy> -size_t GC_aux_template<dummy>::GC_uncollectable_bytes_recently_allocd = 0; - -template <int dummy> -size_t GC_aux_template<dummy>::GC_bytes_recently_freed = 0; - -template <int dummy> -size_t GC_aux_template<dummy>::GC_uncollectable_bytes_recently_freed = 0; - -template <int dummy> -void * GC_aux_template<dummy>::GC_out_of_line_malloc(size_t nwords, int kind) -{ - void * op = GC_generic_malloc_words_small(nwords, kind); - if (0 == op) - GC_ALLOCATOR_THROW_OR_ABORT(); - -# ifdef LINT2 - return GC_call_with_alloc_lock(GC_update_byte_counters, op); -# else - // Anyway, the relevant allocators are not safe for concurrent use - // by multiple threads. - return GC_update_byte_counters(op); -# endif -} - -template <int dummy> -void * GC_CALLBACK GC_aux_template<dummy>::GC_update_byte_counters(void *op) -{ - GC_word non_gc_bytes = GC_get_non_gc_bytes(); - GC_bytes_recently_allocd += GC_uncollectable_bytes_recently_allocd; - non_gc_bytes += GC_uncollectable_bytes_recently_allocd; - GC_uncollectable_bytes_recently_allocd = 0; - - GC_bytes_recently_freed += GC_uncollectable_bytes_recently_freed; - non_gc_bytes -= GC_uncollectable_bytes_recently_freed; - GC_uncollectable_bytes_recently_freed = 0; - GC_set_non_gc_bytes(non_gc_bytes); - - GC_incr_bytes_allocd(GC_bytes_recently_allocd); - GC_bytes_recently_allocd = 0; - - GC_incr_bytes_freed(GC_bytes_recently_freed); - GC_bytes_recently_freed = 0; - return op; -} - -typedef GC_aux_template<0> GC_aux; - -// A fast, single-threaded, garbage-collected allocator -// We assume the first word will be immediately overwritten. -// In this version, deallocation is not a no-op, and explicit -// deallocation is likely to help performance. -// Note: the single_client_... allocators are not safe for concurrent access -// by multiple threads. -template <int dummy> -class single_client_gc_alloc_template { - public: - static void * allocate(size_t n) - { - size_t nwords = GC_round_up(n); - void ** flh; - void * op; - - if (n > GC_max_fast_bytes) { - op = GC_malloc(n); - if (0 == op) - GC_ALLOCATOR_THROW_OR_ABORT(); - return op; - } - flh = &GC_objfreelist_ptr[nwords]; - op = *flh; - if (0 == op) { - return GC_aux::GC_out_of_line_malloc(nwords, GC_NORMAL); - } - *flh = GC_obj_link(op); - GC_aux::GC_bytes_recently_allocd += nwords * GC_bytes_per_word; - return op; - } - static void * ptr_free_allocate(size_t n) - { - size_t nwords = GC_round_up(n); - void ** flh; - void * op; - - if (n > GC_max_fast_bytes) { - op = GC_malloc_atomic(n); - if (0 == op) - GC_ALLOCATOR_THROW_OR_ABORT(); - return op; - } - flh = &GC_aobjfreelist_ptr[nwords]; - op = *flh; - if (0 == op) { - return GC_aux::GC_out_of_line_malloc(nwords, GC_PTRFREE); - } - *flh = GC_obj_link(op); - GC_aux::GC_bytes_recently_allocd += nwords * GC_bytes_per_word; - return op; - } - static void deallocate(void *p, size_t n) - { - if (n > GC_max_fast_bytes) { - GC_free(p); - } else { - size_t nwords = GC_round_up(n); - void ** flh = &GC_objfreelist_ptr[nwords]; - - GC_obj_link(p) = *flh; - memset(reinterpret_cast<char *>(p) + GC_bytes_per_word, 0, - GC_bytes_per_word * (nwords - 1)); - *flh = p; - GC_aux::GC_bytes_recently_freed += nwords * GC_bytes_per_word; - } - } - static void ptr_free_deallocate(void *p, size_t n) - { - if (n > GC_max_fast_bytes) { - GC_free(p); - } else { - size_t nwords = GC_round_up(n); - void ** flh = &GC_aobjfreelist_ptr[nwords]; - - GC_obj_link(p) = *flh; - *flh = p; - GC_aux::GC_bytes_recently_freed += nwords * GC_bytes_per_word; - } - } -}; - -typedef single_client_gc_alloc_template<0> single_client_gc_alloc; - -// Once more, for uncollectible objects. -template <int dummy> -class single_client_traceable_alloc_template { - public: - static void * allocate(size_t n) - { - size_t nwords = GC_round_up_uncollectable(n); - void ** flh; - void * op; - - if (n > GC_max_fast_bytes) { - op = GC_malloc_uncollectable(n); - if (0 == op) - GC_ALLOCATOR_THROW_OR_ABORT(); - return op; - } - flh = &GC_uobjfreelist_ptr[nwords]; - op = *flh; - if (0 == op) { - return GC_aux::GC_out_of_line_malloc(nwords, GC_UNCOLLECTABLE); - } - *flh = GC_obj_link(op); - GC_aux::GC_uncollectable_bytes_recently_allocd += - nwords * GC_bytes_per_word; - return op; - } - static void * ptr_free_allocate(size_t n) - { - size_t nwords = GC_round_up_uncollectable(n); - void ** flh; - void * op; - - if (n > GC_max_fast_bytes) { - op = GC_malloc_atomic_uncollectable(n); - if (0 == op) - GC_ALLOCATOR_THROW_OR_ABORT(); - return op; - } - flh = &GC_auobjfreelist_ptr[nwords]; - op = *flh; - if (0 == op) { - return GC_aux::GC_out_of_line_malloc(nwords, GC_AUNCOLLECTABLE); - } - *flh = GC_obj_link(op); - GC_aux::GC_uncollectable_bytes_recently_allocd += - nwords * GC_bytes_per_word; - return op; - } - static void deallocate(void *p, size_t n) - { - if (n > GC_max_fast_bytes) { - GC_free(p); - } else { - size_t nwords = GC_round_up_uncollectable(n); - void ** flh = &GC_uobjfreelist_ptr[nwords]; - - GC_obj_link(p) = *flh; - *flh = p; - GC_aux::GC_uncollectable_bytes_recently_freed += - nwords * GC_bytes_per_word; - } - } - static void ptr_free_deallocate(void *p, size_t n) - { - if (n > GC_max_fast_bytes) { - GC_free(p); - } else { - size_t nwords = GC_round_up_uncollectable(n); - void ** flh = &GC_auobjfreelist_ptr[nwords]; - - GC_obj_link(p) = *flh; - *flh = p; - GC_aux::GC_uncollectable_bytes_recently_freed += - nwords * GC_bytes_per_word; - } - } -}; - -typedef single_client_traceable_alloc_template<0> single_client_traceable_alloc; - -template < int dummy > -class gc_alloc_template { - public: - static void * allocate(size_t n) { - void * op = GC_malloc(n); - if (0 == op) - GC_ALLOCATOR_THROW_OR_ABORT(); - return op; - } - static void * ptr_free_allocate(size_t n) { - void * op = GC_malloc_atomic(n); - if (0 == op) - GC_ALLOCATOR_THROW_OR_ABORT(); - return op; - } - static void deallocate(void *, size_t) { } - static void ptr_free_deallocate(void *, size_t) { } -}; - -typedef gc_alloc_template < 0 > gc_alloc; - -template < int dummy > -class traceable_alloc_template { - public: - static void * allocate(size_t n) { - void * op = GC_malloc_uncollectable(n); - if (0 == op) - GC_ALLOCATOR_THROW_OR_ABORT(); - return op; - } - static void * ptr_free_allocate(size_t n) { - void * op = GC_malloc_atomic_uncollectable(n); - if (0 == op) - GC_ALLOCATOR_THROW_OR_ABORT(); - return op; - } - static void deallocate(void *p, size_t) { GC_free(p); } - static void ptr_free_deallocate(void *p, size_t) { GC_free(p); } -}; - -typedef traceable_alloc_template < 0 > traceable_alloc; - -// We want to specialize simple_alloc so that it does the right thing -// for all pointer-free types. At the moment there is no portable way to -// even approximate that. The following approximation should work for -// SGI compilers, and recent versions of g++. - -// GC_SPECIALIZE() is used internally. -#define GC_SPECIALIZE(T,alloc) \ - class simple_alloc<T, alloc> { \ - public: \ - static T *allocate(size_t n) \ - { reinterpret_cast<T*>(alloc::ptr_free_allocate(0 == n ? 1 \ - : n * sizeof(T))); } \ - static T *allocate(void) \ - { return reinterpret_cast<T*>(alloc::ptr_free_allocate(sizeof(T))); } \ - static void deallocate(T *p, size_t n) \ - { alloc::ptr_free_deallocate(p, 0 == n ? 1 : n * sizeof(T)); } \ - static void deallocate(T *p) \ - { alloc::ptr_free_deallocate(p, sizeof(T)); } \ - }; - -__STL_BEGIN_NAMESPACE - -GC_SPECIALIZE(char, gc_alloc) -GC_SPECIALIZE(int, gc_alloc) -GC_SPECIALIZE(unsigned, gc_alloc) -GC_SPECIALIZE(float, gc_alloc) -GC_SPECIALIZE(double, gc_alloc) - -GC_SPECIALIZE(char, traceable_alloc) -GC_SPECIALIZE(int, traceable_alloc) -GC_SPECIALIZE(unsigned, traceable_alloc) -GC_SPECIALIZE(float, traceable_alloc) -GC_SPECIALIZE(double, traceable_alloc) - -GC_SPECIALIZE(char, single_client_gc_alloc) -GC_SPECIALIZE(int, single_client_gc_alloc) -GC_SPECIALIZE(unsigned, single_client_gc_alloc) -GC_SPECIALIZE(float, single_client_gc_alloc) -GC_SPECIALIZE(double, single_client_gc_alloc) - -GC_SPECIALIZE(char, single_client_traceable_alloc) -GC_SPECIALIZE(int, single_client_traceable_alloc) -GC_SPECIALIZE(unsigned, single_client_traceable_alloc) -GC_SPECIALIZE(float, single_client_traceable_alloc) -GC_SPECIALIZE(double, single_client_traceable_alloc) - -__STL_END_NAMESPACE - -#ifdef __STL_USE_STD_ALLOCATORS - -__STL_BEGIN_NAMESPACE - -template <class _Tp> -struct _Alloc_traits<_Tp, gc_alloc > -{ - static const bool _S_instanceless = true; - typedef simple_alloc<_Tp, gc_alloc > _Alloc_type; - typedef __allocator<_Tp, gc_alloc > allocator_type; -}; - -inline bool operator==(const gc_alloc&, - const gc_alloc&) -{ - return true; -} - -inline bool operator!=(const gc_alloc&, - const gc_alloc&) -{ - return false; -} - -template <class _Tp> -struct _Alloc_traits<_Tp, single_client_gc_alloc > -{ - static const bool _S_instanceless = true; - typedef simple_alloc<_Tp, single_client_gc_alloc > _Alloc_type; - typedef __allocator<_Tp, single_client_gc_alloc > allocator_type; -}; - -inline bool operator==(const single_client_gc_alloc&, - const single_client_gc_alloc&) -{ - return true; -} - -inline bool operator!=(const single_client_gc_alloc&, - const single_client_gc_alloc&) -{ - return false; -} - -template <class _Tp> -struct _Alloc_traits<_Tp, traceable_alloc > -{ - static const bool _S_instanceless = true; - typedef simple_alloc<_Tp, traceable_alloc > _Alloc_type; - typedef __allocator<_Tp, traceable_alloc > allocator_type; -}; - -inline bool operator==(const traceable_alloc&, - const traceable_alloc&) -{ - return true; -} - -inline bool operator!=(const traceable_alloc&, - const traceable_alloc&) -{ - return false; -} - -template <class _Tp> -struct _Alloc_traits<_Tp, single_client_traceable_alloc > -{ - static const bool _S_instanceless = true; - typedef simple_alloc<_Tp, single_client_traceable_alloc > _Alloc_type; - typedef __allocator<_Tp, single_client_traceable_alloc > allocator_type; -}; - -inline bool operator==(const single_client_traceable_alloc&, - const single_client_traceable_alloc&) -{ - return true; -} - -inline bool operator!=(const single_client_traceable_alloc&, - const single_client_traceable_alloc&) -{ - return false; -} - -__STL_END_NAMESPACE - -#endif /* __STL_USE_STD_ALLOCATORS */ - -#endif /* GC_NEW_ALLOC_H */ diff --git a/include/gc_alloc_ptrs.h b/include/private/gc_alloc_ptrs.h index 6267705e..61e5bf46 100644 --- a/include/gc_alloc_ptrs.h +++ b/include/private/gc_alloc_ptrs.h @@ -11,7 +11,7 @@ * modified is included with the above copyright notice. */ -/* This file should never be included by clients directly. */ +/* This file is kept for a binary compatibility purpose only. */ #ifndef GC_ALLOC_PTRS_H #define GC_ALLOC_PTRS_H @@ -22,12 +22,16 @@ extern "C" { #endif -GC_API void ** const GC_objfreelist_ptr; -GC_API void ** const GC_aobjfreelist_ptr; -GC_API void ** const GC_uobjfreelist_ptr; +#ifndef GC_API_PRIV +# define GC_API_PRIV GC_API +#endif + +GC_API_PRIV void ** const GC_objfreelist_ptr; +GC_API_PRIV void ** const GC_aobjfreelist_ptr; +GC_API_PRIV void ** const GC_uobjfreelist_ptr; #ifdef GC_ATOMIC_UNCOLLECTABLE - GC_API void ** const GC_auobjfreelist_ptr; + GC_API_PRIV void ** const GC_auobjfreelist_ptr; #endif /* Manually update the number of bytes allocated during the current */ @@ -35,8 +39,8 @@ GC_API void ** const GC_uobjfreelist_ptr; /* memory since the last collection, respectively. Both functions are */ /* unsynchronized, GC_call_with_alloc_lock() should be used to avoid */ /* data races. */ -GC_API void GC_CALL GC_incr_bytes_allocd(size_t /* bytes */); -GC_API void GC_CALL GC_incr_bytes_freed(size_t /* bytes */); +GC_API_PRIV void GC_CALL GC_incr_bytes_allocd(size_t /* bytes */); +GC_API_PRIV void GC_CALL GC_incr_bytes_freed(size_t /* bytes */); #ifdef __cplusplus } /* extern "C" */ @@ -34,7 +34,7 @@ /* Some externally visible but unadvertised variables to allow access to */ /* free lists from inlined allocators without including gc_priv.h */ /* or introducing dependencies on internal data structure layouts. */ -#include "gc_alloc_ptrs.h" +#include "private/gc_alloc_ptrs.h" void ** const GC_objfreelist_ptr = GC_objfreelist; void ** const GC_aobjfreelist_ptr = GC_aobjfreelist; void ** const GC_uobjfreelist_ptr = GC_uobjfreelist; @@ -249,13 +249,13 @@ GC_API GC_ATTR_MALLOC void * GC_CALL /* Increment GC_bytes_allocd from code that doesn't have direct access */ /* to GC_arrays. */ -GC_API void GC_CALL GC_incr_bytes_allocd(size_t n) +void GC_CALL GC_incr_bytes_allocd(size_t n) { GC_bytes_allocd += n; } /* The same for GC_bytes_freed. */ -GC_API void GC_CALL GC_incr_bytes_freed(size_t n) +void GC_CALL GC_incr_bytes_freed(size_t n) { GC_bytes_freed += n; } diff --git a/tests/test_cpp.cc b/tests/test_cpp.cc index f323a018..3c555673 100644 --- a/tests/test_cpp.cc +++ b/tests/test_cpp.cc @@ -36,12 +36,7 @@ few minutes to complete. #include <stdlib.h> #include <string.h> -#ifndef DONT_USE_STD_ALLOCATOR -# include "gc_allocator.h" -#else - /* Note: This works only for ancient STL versions. */ -# include "new_gc_alloc.h" -#endif +#include "gc_allocator.h" # include "private/gcconfig.h" @@ -310,24 +305,18 @@ void* Undisguise( GC_word i ) { GC_printf("This test program is not designed for leak detection mode\n"); int i, iters, n; -# ifndef DONT_USE_STD_ALLOCATOR - int *x = gc_allocator<int>().allocate(1); - int *xio; - xio = gc_allocator_ignore_off_page<int>().allocate(1); - (void)xio; - int **xptr = traceable_allocator<int *>().allocate(1); -# else - int *x = (int *)gc_alloc::allocate(sizeof(int)); -# endif + int *x = gc_allocator<int>().allocate(1); + int *xio; + xio = gc_allocator_ignore_off_page<int>().allocate(1); + (void)xio; + int **xptr = traceable_allocator<int *>().allocate(1); *x = 29; -# ifndef DONT_USE_STD_ALLOCATOR - if (!xptr) { - fprintf(stderr, "Out of memory!\n"); - exit(3); - } - GC_PTR_STORE_AND_DIRTY(xptr, x); - x = 0; -# endif + if (!xptr) { + fprintf(stderr, "Out of memory!\n"); + exit(3); + } + GC_PTR_STORE_AND_DIRTY(xptr, x); + x = 0; if (argc != 2 || (n = (int)COVERT_DATAFLOW(atoi(argv[1]))) <= 0) { GC_printf("usage: test_cpp number-of-iterations\n" @@ -413,9 +402,7 @@ void* Undisguise( GC_word i ) { D::Test(); F::Test();} -# ifndef DONT_USE_STD_ALLOCATOR - x = *xptr; -# endif + x = *xptr; my_assert (29 == x[0]); GC_printf( "The test appears to have succeeded.\n" ); return( 0 ); |