Sfoglia il codice sorgente

VC7 allocator support

David Rose 24 anni fa
parent
commit
0a483e3d67

+ 1 - 2
panda/src/express/memoryInfo.cxx

@@ -17,7 +17,6 @@
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 
 
 #ifdef DO_MEMORY_USAGE
 #ifdef DO_MEMORY_USAGE
-// Nothing in this module gets compiled in NDEBUG mode.
 
 
 #include "memoryInfo.h"
 #include "memoryInfo.h"
 #include "typedReferenceCount.h"
 #include "typedReferenceCount.h"
@@ -151,4 +150,4 @@ update_type_handle(TypeHandle &destination, TypeHandle refined) {
   }
   }
 }
 }
 
 
-#endif  // NDEBUG
+#endif  // DO_MEMORY_USAGE

+ 2 - 2
panda/src/express/memoryInfo.h

@@ -19,7 +19,7 @@
 #ifndef MEMORYINFO_H
 #ifndef MEMORYINFO_H
 #define MEMORYINFO_H
 #define MEMORYINFO_H
 
 
-#include <pandabase.h>
+#include "pandabase.h"
 
 
 #ifdef DO_MEMORY_USAGE
 #ifdef DO_MEMORY_USAGE
 
 
@@ -84,7 +84,7 @@ private:
 
 
 #include "memoryInfo.I"
 #include "memoryInfo.I"
 
 
-#endif  // NDEBUG
+#endif  // DO_MEMORY_USAGE
 
 
 #endif
 #endif
 
 

+ 0 - 32
panda/src/express/memoryUsage.I

@@ -16,36 +16,6 @@
 //
 //
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 
 
-#ifdef NDEBUG
-
-// In NDEBUG mode, these are all defined to do nothing.
-
-INLINE bool MemoryUsage::
-get_track_memory_usage() {
-  return false;
-}
-
-INLINE void MemoryUsage::
-record_pointer(ReferenceCount *) {
-}
-
-INLINE void MemoryUsage::
-update_type(ReferenceCount *, TypeHandle) {
-}
-
-INLINE void MemoryUsage::
-update_type(ReferenceCount *, TypedObject *) {
-}
-
-INLINE void MemoryUsage::
-remove_pointer(ReferenceCount *) {
-}
-
-#else  // NDEBUG
-
-// In the normal compilation mode, most of these functions vector into
-// their corresponding ns_* non-static variants.
-
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: MemoryUsage::track_memory_usage
 //     Function: MemoryUsage::track_memory_usage
@@ -380,5 +350,3 @@ INLINE void MemoryUsage::
 show_trend_ages() {
 show_trend_ages() {
   get_global_ptr()->ns_show_trend_ages();
   get_global_ptr()->ns_show_trend_ages();
 }
 }
-
-#endif // NDEBUG

+ 3 - 4
panda/src/express/memoryUsage.cxx

@@ -17,7 +17,6 @@
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 
 
 #ifdef DO_MEMORY_USAGE
 #ifdef DO_MEMORY_USAGE
-// Nothing in this module gets compiled in NDEBUG mode.
 
 
 #include "memoryUsagePointers.h"
 #include "memoryUsagePointers.h"
 #include "trueClock.h"
 #include "trueClock.h"
@@ -190,7 +189,7 @@ choose_bucket(double age) const {
   return 0;
   return 0;
 }
 }
 
 
-#if defined(__GNUC__) && !defined(NDEBUG)
+#if defined(__GNUC__)
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: MemoryUsage::record_pointer
 //     Function: MemoryUsage::record_pointer
@@ -243,7 +242,7 @@ remove_pointer(ReferenceCount *ptr) {
   get_global_ptr()->ns_remove_pointer(ptr);
   get_global_ptr()->ns_remove_pointer(ptr);
 }
 }
 
 
-#endif // __GNUC__ && !NDEBUG
+#endif // __GNUC__
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: MemoryUsage::operator_new_handler
 //     Function: MemoryUsage::operator_new_handler
@@ -1042,4 +1041,4 @@ consolidate_void_ptr(MemoryInfo &info) {
 }
 }
 
 
 
 
-#endif  // NDEBUG
+#endif  // DO_MEMORY_USAGE

+ 7 - 22
panda/src/express/memoryUsage.h

