Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Don't hide type real type, smx_process_t, behind a void*.
authorArnaud Giersch <arnaud.giersch@iut-bm.univ-fcomte.fr>
Sat, 8 Feb 2014 10:35:39 +0000 (11:35 +0100)
committerArnaud Giersch <arnaud.giersch@iut-bm.univ-fcomte.fr>
Sat, 8 Feb 2014 10:35:39 +0000 (11:35 +0100)
include/simgrid/simix.h
src/bindings/java/smx_context_cojava.c
src/bindings/java/smx_context_java.c
src/simix/smx_context_base.c
src/simix/smx_context_raw.c
src/simix/smx_context_sysv.c
src/simix/smx_context_thread.c
src/simix/smx_private.h
src/simix/smx_process.c

index 6bd38df..a50748b 100644 (file)
@@ -140,8 +140,8 @@ typedef void (*void_pfn_smxhost_t) (smx_host_t);
    factory should implement */
 
 
-typedef smx_context_t(*smx_pfn_context_factory_create_context_t)
-  (xbt_main_func_t, int, char **, void_pfn_smxprocess_t, void* data);
+typedef smx_context_t (*smx_pfn_context_factory_create_context_t)(
+  xbt_main_func_t, int, char **, void_pfn_smxprocess_t, smx_process_t process);
 typedef int (*smx_pfn_context_factory_finalize_t) (smx_context_factory_t*);
 typedef void (*smx_pfn_context_free_t) (smx_context_t);
 typedef void (*smx_pfn_context_start_t) (smx_context_t);
@@ -149,7 +149,7 @@ typedef void (*smx_pfn_context_stop_t) (smx_context_t);
 typedef void (*smx_pfn_context_suspend_t) (smx_context_t context);
 typedef void (*smx_pfn_context_runall_t) (void);
 typedef smx_context_t (*smx_pfn_context_self_t) (void);
