Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Pursue deprecation of xbt/synchro.h.
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Fri, 7 Feb 2020 08:13:55 +0000 (09:13 +0100)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Fri, 7 Feb 2020 09:26:53 +0000 (10:26 +0100)
MANIFEST.in
include/simgrid/simix.h
include/xbt/synchro.h
src/simix/libsmx.cpp
src/smpi/include/smpi_actor.hpp
src/smpi/include/smpi_win.hpp
src/xbt/xbt_os_synchro.cpp [deleted file]
teshsuite/mc/mutex-handling/mutex-handling.cpp
tools/cmake/DefinePackages.cmake

index 2416d0e..8063c67 100644 (file)
@@ -2663,7 +2663,6 @@ include src/xbt/xbt_log_layout_format.cpp
 include src/xbt/xbt_log_layout_simple.cpp
 include src/xbt/xbt_main.cpp
 include src/xbt/xbt_os_file.cpp
 include src/xbt/xbt_log_layout_simple.cpp
 include src/xbt/xbt_main.cpp
 include src/xbt/xbt_os_file.cpp
-include src/xbt/xbt_os_synchro.cpp
 include src/xbt/xbt_os_time.c
 include src/xbt/xbt_replay.cpp
 include src/xbt/xbt_str.cpp
 include src/xbt/xbt_os_time.c
 include src/xbt/xbt_replay.cpp
 include src/xbt/xbt_str.cpp
index e56b0a8..24fbc8e 100644 (file)
@@ -198,12 +198,12 @@ XBT_ATTRIB_DEPRECATED_v330("Please use a ActivityImpl* for first parameter") inl
 
 /************************** Synchro simcalls **********************************/
 SG_BEGIN_DECL
 
 /************************** Synchro simcalls **********************************/
 SG_BEGIN_DECL
-XBT_PUBLIC smx_mutex_t simcall_mutex_init();
+XBT_ATTRIB_DEPRECATED_v330("Please use sg_mutex_init()") XBT_PUBLIC smx_mutex_t simcall_mutex_init();
 XBT_PUBLIC void simcall_mutex_lock(smx_mutex_t mutex);
 XBT_PUBLIC int simcall_mutex_trylock(smx_mutex_t mutex);
 XBT_PUBLIC void simcall_mutex_unlock(smx_mutex_t mutex);
 
 XBT_PUBLIC void simcall_mutex_lock(smx_mutex_t mutex);
 XBT_PUBLIC int simcall_mutex_trylock(smx_mutex_t mutex);
 XBT_PUBLIC void simcall_mutex_unlock(smx_mutex_t mutex);
 
-XBT_PUBLIC smx_cond_t simcall_cond_init();
+XBT_ATTRIB_DEPRECATED_v330("Please use sg_cond_init()") XBT_PUBLIC smx_cond_t simcall_cond_init();
 XBT_PUBLIC void simcall_cond_wait(smx_cond_t cond, smx_mutex_t mutex);
 XBT_PUBLIC int simcall_cond_wait_timeout(smx_cond_t cond, smx_mutex_t mutex, double max_duration);
 
 XBT_PUBLIC void simcall_cond_wait(smx_cond_t cond, smx_mutex_t mutex);
 XBT_PUBLIC int simcall_cond_wait_timeout(smx_cond_t cond, smx_mutex_t mutex, double max_duration);
 
index d882899..f1b8722 100644 (file)
@@ -5,13 +5,15 @@
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
-#ifndef XBT_THREAD_H
-#define XBT_THREAD_H
+#ifndef XBT_SYNCHRO_H
+#define XBT_SYNCHRO_H
 
 
-#include "simgrid/forward.h"
-#include <xbt/function_types.h>
+#include "simgrid/cond.h"
+#include "simgrid/mutex.h"
 #include <xbt/misc.h> /* SG_BEGIN_DECL */
 
 #include <xbt/misc.h> /* SG_BEGIN_DECL */
 
+#warning xbt/synchro.h is deprecated and will be removed in v3.28.
+
 SG_BEGIN_DECL
 
 /** @addtogroup XBT_synchro
 SG_BEGIN_DECL
 
 /** @addtogroup XBT_synchro
@@ -27,17 +29,19 @@ SG_BEGIN_DECL
 /** @brief Thread mutex data type (opaque object)
  *  @hideinitializer
  */
 /** @brief Thread mutex data type (opaque object)
  *  @hideinitializer
  */