@@ -19,7 +19,7 @@
 #ifndef MEMORYUSAGE_H
 #ifndef MEMORYUSAGE_H
 #define MEMORYUSAGE_H
 #define MEMORYUSAGE_H
 
 
-#include <pandabase.h>
+#include "pandabase.h"
 
 
 #ifdef DO_MEMORY_USAGE
 #ifdef DO_MEMORY_USAGE
 
 
@@ -46,38 +46,24 @@ class EXPCL_PANDAEXPRESS MemoryUsage {
 public:
 public:
   INLINE static bool get_track_memory_usage();
   INLINE static bool get_track_memory_usage();
 
 
-#if defined(__GNUC__) && !defined(NDEBUG)
+#if defined(__GNUC__)
   // There seems to be a problem with egcs-2.91.66: it gets confused
   // There seems to be a problem with egcs-2.91.66: it gets confused
   // with too many nested inline functions, and sets the wrong pointer
   // with too many nested inline functions, and sets the wrong pointer
   // as 'this'.  Yucky.  The workaround is to make these functions
   // as 'this'.  Yucky.  The workaround is to make these functions
   // non-inline, but this is inner-loop stuff, and we'd rather not pay
   // non-inline, but this is inner-loop stuff, and we'd rather not pay
   // the price universally.  So we only compile them non-inline when
   // the price universally.  So we only compile them non-inline when
-  // we're building on GCC and not building in NDEBUG mode (in NDEBUG
-  // mode, these functions do nothing anyway).
+  // we're building on GCC.
   static void record_pointer(ReferenceCount *ptr);
   static void record_pointer(ReferenceCount *ptr);
   static void update_type(ReferenceCount *ptr, TypeHandle type);
   static void update_type(ReferenceCount *ptr, TypeHandle type);
   static void update_type(ReferenceCount *ptr, TypedObject *typed_ptr);
   static void update_type(ReferenceCount *ptr, TypedObject *typed_ptr);
   static void remove_pointer(ReferenceCount *ptr);
   static void remove_pointer(ReferenceCount *ptr);
-#else // __GNUC__ && !NDEBUG
+#else // __GNUC__
   INLINE static void record_pointer(ReferenceCount *ptr);
   INLINE static void record_pointer(ReferenceCount *ptr);
   INLINE static void update_type(ReferenceCount *ptr, TypeHandle type);
   INLINE static void update_type(ReferenceCount *ptr, TypeHandle type);
   INLINE static void update_type(ReferenceCount *ptr, TypedObject *typed_ptr);
   INLINE static void update_type(ReferenceCount *ptr, TypedObject *typed_ptr);
   INLINE static void remove_pointer(ReferenceCount *ptr);
   INLINE static void remove_pointer(ReferenceCount *ptr);
-#endif // __GNUC__ && !NDEBUG
+#endif // __GNUC__
 
 
-#ifdef NDEBUG
-public:
-  INLINE static bool is_tracking() { return false; }
-  INLINE static bool is_counting() { return false; }
-  INLINE static size_t get_current_cpp_size() { return 0; }
-  INLINE static bool has_cpp_size() { return false; }
-  INLINE static size_t get_cpp_size() { return 0; }
-  INLINE static bool has_interpreter_size() { return false; }
-  INLINE static size_t get_interpreter_size() { return 0; }
-  INLINE static bool has_total_size() { return false; }
-  INLINE static size_t get_total_size() { return 0; }
-
-#else  // NDEBUG
 public:
 public:
   static void *operator_new_handler(size_t size);
   static void *operator_new_handler(size_t size);
   static void operator_delete_handler(void *ptr);
   static void operator_delete_handler(void *ptr);
@@ -194,12 +180,11 @@ private:
 
 
   bool _track_memory_usage;
   bool _track_memory_usage;
   bool _count_memory_usage;
   bool _count_memory_usage;
-
-#endif  // NDEBUG
 };
 };
 
 
 #include "memoryUsage.I"
 #include "memoryUsage.I"
-#endif
+
+#endif  // DO_MEMORY_USAGE
 
 
 #endif
 #endif
 
 

+ 1 - 2
panda/src/express/memoryUsagePointerCounts.cxx