-typedef void* (*smx_pfn_context_get_data_t) (smx_context_t context);
+typedef smx_process_t (*smx_pfn_context_get_process_t) (smx_context_t context);
 
 /* interface of the context factories */
 typedef struct s_smx_context_factory {
@@ -161,7 +161,7 @@ typedef struct s_smx_context_factory {
   smx_pfn_context_suspend_t suspend;
   smx_pfn_context_runall_t runall;
   smx_pfn_context_self_t self;
-  smx_pfn_context_get_data_t get_data;
+  smx_pfn_context_get_process_t get_process;
 } s_smx_context_factory_t;
 
 /* Hack: let msg load directly the right factory */
@@ -182,7 +182,7 @@ typedef struct s_smx_context {
   s_xbt_swag_hookup_t hookup;
   xbt_main_func_t code;
   void_pfn_smxprocess_t cleanup_func;
-  void *data;   /* Here SIMIX stores the smx_process_t containing the context */
+  smx_process_t process;
   char **argv;
   int argc;
   unsigned iwannadie:1;
@@ -193,15 +193,14 @@ XBT_PUBLIC(void) smx_ctx_base_factory_init(smx_context_factory_t *factory);
 XBT_PUBLIC(int) smx_ctx_base_factory_finalize(smx_context_factory_t *factory);
 
 XBT_PUBLIC(smx_context_t)
-smx_ctx_base_factory_create_context_sized(size_t size,
-                                          xbt_main_func_t code, int argc,
-                                          char **argv,
+smx_ctx_base_factory_create_context_sized(size_t size, xbt_main_func_t code,
+                                          int argc, char **argv,
                                           void_pfn_smxprocess_t cleanup,
-                                          void* data);
+                                          smx_process_t process);
 XBT_PUBLIC(void) smx_ctx_base_free(smx_context_t context);
 XBT_PUBLIC(void) smx_ctx_base_stop(smx_context_t context);
 XBT_PUBLIC(smx_context_t) smx_ctx_base_self(void);
-XBT_PUBLIC(void) *smx_ctx_base_get_data(smx_context_t context);
+XBT_PUBLIC(smx_process_t) smx_ctx_base_get_process(smx_context_t context);
 
 XBT_PUBLIC(xbt_dynar_t) SIMIX_process_get_runnable(void);
 XBT_PUBLIC(smx_process_t) SIMIX_process_from_PID(int PID);
index fd064e8..3503536 100644 (file)
@@ -38,10 +38,10 @@ XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(jmsg);
 
 
 static smx_context_t
-smx_ctx_cojava_factory_create_context(xbt_main_func_t code, int argc,
-                                    char **argv,
-                                    void_pfn_smxprocess_t cleanup_func,
-                                    void *data);
+smx_ctx_cojava_factory_create_context(xbt_main_func_t code,
+                                      int argc, char **argv,
+                                      void_pfn_smxprocess_t cleanup_func,
+                                      smx_process_t process);
 
 static void smx_ctx_cojava_free(smx_context_t context);
 static void smx_ctx_cojava_suspend(smx_context_t context);
@@ -63,7 +63,7 @@ void SIMIX_ctx_cojava_factory_init(smx_context_factory_t * factory)
   (*factory)->name = "ctx_cojava_factory";
   //(*factory)->finalize = smx_ctx_base_factory_finalize;
   (*factory)->self = smx_ctx_cojava_self;
-  (*factory)->get_data = smx_ctx_base_get_data;
+  (*factory)->get_process = smx_ctx_base_get_process;
 
   global_env = get_current_thread_env();
 
@@ -114,10 +114,10 @@ smx_context_t smx_ctx_cojava_self(void)
 }
 
 static smx_context_t
-smx_ctx_cojava_factory_create_context(xbt_main_func_t code, int argc,
-                                    char **argv,
-                                    void_pfn_smxprocess_t cleanup_func,
-                                    void* data)
+smx_ctx_cojava_factory_create_context(xbt_main_func_t code,
+                                      int argc, char **argv,
+                                      void_pfn_smxprocess_t cleanup_func,
+                                      smx_process_t process)
 {
        smx_ctx_cojava_t context = xbt_new0(s_smx_ctx_cojava_t, 1);
   /* If the user provided a function for the process then use it
@@ -143,7 +143,7 @@ smx_ctx_cojava_factory_create_context(xbt_main_func_t code, int argc,
        maestro_context = (smx_context_t)context;
   }
   context->bound = 0;
-  context->super.data = data;
+  context->super.process = process;
   return (smx_context_t) context;
 }
 
index e205682..de35188 100644 (file)
@@ -17,10 +17,10 @@ extern JavaVM *__java_vm;
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(jmsg, bindings, "MSG for Java(TM)");
 
 static smx_context_t
-smx_ctx_java_factory_create_context(xbt_main_func_t code, int argc,
-                                    char **argv,
+smx_ctx_java_factory_create_context(xbt_main_func_t code,
+                                    int argc, char **argv,
                                     void_pfn_smxprocess_t cleanup_func,
-                                    void *data);
+                                    smx_process_t process);
 
 static void smx_ctx_java_free(smx_context_t context);
 static void smx_ctx_java_suspend(smx_context_t context);
@@ -41,7 +41,7 @@ void SIMIX_ctx_java_factory_init(smx_context_factory_t * factory)
   (*factory)->name = "ctx_java_factory";
   //(*factory)->finalize = smx_ctx_base_factory_finalize;
   (*factory)->self = smx_ctx_java_self;
-  (*factory)->get_data = smx_ctx_base_get_data;
+  (*factory)->get_process = smx_ctx_base_get_process;
 }
 smx_context_t smx_ctx_java_self(void)
 {
@@ -49,10 +49,10 @@ smx_context_t smx_ctx_java_self(void)
 }
 
 static smx_context_t
-smx_ctx_java_factory_create_context(xbt_main_func_t code, int argc,
-                                    char **argv,
+smx_ctx_java_factory_create_context(xbt_main_func_t code,
+                                    int argc, char **argv,
                                     void_pfn_smxprocess_t cleanup_func,
-                                    void* data)
+                                    smx_process_t process)
 {
   static int thread_amount=0;
   smx_ctx_java_t context = xbt_new0(s_smx_ctx_java_t, 1);
@@ -86,7 +86,7 @@ smx_ctx_java_factory_create_context(xbt_main_func_t code, int argc,
        context->thread = NULL;
     xbt_os_thread_set_extra_data(context);
   }
-  context->super.data = data;
+  context->super.process = process;
   
   return (smx_context_t) context;
 }
index 3135415..848b8d7 100644 (file)
@@ -25,7 +25,7 @@ void smx_ctx_base_factory_init(smx_context_factory_t *factory)
   (*factory)->suspend = NULL;
   (*factory)->runall = NULL;
   (*factory)->self = smx_ctx_base_self;
-  (*factory)->get_data = smx_ctx_base_get_data;
+  (*factory)->get_process = smx_ctx_base_get_process;
 
   (*factory)->name = "base context factory";
 }
@@ -38,11 +38,10 @@ int smx_ctx_base_factory_finalize(smx_context_factory_t * factory)
 }
 
 smx_context_t
-smx_ctx_base_factory_create_context_sized(size_t size,
-                                          xbt_main_func_t code, int argc,
-                                          char **argv,
+smx_ctx_base_factory_create_context_sized(size_t size, xbt_main_func_t code,
+                                          int argc, char **argv,
                                           void_pfn_smxprocess_t cleanup_func,
-                                          void *data)
+                                          smx_process_t process)
 {
   smx_context_t context = xbt_malloc0(size);
 
@@ -61,7 +60,7 @@ smx_ctx_base_factory_create_context_sized(size_t size,
   } else {
     SIMIX_context_set_current(context);
   }
-  context->data = data;
+  context->process = process;
 
   return context;
 }
@@ -87,9 +86,9 @@ void smx_ctx_base_free(smx_context_t context)
 void smx_ctx_base_stop(smx_context_t context)
 {
   if (context->cleanup_func)
-    context->cleanup_func(context->data);
+    context->cleanup_func(context->process);
   context->iwannadie = 0;
-  simcall_process_cleanup(context->data);
+  simcall_process_cleanup(context->process);
   context->iwannadie = 1;
 }
 
@@ -98,7 +97,7 @@ smx_context_t smx_ctx_base_self(void)
   return SIMIX_context_get_current();
 }
 
-void *smx_ctx_base_get_data(smx_context_t context)
+smx_process_t smx_ctx_base_get_process(smx_context_t context)
 {
-  return context->data;
+  return context->process;
 }
index 7bf2b87..d475f6b 100644 (file)
@@ -210,7 +210,7 @@ static char new_sr = 0;
 static void smx_ctx_raw_wrapper(smx_ctx_raw_t context);
 static int smx_ctx_raw_factory_finalize(smx_context_factory_t *factory);
 static smx_context_t smx_ctx_raw_create_context(xbt_main_func_t code, int argc,
-    char **argv, void_pfn_smxprocess_t cleanup_func, void *data);
+    char **argv, void_pfn_smxprocess_t cleanup_func, smx_process_t process);
 static void smx_ctx_raw_free(smx_context_t context);
 static void smx_ctx_raw_wrapper(smx_ctx_raw_t context);
 static void smx_ctx_raw_stop(smx_context_t context);
@@ -296,12 +296,12 @@ static int smx_ctx_raw_factory_finalize(smx_context_factory_t *factory)
  * \param argv arguments to pass to the main function
  * \param cleanup_func a function to call to free the user data when the
  * context finished
- * \param data user data
+ * \param process SIMIX process
  */
 static smx_context_t
 smx_ctx_raw_create_context(xbt_main_func_t code, int argc, char **argv,
-    void_pfn_smxprocess_t cleanup_func,
-    void *data)
+                           void_pfn_smxprocess_t cleanup_func,
+                           smx_process_t process)
 {
 
   smx_ctx_raw_t context =
@@ -311,7 +311,7 @@ smx_ctx_raw_create_context(xbt_main_func_t code, int argc, char **argv,
           argc,
           argv,
           cleanup_func,
-          data);
+          process);
 
   /* if the user provided a function for the process then use it,
      otherwise it is the context for maestro */
@@ -328,7 +328,7 @@ smx_ctx_raw_create_context(xbt_main_func_t code, int argc, char **argv,
 #endif                          /* HAVE_VALGRIND_VALGRIND_H */
 
      } else {
-       if(data != NULL && raw_maestro_context==NULL)
+       if(process != NULL && raw_maestro_context==NULL)
          raw_maestro_context = context;
 
        if(MC_is_active())
index f97b92b..b1906cc 100644 (file)
@@ -51,11 +51,11 @@ smx_ctx_sysv_create_context_sized(size_t structure_size,
                                   xbt_main_func_t code, int argc,
                                   char **argv,
                                   void_pfn_smxprocess_t cleanup_func,
-                                  void *data);
+                                  smx_process_t process);
 static void smx_ctx_sysv_free(smx_context_t context);
 static smx_context_t
 smx_ctx_sysv_create_context(xbt_main_func_t code, int argc, char **argv,
-    void_pfn_smxprocess_t cleanup_func, void* data);
+    void_pfn_smxprocess_t cleanup_func, smx_process_t process);
 
 static void smx_ctx_sysv_wrapper(int count, ...);
 