-#ifdef __cplusplus
-typedef simgrid::kernel::activity::MutexImpl* xbt_mutex_t;
-#else
-typedef struct s_smx_mutex_* xbt_mutex_t;
-#endif
+typedef sg_mutex_t xbt_mutex_t;
 
 /** @brief Creates a new mutex variable */
 
 /** @brief Creates a new mutex variable */
-XBT_ATTRIB_DEPRECATED_v328("Please use sg_mutex_init") XBT_PUBLIC xbt_mutex_t xbt_mutex_init(void);
+XBT_ATTRIB_DEPRECATED_v328("Please use sg_mutex_init") static inline xbt_mutex_t xbt_mutex_init(void)
+{
+  return sg_mutex_init();
+}
 
 /** @brief Blocks onto the given mutex variable */
 
 /** @brief Blocks onto the given mutex variable */
-XBT_ATTRIB_DEPRECATED_v328("Please use sg_mutex_lock") XBT_PUBLIC void xbt_mutex_acquire(xbt_mutex_t mutex);
+XBT_ATTRIB_DEPRECATED_v328("Please use sg_mutex_lock") static inline void xbt_mutex_acquire(xbt_mutex_t mutex)
+{
+  sg_mutex_lock(mutex);
+}
 
 /** @brief Tries to block onto the given mutex variable
  * Tries to lock a mutex, return 1 if the mutex is unlocked, else 0.
 
 /** @brief Tries to block onto the given mutex variable
  * Tries to lock a mutex, return 1 if the mutex is unlocked, else 0.
@@ -45,40 +49,69 @@ XBT_ATTRIB_DEPRECATED_v328("Please use sg_mutex_lock") XBT_PUBLIC void xbt_mutex
  * @param mutex The mutex
  * @return 1 - mutex free, 0 - mutex used
  */
  * @param mutex The mutex
  * @return 1 - mutex free, 0 - mutex used
  */
-XBT_ATTRIB_DEPRECATED_v328("Please use sg_mutex_try_lock") XBT_PUBLIC int xbt_mutex_try_acquire(xbt_mutex_t mutex);
+XBT_ATTRIB_DEPRECATED_v328("Please use sg_mutex_try_lock") static inline int xbt_mutex_try_acquire(xbt_mutex_t mutex)
+{
+  return sg_mutex_try_lock(mutex);
+}
 
 /** @brief Releases the given mutex variable */
 
 /** @brief Releases the given mutex variable */
-XBT_ATTRIB_DEPRECATED_v328("Please use sg_mutex_unlock") XBT_PUBLIC void xbt_mutex_release(xbt_mutex_t mutex);
+XBT_ATTRIB_DEPRECATED_v328("Please use sg_mutex_unlock") static inline void xbt_mutex_release(xbt_mutex_t mutex)
+{
+  sg_mutex_unlock(mutex);
+}
 
 /** @brief Destroys the given mutex variable */
 
 /** @brief Destroys the given mutex variable */
-XBT_ATTRIB_DEPRECATED_v328("Please use sg_mutex_destroy") XBT_PUBLIC void xbt_mutex_destroy(xbt_mutex_t mutex);
+XBT_ATTRIB_DEPRECATED_v328("Please use sg_mutex_destroy") static inline void xbt_mutex_destroy(xbt_mutex_t mutex)
+{
+  sg_mutex_destroy(mutex);
+}
 
 /** @brief Thread condition data type (opaque object)
  *  @hideinitializer
  */
 
 /** @brief Thread condition data type (opaque object)
  *  @hideinitializer
  */
-#ifdef __cplusplus
-typedef simgrid::kernel::activity::ConditionVariableImpl* xbt_cond_t;
-#else
-typedef struct s_smx_cond_* xbt_cond_t;
-#endif
+typedef sg_cond_t xbt_cond_t;
 
 /** @brief Creates a condition variable */
 
 /** @brief Creates a condition variable */
-XBT_ATTRIB_DEPRECATED_v328("Please use sg_cond_init") XBT_PUBLIC xbt_cond_t xbt_cond_init(void);
+XBT_ATTRIB_DEPRECATED_v328("Please use sg_cond_init") static inline xbt_cond_t xbt_cond_init(void)
+{
+  return sg_cond_init();
+}
 
 /** @brief Blocks onto the given condition variable */
 
 /** @brief Blocks onto the given condition variable */
