Panda3D
dtoolbase.cxx
1 // Filename: dtoolbase.cxx
2 // Created by: drose (12Sep00)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #include "dtoolbase.h"
16 #include "memoryHook.h"
17 
18 #if defined(USE_TAU) && defined(WIN32)
19 // Hack around tau's lack of DLL export declarations for Profiler class.
20 bool __tau_shutdown = false;
21 #endif
22 
23 MemoryHook *memory_hook;
24 
25 ////////////////////////////////////////////////////////////////////
26 // Function: init_memory_hook
27 // Description: Any code that might need to use PANDA_MALLOC or
28 // PANDA_FREE, or any methods of the global memory_hook
29 // object, at static init time, should ensure that it
30 // calls init_memory_hook() first to ensure that the
31 // pointer has been properly initialized. There is no
32 // harm in calling this function more than once.
33 //
34 // There is no need to call this function other than at
35 // static init time.
36 ////////////////////////////////////////////////////////////////////
37 void
38 init_memory_hook() {
39  if (memory_hook == NULL) {
40  memory_hook = new MemoryHook;
41  }
42 }
43 
44 // Here's a quick way to ensure the above function is called at least
45 // once at static init time.
47 public:
48  InitMemoryHook() {
49  init_memory_hook();
50  }
51 };
52 static InitMemoryHook _imh_object;
53 
54 #if defined(HAVE_THREADS) && defined(SIMPLE_THREADS)
55 
56 static void
57 default_thread_yield() {
58 }
59 static void
60 default_thread_consider_yield() {
61 }
62 void (*global_thread_yield)() = default_thread_yield;
63 void (*global_thread_consider_yield)() = default_thread_consider_yield;
64 
65 #endif // HAVE_THREADS && SIMPLE_THREADS
This class provides a wrapper around the various possible malloc schemes Panda might employ...
Definition: memoryHook.h:43