@@ -120,7 +120,7 @@ static smx_context_t
 smx_ctx_sysv_create_context_sized(size_t size, xbt_main_func_t code,
                                   int argc, char **argv,
                                   void_pfn_smxprocess_t cleanup_func,
-                                  void *data)
+                                  smx_process_t process)
 {
   int ctx_addr[CTX_ADDR_LEN];
   smx_ctx_sysv_t context =
@@ -129,7 +129,7 @@ smx_ctx_sysv_create_context_sized(size_t size, xbt_main_func_t code,
                                                                  argc,
                                                                  argv,
                                                                  cleanup_func,
-                                                                 data);
+                                                                 process);
 
   /* if the user provided a function for the process then use it,
      otherwise it is the context for maestro */
@@ -166,25 +166,27 @@ smx_ctx_sysv_create_context_sized(size_t size, xbt_main_func_t code,
               sizeof(smx_ctx_sysv_t), sizeof(int), CTX_ADDR_LEN);
     }
   } else {
-    if(data != NULL && sysv_maestro_context == NULL)
+    if (process != NULL && sysv_maestro_context == NULL)
       sysv_maestro_context = context;
   }
 
   if(MC_is_active() && code)
-    MC_new_stack_area(context, ((smx_process_t)((smx_context_t)context)->data)->name, &(context->uc), size);
+    MC_new_stack_area(context, ((smx_context_t)context)->process->name,
+                      &(context->uc), size);
 
   return (smx_context_t) context;
 }
 
 static smx_context_t
 smx_ctx_sysv_create_context(xbt_main_func_t code, int argc, char **argv,
-    void_pfn_smxprocess_t cleanup_func,
-    void *data)
+                            void_pfn_smxprocess_t cleanup_func,
+                            smx_process_t process)
 {
 
-  return smx_ctx_sysv_create_context_sized(sizeof(s_smx_ctx_sysv_t) + smx_context_stack_size,
+  return smx_ctx_sysv_create_context_sized(sizeof(s_smx_ctx_sysv_t) +
+                                           smx_context_stack_size,
                                            code, argc, argv, cleanup_func,
-                                           data);
+                                           process);
 
 }
 
