#include "gc.h"
+#ifdef GC_NAMESPACE
+# define GC_NS_QUALIFY(T) boehmgc::T
+#else
+# define GC_NS_QUALIFY(T) T
+#endif
+
#ifndef THINK_CPLUS
# define GC_cdecl GC_CALLBACK
#else
# define GC_PLACEMENT_DELETE
#endif
+#ifdef GC_NAMESPACE
+namespace boehmgc
+{
+#endif
+
enum GCPlacement {
UseGC,
# ifndef GC_NAME_CONFLICT
GC=UseGC,
# endif
- NoGC,
- PointerFreeGC
+ NoGC,
+ PointerFreeGC
};
class gc {
typedef void (GC_CALLBACK * GCCleanUpFunc)( void* obj, void* clientData );
}
+#ifdef GC_NAMESPACE
+}
+#endif
+
#ifdef _MSC_VER
// Disable warning that "no matching operator delete found; memory will
// not be freed if initialization throws an exception"
# pragma warning(disable:4291)
#endif
-inline void* operator new( size_t size, GCPlacement gcp,
- GCCleanUpFunc cleanup = 0,
+inline void* operator new( size_t size, GC_NS_QUALIFY(GCPlacement) gcp,
+ GC_NS_QUALIFY(GCCleanUpFunc) cleanup = 0,
void* clientData = 0 );
/*
Allocates a collectable or uncollected object, according to the
from "gc_cleanup". */
#ifdef GC_PLACEMENT_DELETE
- inline void operator delete( void*, GCPlacement, GCCleanUpFunc, void * );
+ inline void operator delete( void*, GC_NS_QUALIFY(GCPlacement),
+ GC_NS_QUALIFY(GCCleanUpFunc), void * );
#endif
#ifdef _MSC_VER
#endif /* _MSC_VER */
#ifdef GC_OPERATOR_NEW_ARRAY
- inline void* operator new[]( size_t size, GCPlacement gcp,
- GCCleanUpFunc cleanup = 0,
+ inline void* operator new[]( size_t size, GC_NS_QUALIFY(GCPlacement) gcp,
+ GC_NS_QUALIFY(GCCleanUpFunc) cleanup = 0,
void* clientData = 0 );
/* The operator new for arrays, identical to the above. */
#endif /* GC_OPERATOR_NEW_ARRAY */
****************************************************************************/
+#ifdef GC_NAMESPACE
+namespace boehmgc
+{
+#endif
+
inline void* gc::operator new( size_t size ) {
return GC_MALLOC( size );
}
}
}
-inline void* operator new( size_t size, GCPlacement gcp,
- GCCleanUpFunc cleanup, void* clientData )
+#ifdef GC_NAMESPACE
+}
+#endif
+
+inline void* operator new( size_t size, GC_NS_QUALIFY(GCPlacement) gcp,
+ GC_NS_QUALIFY(GCCleanUpFunc) cleanup,
+ void* clientData )
{
void* obj;
- if (gcp == UseGC) {
+ if (gcp == GC_NS_QUALIFY(UseGC)) {
obj = GC_MALLOC( size );
if (cleanup != 0)
GC_REGISTER_FINALIZER_IGNORE_SELF( obj, cleanup, clientData,
0, 0 );
- } else if (gcp == PointerFreeGC) {
+ } else if (gcp == GC_NS_QUALIFY(PointerFreeGC)) {
obj = GC_MALLOC_ATOMIC( size );
} else {
obj = GC_MALLOC_UNCOLLECTABLE( size );
}
#ifdef GC_PLACEMENT_DELETE
- inline void operator delete( void *p, GCPlacement /* gcp */,
- GCCleanUpFunc /* cleanup */,
+ inline void operator delete( void *p, GC_NS_QUALIFY(GCPlacement) /* gcp */,
+ GC_NS_QUALIFY(GCCleanUpFunc) /* cleanup */,
void* /* clientData */ )
{
GC_FREE(p);
#endif /* GC_PLACEMENT_DELETE */
#ifdef GC_OPERATOR_NEW_ARRAY
- inline void* operator new[]( size_t size, GCPlacement gcp,
- GCCleanUpFunc cleanup, void* clientData )
+ inline void* operator new[]( size_t size, GC_NS_QUALIFY(GCPlacement) gcp,
+ GC_NS_QUALIFY(GCCleanUpFunc) cleanup,
+ void* clientData )
{
return ::operator new( size, gcp, cleanup, clientData );
}
#endif
#ifdef GC_NAME_CONFLICT
-# define USE_GC UseGC
+# define USE_GC GC_NS_QUALIFY(UseGC)
struct foo * GC;
#else
-# define USE_GC GC
+# define USE_GC GC_NS_QUALIFY(GC)
#endif
#define my_assert( e ) \
int i;};
-class B: public gc, public A {public:
+class B: public GC_NS_QUALIFY(gc), public A { public:
/* A collectable class. */
B( int j ): A( j ) {}
int B::deleting = 0;
-class C: public gc_cleanup, public A {public:
+class C: public GC_NS_QUALIFY(gc_cleanup), public A { public:
/* A collectable class with cleanup and virtual multiple inheritance. */
C( int levelArg ): A( levelArg ), level( levelArg ) {
int C::nAllocated = 0;
-class D: public gc {public:
+class D: public GC_NS_QUALIFY(gc) { public:
/* A collectable class with a static member function to be used as
an explicit clean-up function supplied to ::new. */
int D::nAllocated = 0;
-class E: public gc_cleanup {public:
+class E: public GC_NS_QUALIFY(gc_cleanup) { public:
/* A collectable class with clean-up for use by F. */
E() {
GC_word as[ 1000 ];
GC_word bs[ 1000 ];
for (i = 0; i < 1000; i++) {
- as[ i ] = Disguise( new (NoGC ) A( i ) );
- bs[ i ] = Disguise( new (NoGC) B( i ) );}
+ as[ i ] = Disguise( new (GC_NS_QUALIFY(NoGC)) A(i) );
+ bs[ i ] = Disguise( new (GC_NS_QUALIFY(NoGC)) B(i) ); }
/* Allocate a fair number of finalizable Cs, Ds, and Fs.
Later we'll check to make sure they've gone away. */