version 1.1, 1999/12/03 07:39:10 |
version 1.5, 2002/07/24 08:00:18 |
|
|
// It also doesn't yet understand the new header file names or |
// It also doesn't yet understand the new header file names or |
// namespaces. |
// namespaces. |
// |
// |
// This assumes the collector has been compiled with -DATOMIC_UNCOLLECTABLE |
// This assumes the collector has been compiled with -DATOMIC_UNCOLLECTABLE. |
// and -DALL_INTERIOR_POINTERS. We also recommend |
// The user should also consider -DREDIRECT_MALLOC=GC_uncollectable_malloc, |
// -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. |
// Some of this could be faster in the explicit deallocation case. |
// In particular, we spend too much time clearing objects on the |
// In particular, we spend too much time clearing objects on the |
|
|
// problems. The argument for changing it is that the usual default |
// problems. The argument for changing it is that the usual default |
// allocator is usually a very bad choice for a garbage collected environment.) |
// allocator is usually a very bad choice for a garbage collected environment.) |
// |
// |
|
// This code assumes that the collector itself has been compiled with a |
|
// compiler that defines __STDC__ . |
|
// |
|
|
#ifndef GC_ALLOC_H |
#ifndef GC_ALLOC_H |
|
|
#include "gc.h" |
#include "gc.h" |
#include <alloc.h> |
|
|
|
|
#if (__GNUC__ < 3) |
|
# include <stack> // A more portable way to get stl_alloc.h . |
|
#else |
|
# 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 |
|
#endif |
|
|
|
|
#define GC_ALLOC_H |
#define GC_ALLOC_H |
|
|
#include <stddef.h> |
#include <stddef.h> |
Line 318 class traceable_alloc_template { |
|
Line 334 class traceable_alloc_template { |
|
|
|
typedef traceable_alloc_template < 0 > traceable_alloc; |
typedef traceable_alloc_template < 0 > traceable_alloc; |
|
|
#ifdef _SGI_SOURCE |
|
|
|
// We want to specialize simple_alloc so that it does the right thing |
// We want to specialize simple_alloc so that it does the right thing |
// for all pointerfree types. At the moment there is no portable way to |
// for all pointerfree types. At the moment there is no portable way to |
// even approximate that. The following approximation should work for |
// even approximate that. The following approximation should work for |
// SGI compilers, and perhaps some others. |
// SGI compilers, and recent versions of g++. |
|
|
# define __GC_SPECIALIZE(T,alloc) \ |
# define __GC_SPECIALIZE(T,alloc) \ |
class simple_alloc<T, alloc> { \ |
class simple_alloc<T, alloc> { \ |
Line 339 class simple_alloc<T, alloc> { \ (public) |
|
Line 353 class simple_alloc<T, alloc> { \ (public) |
|
{ alloc::ptr_free_deallocate(p, sizeof (T)); } \ |
{ alloc::ptr_free_deallocate(p, sizeof (T)); } \ |
}; |
}; |
|
|
|
__STL_BEGIN_NAMESPACE |
|
|
__GC_SPECIALIZE(char, gc_alloc) |
__GC_SPECIALIZE(char, gc_alloc) |
__GC_SPECIALIZE(int, gc_alloc) |
__GC_SPECIALIZE(int, gc_alloc) |
__GC_SPECIALIZE(unsigned, gc_alloc) |
__GC_SPECIALIZE(unsigned, gc_alloc) |
Line 363 __GC_SPECIALIZE(unsigned, single_client_traceable_allo |
|
Line 379 __GC_SPECIALIZE(unsigned, single_client_traceable_allo |
|
__GC_SPECIALIZE(float, single_client_traceable_alloc) |
__GC_SPECIALIZE(float, single_client_traceable_alloc) |
__GC_SPECIALIZE(double, single_client_traceable_alloc) |
__GC_SPECIALIZE(double, single_client_traceable_alloc) |
|
|
|
__STL_END_NAMESPACE |
|
|
#ifdef __STL_USE_STD_ALLOCATORS |
#ifdef __STL_USE_STD_ALLOCATORS |
|
|
__STL_BEGIN_NAMESPACE |
__STL_BEGIN_NAMESPACE |
Line 450 inline bool operator!=(const single_client_traceable_a |
|
Line 468 inline bool operator!=(const single_client_traceable_a |
|
__STL_END_NAMESPACE |
__STL_END_NAMESPACE |
|
|
#endif /* __STL_USE_STD_ALLOCATORS */ |
#endif /* __STL_USE_STD_ALLOCATORS */ |
|
|
#endif /* _SGI_SOURCE */ |
|
|
|
#endif /* GC_ALLOC_H */ |
#endif /* GC_ALLOC_H */ |