Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
avoid potential division by 0... But not sure 0 is right as an answer here
[simgrid.git] / src / simix / popping_private.h
index 934565c..160e55e 100644 (file)
@@ -11,6 +11,7 @@
 
 #include <src/kernel/activity/ActivityImpl.hpp>
 #include <src/kernel/activity/CommImpl.hpp>
+#include <src/kernel/activity/ExecImpl.hpp>
 
 #include <boost/intrusive_ptr.hpp>
 
@@ -21,7 +22,7 @@ XBT_PUBLIC_DATA(const char*) simcall_names[]; /* Name of each simcall */
 
 #include "popping_enum.h" /* Definition of e_smx_simcall_t, with one value per simcall */
 
-typedef int (*simix_match_func_t)(void *, void *, smx_activity_t);
+typedef int (*simix_match_func_t)(void*, void*, simgrid::kernel::activity::CommImpl*);
 typedef void (*simix_copy_data_func_t)(smx_activity_t, void*, size_t);
 typedef void (*simix_clean_func_t)(void *);
 typedef void (*FPtr)(void); // Hide the ugliness
@@ -121,9 +122,11 @@ SIMIX_MARSHAL(FPtr, fp);
 
 inline void unmarshal(type<void>, u_smx_scalar const& simcall)
 {
+  /* Nothing to do for void data */
 }
 inline void unmarshal_raw(type<void>, u_smx_scalar const& simcall)
 {
+  /* Nothing to do for void data */
 }
 
 template<class T> inline
@@ -144,13 +147,17 @@ template <class T> inline T* unmarshal_raw(type<T*>, u_smx_scalar const& simcall
 template <class T>
 inline void marshal(type<boost::intrusive_ptr<T>>, u_smx_scalar& simcall, boost::intrusive_ptr<T> value)
 {
-  intrusive_ptr_add_ref(&*value);
-  simcall.dp = static_cast<void*>(&*value);
+  if (value.get() == nullptr) { // Sometimes we return nullptr in an intrusive_ptr...
+    simcall.dp = nullptr;
+  } else {
+    intrusive_ptr_add_ref(&*value);
+    simcall.dp = static_cast<void*>(&*value);
+  }
 }
 template <class T> inline boost::intrusive_ptr<T> unmarshal(type<boost::intrusive_ptr<T>>, u_smx_scalar const& simcall)
 {
+  // refcount was already increased during the marshaling, thus the "false" as last argument
   boost::intrusive_ptr<T> res = boost::intrusive_ptr<T>(static_cast<T*>(simcall.dp), false);
-  // intrusive_ptr_release(&*res);
   return res;
 }
 template <class T> inline T* unmarshal_raw(type<boost::intrusive_ptr<T>>, u_smx_scalar const& simcall)