index 7e7d933..ea06db0 100644 (file)
@@ -25,10 +25,10 @@ typedef struct s_smx_ctx_thread {
 static xbt_os_sem_t smx_ctx_thread_sem;
 
 static smx_context_t
-smx_ctx_thread_factory_create_context(xbt_main_func_t code, int argc,
-                                      char **argv,
+smx_ctx_thread_factory_create_context(xbt_main_func_t code,
+                                      int argc, char **argv,
                                       void_pfn_smxprocess_t cleanup_func,
-                                      void *data);
+                                      smx_process_t process);
 
 static void smx_ctx_thread_free(smx_context_t context);
 static void smx_ctx_thread_stop(smx_context_t context);
@@ -80,12 +80,12 @@ static smx_context_t
 smx_ctx_thread_factory_create_context(xbt_main_func_t code, int argc,
                                       char **argv,
                                       void_pfn_smxprocess_t cleanup_func,
-                                      void *data)
+                                      smx_process_t process)
 {
   smx_ctx_thread_t context = (smx_ctx_thread_t)
       smx_ctx_base_factory_create_context_sized(sizeof(s_smx_ctx_thread_t),
                                                 code, argc, argv,
-                                                cleanup_func, data);
+                                                cleanup_func, process);
 
   /* If the user provided a function for the process then use it
      otherwise is the context for maestro */
index 4b1b6bc..8462493 100644 (file)
@@ -320,13 +320,13 @@ static XBT_INLINE smx_context_t SIMIX_context_self(void)
 }
 
 /**
- \brief returns the data associated to a context
+ \brief returns the SIMIX process associated to a context
  \param context The context
- \return The data
+ \return The SIMIX process
  */
-static XBT_INLINE void* SIMIX_context_get_data(smx_context_t context)
+static XBT_INLINE smx_process_t SIMIX_context_get_process(smx_context_t context)
 {
-  return simix_global->context_factory->get_data(context);
+  return simix_global->context_factory->get_process(context);
 }
 
 XBT_PUBLIC(int) SIMIX_process_get_maxpid(void);
index 737ea00..74a4d26 100644 (file)
@@ -26,7 +26,7 @@ XBT_INLINE smx_process_t SIMIX_process_self(void)
 {
   smx_context_t self_context = SIMIX_context_self();
 
-  return self_context ? SIMIX_context_get_data(self_context) : NULL;
+  return self_context ? SIMIX_context_get_process(self_context) : NULL;
 }
 
 /**