-XBT_ATTRIB_DEPRECATED_v328("Please use sg_cond_wait") XBT_PUBLIC void xbt_cond_wait(xbt_cond_t cond, xbt_mutex_t mutex);
+XBT_ATTRIB_DEPRECATED_v328("Please use sg_cond_wait") static inline void xbt_cond_wait(xbt_cond_t cond,
+                                                                                       xbt_mutex_t mutex)
+{
+  sg_cond_wait(cond, mutex);
+}
+
 /** @brief Blocks onto the given condition variable, but only for the given amount of time.
  *  @return 0 on success, 1 on timeout */
 /** @brief Blocks onto the given condition variable, but only for the given amount of time.
  *  @return 0 on success, 1 on timeout */
-XBT_ATTRIB_DEPRECATED_v328("Please use sg_cond_wait_for") XBT_PUBLIC
-    int xbt_cond_timedwait(xbt_cond_t cond, xbt_mutex_t mutex, double delay);
+XBT_ATTRIB_DEPRECATED_v328("Please use sg_cond_wait_for") static inline int xbt_cond_timedwait(xbt_cond_t cond,
+                                                                                               xbt_mutex_t mutex,
+                                                                                               double delay)
+{
+  return sg_cond_wait_for(cond, mutex, delay);
+}
+
 /** @brief Signals the given mutex variable */
 /** @brief Signals the given mutex variable */
-XBT_ATTRIB_DEPRECATED_v328("Please use sg_cond_notify_one") XBT_PUBLIC void xbt_cond_signal(xbt_cond_t cond);
+XBT_ATTRIB_DEPRECATED_v328("Please use sg_cond_notify_one") static inline void xbt_cond_signal(xbt_cond_t cond)
+{
+  sg_cond_notify_one(cond);
+}
+
 /** @brief Broadcasts the given mutex variable */
 /** @brief Broadcasts the given mutex variable */
-XBT_ATTRIB_DEPRECATED_v328("Please use sg_cond_notify_all") XBT_PUBLIC void xbt_cond_broadcast(xbt_cond_t cond);
+XBT_ATTRIB_DEPRECATED_v328("Please use sg_cond_notify_all") static inline void xbt_cond_broadcast(xbt_cond_t cond)
+{
+  sg_cond_notify_all(cond);
+}
+
 /** @brief Destroys the given mutex variable */
 /** @brief Destroys the given mutex variable */
-XBT_ATTRIB_DEPRECATED_v328("Please use sg_cond_destroy") XBT_PUBLIC void xbt_cond_destroy(xbt_cond_t cond);
+XBT_ATTRIB_DEPRECATED_v328("Please use sg_cond_destroy") static inline void xbt_cond_destroy(xbt_cond_t cond)
+{
+  sg_cond_destroy(cond);
+}
 
 /** @} */
 
 SG_END_DECL
 
 /** @} */
 
 SG_END_DECL
-#endif /* _XBT_THREAD_H */
+#endif /* XBT_SYNCHRO_H */
index 2e4dc45..e66028a 100644 (file)
@@ -222,7 +222,7 @@ bool simcall_comm_test(simgrid::kernel::activity::ActivityImpl* comm)
  * @ingroup simix_synchro_management
  *
  */
  * @ingroup simix_synchro_management
  *
  */
