Browse Source

Fix a variety of ABI compatibility issues

We need third-party extensions that link with the Panda3D libraries to continue to work when shipping them with the optimized libraries that deploy-ng uses.  To do this, we need the optimized build not to omit symbols that these extensions might depend on.
rdb 6 years ago
parent
commit
f4926bff20

+ 0 - 8
dtool/src/dtoolbase/memoryBase.h

@@ -23,8 +23,6 @@
 // MemoryBase; this macro is provided to resolve problems with multiple
 // inheritance or some such.
 
-#ifndef USE_MEMORY_NOWRAPPERS
-
 #define ALLOC_MEMORY_BASE                                    \
   inline void *operator new(size_t size) RETURNS_ALIGNED(MEMORY_HOOK_ALIGNMENT) { \
     return PANDA_MALLOC_SINGLE(size);                        \
@@ -51,12 +49,6 @@
   inline void operator delete[](void *, void *) {            \
   }
 
-#else   // USE_MEMORY_NOWRAPPERS
-
-#define ALLOC_MEMORY_BASE
-
-#endif  // USE_MEMORY_NOWRAPPERS
-
 /**
  * This class is intended to be the base class of all objects in Panda that
  * might be allocated and deleted via the new and delete operators.  It

+ 2 - 2
panda/src/express/dcast.cxx

@@ -21,7 +21,6 @@
 #include <windows.h>  // for IsBadWritePtr()
 #endif
 
-#ifdef DO_DCAST
 /**
  * This function performs the actual check that the indicated TypedObject
  * pointer is of the intended type.
@@ -29,6 +28,7 @@
 bool
 _dcast_verify(TypeHandle want_handle, size_t want_size,
               const TypedObject *ptr) {
+#ifdef DO_DCAST
   if (get_verify_dcast()) {
     if (ptr == nullptr) {
       // This is allowed these days.  It used to be an error, but what the
@@ -54,7 +54,7 @@ _dcast_verify(TypeHandle want_handle, size_t want_size,
       return false;
     }
   }
+#endif  // DO_DCAST
 
   return true;
 }
-#endif  // DO_DCAST

+ 3 - 3
panda/src/express/dcast.h

@@ -62,12 +62,12 @@ INLINE WantType *_dcast_ref(WantType *&, TypedObject *ptr);
 template<class WantType>
 INLINE const WantType *_dcast_ref(WantType *&, const TypedObject *ptr);
 
-#ifdef DO_DCAST
-// _dcast_verify performs the actual verification.
+// _dcast_verify performs the actual verification.  This is an empty function
+// when DO_DCAST is not set, but we still need to define it for ABI
+// compatibility reasons.
 EXPCL_PANDA_EXPRESS bool
 _dcast_verify(TypeHandle want_handle, size_t want_size,
               const TypedObject *ptr);
-#endif  // DO_DCAST
 
 #define DCAST_INTO_V(to_pointer, from_pointer) \
   { \

+ 42 - 2
panda/src/pstatclient/pStatClient.cxx

@@ -12,6 +12,8 @@
  */
 
 #include "pStatClient.h"
+#include "pStatCollector.h"
+#include "pStatThread.h"
 
 #ifdef DO_PSTATS
 // This file only defines anything interesting if DO_PSTATS is defined.
@@ -19,8 +21,6 @@
 #include "pStatClientImpl.h"
 #include "pStatClientControlMessage.h"
 #include "pStatServerControlMessage.h"
-#include "pStatCollector.h"
-#include "pStatThread.h"
 #include "config_pstatclient.h"
 #include "pStatProperties.h"
 #include "thread.h"
@@ -1222,4 +1222,44 @@ InternalThread(const string &name, const string &sync_name) :
 {
 }
 
+#else  // DO_PSTATS
+
+PStatThread PStatClient::
+get_main_thread() const {
+  return PStatThread((PStatClient *)this, 0);
+}
+
+PStatThread PStatClient::
+get_current_thread() const {
+  return get_main_thread();
+}
+
+PStatCollector PStatClient::
+make_collector_with_relname(int parent_index, std::string relname) {
+  return PStatCollector();
+}
+
+PStatClient *PStatClient::
+get_global_pstats() {
+  static PStatClient global_pstats;
+  return &global_pstats;
+}
+
+void PStatClient::
+start(int collector_index, int thread_index) {
+}
+
+void PStatClient::
+start(int collector_index, int thread_index, double as_of) {
+}
+
+void PStatClient::
+stop(int collector_index, int thread_index) {
+}
+
+void PStatClient::
+stop(int collector_index, int thread_index, double as_of) {
+}
+
+
 #endif // DO_PSTATS

+ 26 - 0
panda/src/pstatclient/pStatClient.h

@@ -266,6 +266,12 @@ public:
   ~PStatClient() { }
 
 PUBLISHED:
+  std::string get_collector_name(int index) const { return std::string(); }
+  std::string get_collector_fullname(int index) const { return std::string(); }
+
+  PStatThread get_main_thread() const;
+  PStatThread get_current_thread() const;
+
   INLINE static bool connect(const std::string & = std::string(), int = -1) { return false; }
   INLINE static void disconnect() { }
   INLINE static bool is_connected() { return false; }
@@ -273,6 +279,26 @@ PUBLISHED:
 
   INLINE static void main_tick() { }
   INLINE static void thread_tick(const std::string &) { }
+
+  static PStatClient *get_global_pstats();
+
+private:
+  // These are used by inline PStatCollector methods, so they need to be
+  // stubbed out for ABI compatibility.
+  PStatCollector make_collector_with_relname(int parent_index, std::string relname);
+
+  bool is_active(int collector_index, int thread_index) const { return false; }
+  bool is_started(int collector_index, int thread_index) const { return false; }
+
+  void start(int collector_index, int thread_index);
+  void start(int collector_index, int thread_index, double as_of);
+  void stop(int collector_index, int thread_index);
+  void stop(int collector_index, int thread_index, double as_of);
+
+  void clear_level(int collector_index, int thread_index) { }
+  void set_level(int collector_index, int thread_index, double level) { }
+  void add_level(int collector_index, int thread_index, double increment) { }
+  double get_level(int collector_index, int thread_index) const { return 0.0; }
 };
 
 #endif  // DO_PSTATS