Upgrade Boehm GC to 7.2alpha4.
[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  *
9  * Permission is hereby granted to copy this code for any purpose,
10  * provided the above notices are retained on all copies.
11  */
12
13 /*************************************************************************
14 This implementation module for gc_c++.h provides an implementation of
15 the global operators "new" and "delete" that calls the Boehm
16 allocator.  All objects allocated by this implementation will be
17 non-collectable but part of the root set of the collector.
18
19 You should ensure (using implementation-dependent techniques) that the
20 linker finds this module before the library that defines the default
21 built-in "new" and "delete".
22
23 Authors: John R. Ellis and Jesse Hull
24
25 **************************************************************************/
26
27 # ifdef HAVE_CONFIG_H
28 #   include "private/config.h"
29 # endif
30
31 # ifndef GC_BUILD
32 #   define GC_BUILD
33 # endif
34
35 #include "gc_cpp.h"
36
37 void* operator new( size_t size ) {
38     return GC_MALLOC_UNCOLLECTABLE( size );}
39
40 void operator delete( void* obj ) {
41     GC_FREE( obj );}
42
43 #ifdef GC_OPERATOR_NEW_ARRAY
44
45 void* operator new[]( size_t size ) {
46     return GC_MALLOC_UNCOLLECTABLE( size );}
47
48 void operator delete[]( void* obj ) {
49     GC_FREE( obj );}
50
51 #endif /* GC_OPERATOR_NEW_ARRAY */
52
53 #ifdef _MSC_VER
54
55 // This new operator is used by VC++ in case of Debug builds !
56 void* operator new( size_t size,
57                           int ,//nBlockUse,
58                           const char * szFileName,
59                           int nLine )
60 {
61 #ifndef GC_DEBUG
62         return GC_malloc_uncollectable( size );
63 #else
64         return GC_debug_malloc_uncollectable(size, szFileName, nLine);
65 #endif
66 }
67
68 #if _MSC_VER > 1020
69 // This new operator is used by VC++ 7.0 and later in Debug builds.
70 void* operator new[](size_t size, int nBlockUse, const char* szFileName, int nLine)
71 {
72     return operator new(size, nBlockUse, szFileName, nLine);
73 }
74 #endif
75
76 #endif /* _MSC_VER */