forked from pmatos/boomerang
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdriver.cpp
65 lines (57 loc) · 1.56 KB
/
driver.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// SPDX-FileCopyrightText: 1998-2001 The University of Queensland
// SPDX-FileCopyrightText: 2001 Sun Microsystems, Inc
// SPDX-FileCopyrightText: 2002-2006 Mike Van Emmerik and Trent Waddington
// SPDX-License-Identifier: BSD-3-Clause
/**
* \file
* \brief Important initialisation that has to happen at the start of main().
*
* Also contains main(), so it can be the only file different between
* boomerang and bigtest.
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "boomerang.h"
#ifdef GARBAGE_COLLECTOR
//#define GC_DEBUG 1 // Uncomment to debug the garbage collector
#include <gc/gc.h>
// Prototypes for various initialisation functions for garbage collection safety
void init_dfa();
void init_basicblock();
#endif
#ifndef NO_CMDLINE_MAIN
int
main(int argc, const char *argv[])
{
#ifdef GARBAGE_COLLECTOR
// Call the various initialisation functions for safe garbage collection
init_dfa();
init_basicblock();
#endif
return Boomerang::get().commandLine(argc, argv);
}
#endif
#ifdef GARBAGE_COLLECTOR
#ifndef NO_NEW_OR_DELETE_OPERATORS
/* This makes sure that the garbage collector sees all allocations, even those
that we can't be bothered collecting, especially standard STL objects */
void *
operator new(size_t n)
{
#ifdef DONT_COLLECT_STL
return GC_malloc_uncollectable(n); // Don't collect, but mark
#else
return GC_malloc(n); // Collect everything
#endif
}
void
operator delete(void *p)
{
#ifdef DONT_COLLECT_STL
GC_free(p); // Important to call this if you call GC_malloc_uncollectable
// #else do nothing!
#endif
}
#endif
#endif