Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Extend definition of simcalls to include a pointer to the simcall handler functions.
authorCristian Rosa <cristian@rtfm.org.ar>
Fri, 7 Sep 2012 15:33:18 +0000 (12:33 -0300)
committershenshei <paul.bedaride@gmail.com>
Wed, 28 Nov 2012 08:15:42 +0000 (09:15 +0100)
Use these pointers to initialize a simcall dispatch table.

src/simix/smx_smurf.c
src/simix/smx_smurf_private.h
src/simix/smx_user.c

index 91c67a4..0ef4ca3 100644 (file)
@@ -198,7 +198,7 @@ void SIMIX_simcall_pre(smx_simcall_t simcall, int value)
       SIMIX_simcall_answer(simcall);
       break;
 
       SIMIX_simcall_answer(simcall);
       break;
 
-    case SIMCALL_RDV_GEY_BY_NAME:
+    case SIMCALL_RDV_GET_BY_NAME:
       simcall->rdv_get_by_name.result =
         SIMIX_rdv_get_by_name(simcall->rdv_get_by_name.name);
       SIMIX_simcall_answer(simcall);
       simcall->rdv_get_by_name.result =
         SIMIX_rdv_get_by_name(simcall->rdv_get_by_name.name);
       SIMIX_simcall_answer(simcall);
@@ -623,7 +623,13 @@ void SIMIX_simcall_post(smx_action_t action)
 /* FIXME: add types for every simcall */
 const char *simcall_types[NUM_SIMCALLS] = { [SIMCALL_HOST_EXECUTE] = "%s%p%f%f%p" };
 
 /* FIXME: add types for every simcall */
 const char *simcall_types[NUM_SIMCALLS] = { [SIMCALL_HOST_EXECUTE] = "%s%p%f%f%p" };
 
-simcall_handler_t simcall_table[NUM_SIMCALLS] = {[SIMCALL_HOST_EXECUTE] = &SIMIX_host_execute};
+simcall_handler_t simcall_table[NUM_SIMCALLS] = {
+#undef SIMCALL_ENUM_ELEMENT
+#define SIMCALL_ENUM_ELEMENT(x,y) &y /* generate strings from the enumeration values */
+SIMCALL_LIST
+#undef SIMCALL_ENUM_ELEMENT
+};
+
 
 void SIMIX_simcall_typecheck(const char *fmt, ...)
 {
 
 void SIMIX_simcall_typecheck(const char *fmt, ...)
 {
index 7ba6aec..f6e0389 100644 (file)
@@ -9,8 +9,14 @@
 
 /********************************* Simcalls *********************************/
 
 
 /********************************* Simcalls *********************************/
 
-/* we want to build the e_smx_simcall_t enumeration and the table of the
- * corresponding strings automatically, using macros */
+/* we want to build the e_smx_simcall_t enumeration, the table of the
+ * corresponding simcalls string names, and the simcall handlers table
+ * automatically, using macros.
+ * To add a new simcall follow the following syntax:
+ *
+ * SIMCALL_ENUM_ELEMENT(<simcall_enumeration_id>, <simcall_handler_function>)
+ *
+ * */
 
 #define SIMCALL_LIST1 \
 SIMCALL_ENUM_ELEMENT(SIMCALL_NONE),\
 
 #define SIMCALL_LIST1 \
 SIMCALL_ENUM_ELEMENT(SIMCALL_NONE),\
@@ -107,14 +113,14 @@ SIMCALL_ENUM_ELEMENT(SIMCALL_NEW_API_INIT)
  * because they are not always present */
 #ifdef HAVE_LATENCY_BOUND_TRACKING
 #define SIMCALL_LIST2 \
  * because they are not always present */
 #ifdef HAVE_LATENCY_BOUND_TRACKING
 #define SIMCALL_LIST2 \
-,SIMCALL_ENUM_ELEMENT(SIMCALL_COMM_IS_LATENCY_BOUNDED)
+,SIMCALL_ENUM_ELEMENT(SIMCALL_COMM_IS_LATENCY_BOUNDED, SIMIX_comm_is_latency_bounded)
 #else
 #define SIMCALL_LIST2
 #endif
 
 #ifdef HAVE_TRACING
 #define SIMCALL_LIST3 \
 #else
 #define SIMCALL_LIST2
 #endif
 
 #ifdef HAVE_TRACING
 #define SIMCALL_LIST3 \
-,SIMCALL_ENUM_ELEMENT(SIMCALL_SET_CATEGORY)
+,SIMCALL_ENUM_ELEMENT(SIMCALL_SET_CATEGORY, SIMIX_set_category)
 #else
 #define SIMCALL_LIST3
 #endif
 #else
 #define SIMCALL_LIST3
 #endif
@@ -132,7 +138,7 @@ SIMCALL_ENUM_ELEMENT(SIMCALL_NEW_API_INIT)
 
 /* you can redefine the following macro differently to generate something else
  * with the list of enumeration values (e.g. a table of strings or a table of function pointers) */
 
 /* you can redefine the following macro differently to generate something else
  * with the list of enumeration values (e.g. a table of strings or a table of function pointers) */
-#define SIMCALL_ENUM_ELEMENT(x) x
+#define SIMCALL_ENUM_ELEMENT(x, y) x
 
 /**
  * \brief All possible simcalls.
 
 /**
  * \brief All possible simcalls.
index db657c1..d019078 100644 (file)
@@ -14,7 +14,7 @@ XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(simix);
 
 static const char* simcall_names[] = {
 #undef SIMCALL_ENUM_ELEMENT
 
 static const char* simcall_names[] = {
 #undef SIMCALL_ENUM_ELEMENT
-#define SIMCALL_ENUM_ELEMENT(x) #x /* generate strings from the enumeration values */
+#define SIMCALL_ENUM_ELEMENT(x,y) #x /* generate strings from the enumeration values */
 SIMCALL_LIST
 #undef SIMCALL_ENUM_ELEMENT
 };
 SIMCALL_LIST
 #undef SIMCALL_ENUM_ELEMENT
 };