@@ -17,7 +17,6 @@
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 
 
 #ifdef DO_MEMORY_USAGE
 #ifdef DO_MEMORY_USAGE
-// Nothing in this module gets compiled in NDEBUG mode.
 
 
 #include "memoryUsagePointerCounts.h"
 #include "memoryUsagePointerCounts.h"
 #include "memoryInfo.h"
 #include "memoryInfo.h"
@@ -78,5 +77,5 @@ output_bytes(ostream &out, size_t size) {
   }
   }
 }
 }
 
 
-#endif  // NDEBUG
+#endif  // DO_MEMORY_USAGE
 
 

+ 2 - 2
panda/src/express/memoryUsagePointerCounts.h

@@ -19,7 +19,7 @@
 #ifndef MEMORYUSAGEPOINTERCOUNTS_H
 #ifndef MEMORYUSAGEPOINTERCOUNTS_H
 #define MEMORYUSAGEPOINTERCOUNTS_H
 #define MEMORYUSAGEPOINTERCOUNTS_H
 
 
-#include <pandabase.h>
+#include "pandabase.h"
 
 
 #ifdef DO_MEMORY_USAGE
 #ifdef DO_MEMORY_USAGE
 
 
@@ -62,7 +62,7 @@ INLINE ostream &operator << (ostream &out, const MemoryUsagePointerCounts &c);
 
 
 #include "memoryUsagePointerCounts.I"
 #include "memoryUsagePointerCounts.I"
 
 
-#endif  // NDEBUG
+#endif  // DO_MEMORY_USAGE
 
 
 #endif
 #endif
 
 

+ 1 - 2
panda/src/express/memoryUsagePointers.cxx

@@ -17,7 +17,6 @@
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 
 
 #ifdef DO_MEMORY_USAGE
 #ifdef DO_MEMORY_USAGE
-// Nothing in this module gets compiled in NDEBUG mode.
 
 
 #include "memoryUsagePointers.h"
 #include "memoryUsagePointers.h"
 #include "config_express.h"
 #include "config_express.h"
@@ -169,4 +168,4 @@ add_entry(ReferenceCount *ref_ptr, TypedObject *typed_ptr,
 }
 }
 
 
 
 
-#endif // NDEBUG
+#endif  // DO_MEMORY_USAGE

+ 2 - 2
panda/src/express/memoryUsagePointers.h

@@ -19,7 +19,7 @@
 #ifndef MEMORYUSAGEPOINTERS_H
 #ifndef MEMORYUSAGEPOINTERS_H
 #define MEMORYUSAGEPOINTERS_H
 #define MEMORYUSAGEPOINTERS_H
 
 
-#include <pandabase.h>
+#include "pandabase.h"
 
 
 #ifdef DO_MEMORY_USAGE
 #ifdef DO_MEMORY_USAGE
 
 
@@ -93,7 +93,7 @@ private:
 
 
 #include "memoryUsagePointers.I"
 #include "memoryUsagePointers.I"
 
 
-#endif  // NDEBUG
+#endif  // MEMORY_USAGE_POINTERS
 
 
 #endif
 #endif
 
 

+ 4 - 0
panda/src/express/multifile.h

@@ -68,6 +68,9 @@ private:
 
 
   INLINE void write_header(ofstream &write_stream);
   INLINE void write_header(ofstream &write_stream);
 
 
+public:
+  // This nested class must be public so we can make a list of its
+  // pointers.  Weird.
   class Memfile {
   class Memfile {
   public:
   public:
     Memfile(void);
     Memfile(void);
@@ -99,6 +102,7 @@ private:
     int _bytes_written;
     int _bytes_written;
   };
   };
 
 
+private:
   typedef plist<Memfile *> MemfileList;
   typedef plist<Memfile *> MemfileList;
 
 
   class MemfileMatch {
   class MemfileMatch {

+ 0 - 6
panda/src/pandabase/pandabase.h

@@ -26,11 +26,5 @@
 #include <dtoolbase.h>
 #include <dtoolbase.h>
 #include "pandasymbols.h"
 #include "pandasymbols.h"
 
 
-#if defined(UNKNOWN_ALLOCATOR) || defined(NDEBUG)
-#undef DO_MEMORY_USAGE
-#else
-#define DO_MEMORY_USAGE
-#endif
-
 #endif
 #endif