-smx_mutex_t simcall_mutex_init()
+smx_mutex_t simcall_mutex_init() // XBT_ATTRIB_DEPRECATED_v330
 {
   if (simix_global == nullptr) {
     fprintf(stderr, "You must initialize the SimGrid engine before using it\n"); // We can't use xbt_die since we may
 {
   if (simix_global == nullptr) {
     fprintf(stderr, "You must initialize the SimGrid engine before using it\n"); // We can't use xbt_die since we may
@@ -263,7 +263,7 @@ void simcall_mutex_unlock(smx_mutex_t mutex)
  * @ingroup simix_synchro_management
  *
  */
  * @ingroup simix_synchro_management
  *
  */
-smx_cond_t simcall_cond_init()
+smx_cond_t simcall_cond_init() // XBT_ATTRIB_DEPRECATED_v330
 {
   return simgrid::kernel::actor::simcall([] { return new simgrid::kernel::activity::ConditionVariableImpl(); });
 }
 {
   return simgrid::kernel::actor::simcall([] { return new simgrid::kernel::activity::ConditionVariableImpl(); });
 }
index bd78da2..61ae4bc 100644 (file)
@@ -9,7 +9,6 @@
 #include "private.hpp"
 #include "simgrid/s4u/Mailbox.hpp"
 #include "src/instr/instr_smpi.hpp"
 #include "private.hpp"
 #include "simgrid/s4u/Mailbox.hpp"
 #include "src/instr/instr_smpi.hpp"
-#include "xbt/synchro.h"
 
 namespace simgrid {
 namespace smpi {
 
 namespace simgrid {
 namespace smpi {
index f9a1206..84a3f82 100644 (file)
@@ -11,7 +11,6 @@
 #include "smpi_errhandler.hpp"
 #include "smpi_f2c.hpp"
 #include "smpi_keyvals.hpp"
 #include "smpi_errhandler.hpp"
 #include "smpi_f2c.hpp"
 #include "smpi_keyvals.hpp"
-#include "xbt/synchro.h"
 
 #include <vector>
 #include <list>
 
 #include <vector>
 #include <list>
diff --git a/src/xbt/xbt_os_synchro.cpp b/src/xbt/xbt_os_synchro.cpp
deleted file mode 100644 (file)
index 65829c9..0000000
+++ /dev/null
@@ -1,71 +0,0 @@
-/* Classical synchro schema, implemented on top of SimGrid                  */
-
-/* Copyright (c) 2007-2020. The SimGrid Team.
- * All rights reserved.                                                     */
-
-/* This program is free software; you can redistribute it and/or modify it
- * under the terms of the license (GNU LGPL) which comes with this package. */
-
-#include "simgrid/Exception.hpp"
-#include "simgrid/simix.h" /* used implementation */
-#include "src/kernel/activity/ConditionVariableImpl.hpp"
-#include "src/kernel/activity/MutexImpl.hpp"
-#include "xbt/synchro.h"
-
-/****** mutex related functions ******/
-xbt_mutex_t xbt_mutex_init(void)
-{
-  return (xbt_mutex_t)simcall_mutex_init();
-}
-
-void xbt_mutex_acquire(xbt_mutex_t mutex)
-{
-  simcall_mutex_lock((smx_mutex_t)mutex);
-}
-
-int xbt_mutex_try_acquire(xbt_mutex_t mutex)
-{
-  return simcall_mutex_trylock((smx_mutex_t)mutex);
-}
-
-void xbt_mutex_release(xbt_mutex_t mutex)
-{
-  simcall_mutex_unlock((smx_mutex_t)mutex);
-}
-
-void xbt_mutex_destroy(xbt_mutex_t mutex)
-{
-  if (mutex != nullptr)
-    mutex->unref();
-}
-
-/***** condition related functions *****/
-xbt_cond_t xbt_cond_init(void)
-{
-  return (xbt_cond_t)simcall_cond_init();
-}
-
-void xbt_cond_wait(xbt_cond_t cond, xbt_mutex_t mutex)
-{
-  simcall_cond_wait((smx_cond_t)cond, (smx_mutex_t)mutex);
-}
-
-int xbt_cond_timedwait(xbt_cond_t cond, xbt_mutex_t mutex, double delay)
-{
-  return simcall_cond_wait_timeout((smx_cond_t)cond, (smx_mutex_t)mutex, delay);
-}
-
-void xbt_cond_signal(xbt_cond_t cond)
-{
-  cond->get_iface()->notify_one();
-}
-
-void xbt_cond_broadcast(xbt_cond_t cond)
-{
-  cond->get_iface()->notify_all();
-}
-
-void xbt_cond_destroy(xbt_cond_t cond)
-{
-  delete cond;
-}
index 4e00e3d..fe63b5a 100644 (file)
@@ -23,7 +23,6 @@
 #include "simgrid/s4u/Host.hpp"
 #include "simgrid/s4u/Mailbox.hpp"
 #include "simgrid/s4u/Mutex.hpp"
 #include "simgrid/s4u/Host.hpp"
 #include "simgrid/s4u/Mailbox.hpp"
 #include "simgrid/s4u/Mutex.hpp"
-#include <xbt/synchro.h>
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, "Messages specific for this msg example");
 
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, "Messages specific for this msg example");
 
index a0fe3ef..7b922bc 100644 (file)
@@ -293,7 +293,6 @@ set(XBT_SRC
   src/xbt/xbt_log_layout_simple.cpp
   src/xbt/xbt_main.cpp
   src/xbt/xbt_os_file.cpp
   src/xbt/xbt_log_layout_simple.cpp
   src/xbt/xbt_main.cpp
   src/xbt/xbt_os_file.cpp
-  src/xbt/xbt_os_synchro.cpp
   src/xbt/xbt_os_time.c
   src/xbt/xbt_replay.cpp
   src/xbt/xbt_str.cpp
   src/xbt/xbt_os_time.c
   src/xbt/xbt_replay.cpp
   src/xbt/xbt_str.cpp