boehm-gc: revert all CACAO-specific modifications; this is now an exact copy of the...
[cacao.git] / src / mm / boehm-gc / gc_cpp.cc
1 /*************************************************************************
2 Copyright (c) 1994 by Xerox Corporation.  All rights reserved.
3  
4 THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
5 OR IMPLIED.  ANY USE IS AT YOUR OWN RISK.
6  
7     Last modified on Sat Nov 19 19:31:14 PST 1994 by ellis
8                   on Sat Jun  8 15:10:00 PST 1994 by boehm
9
10 Permission is hereby granted to copy this code for any purpose,
11 provided the above notices are retained on all copies.
12
13 This implementation module for gc_c++.h provides an implementation of
14 the global operators "new" and "delete" that calls the Boehm
15 allocator.  All objects allocated by this implementation will be
16 non-collectable but part of the root set of the collector.
17
18 You should ensure (using implementation-dependent techniques) that the
19 linker finds this module before the library that defines the default
20 built-in "new" and "delete".
21
22 Authors: John R. Ellis and Jesse Hull
23
24 **************************************************************************/
25
26 #include <gc_cpp.h>
27
28 void* operator new( size_t size ) {
29     return GC_MALLOC_UNCOLLECTABLE( size );}
30   
31 void operator delete( void* obj ) {
32     GC_FREE( obj );}
33   
34 #ifdef GC_OPERATOR_NEW_ARRAY
35
36 void* operator new[]( size_t size ) {
37     return GC_MALLOC_UNCOLLECTABLE( size );}
38   
39 void operator delete[]( void* obj ) {
40     GC_FREE( obj );}
41
42 #endif /* GC_OPERATOR_NEW_ARRAY */
43
44 #ifdef _MSC_VER
45
46 // This new operator is used by VC++ in case of Debug builds !
47 void* operator new( size_t size,
48                           int ,//nBlockUse,
49                           const char * szFileName,
50                           int nLine )
51 {
52 #ifndef GC_DEBUG
53         return GC_malloc_uncollectable( size );
54 #else
55         return GC_debug_malloc_uncollectable(size, szFileName, nLine);
56 #endif
57 }
58
59 #if _MSC_VER > 1020
60 // This new operator is used by VC++ 7.0 and later in Debug builds.
61 void* operator new[](size_t size, int nBlockUse, const char* szFileName, int nLine)
62 {
63     return operator new(size, nBlockUse, szFileName, nLine);
64 }
65 #endif
66
67 #endif /* _MSC_VER */
68