implemented Setup.hs to build boehm cpp libs and install them;
[hs-boehmgc.git] / gc-7.2 / 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 #if !defined(__CYGWIN__)
41   void operator delete( void* obj ) {
42     GC_FREE( obj );
43   }
44 #endif /* !__CYGWIN__ */
45
46 #ifdef GC_OPERATOR_NEW_ARRAY
47
48 void* operator new[]( size_t size ) {
49     return GC_MALLOC_UNCOLLECTABLE( size );}
50
51 void operator delete[]( void* obj ) {
52     GC_FREE( obj );}
53
54 #endif /* GC_OPERATOR_NEW_ARRAY */
55
56 #ifdef _MSC_VER
57
58 // This new operator is used by VC++ in case of Debug builds !
59 void* operator new( size_t size,
60                           int ,//nBlockUse,
61                           const char * szFileName,
62                           int nLine )
63 {
64 #ifndef GC_DEBUG
65         return GC_malloc_uncollectable( size );
66 #else
67         return GC_debug_malloc_uncollectable(size, szFileName, nLine);
68 #endif
69 }
70
71 #if _MSC_VER > 1020
72 // This new operator is used by VC++ 7.0 and later in Debug builds.
73 void* operator new[](size_t size, int nBlockUse, const char* szFileName, int nLine)
74 {
75     return operator new(size, nBlockUse, szFileName, nLine);
76 }
77 #endif
78
79 #endif /* _MSC_VER */