Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
cleaning step: uniform naming (stream to fd) + some cuts at 80
authorsuter <frederic.suter@cc.in2p3.fr>
Tue, 11 Jun 2013 08:49:21 +0000 (10:49 +0200)
committersuter <frederic.suter@cc.in2p3.fr>
Tue, 11 Jun 2013 09:05:09 +0000 (11:05 +0200)
characters

include/msg/msg.h
include/simgrid/simix.h
src/bindings/java/jmsg_file.c
src/include/surf/surf.h
src/msg/msg_io.c
src/simix/smx_io.c
src/simix/smx_io_private.h
src/simix/smx_smurf_private.h
src/simix/smx_user.c
src/surf/storage.c
src/surf/workstation.c

index 3a342b7..df345d2 100644 (file)
@@ -71,8 +71,10 @@ XBT_PUBLIC(unsigned long int) MSG_get_sent_msg(void);
 
 
 /************************** File handling ***********************************/
-XBT_PUBLIC(size_t) MSG_file_read(void* ptr, size_t size, size_t nmemb, msg_file_t stream);
-XBT_PUBLIC(size_t) MSG_file_write(const void* ptr, size_t size, size_t nmemb, msg_file_t stream);
+XBT_PUBLIC(size_t) MSG_file_read(void* ptr, size_t size, size_t nmemb,
+                                 msg_file_t fd);
+XBT_PUBLIC(size_t) MSG_file_write(const void* ptr, size_t size, size_t nmemb,
+                                  msg_file_t fd);
 XBT_PUBLIC(msg_file_t) MSG_file_open(const char* mount, const char* path);
 XBT_PUBLIC(int) MSG_file_close(msg_file_t fd);
 XBT_PUBLIC(size_t) MSG_file_get_size(msg_file_t fd);
index 434aef5..d6252f0 100644 (file)
@@ -461,9 +461,9 @@ XBT_PUBLIC(void) simcall_sem_acquire_timeout(smx_sem_t sem,
 XBT_PUBLIC(int) simcall_sem_get_capacity(smx_sem_t sem);
 
 XBT_PUBLIC(double) simcall_file_read(void* ptr, size_t size, size_t nmemb,
-                                     smx_file_t stream);
+                                     smx_file_t fd);
 XBT_PUBLIC(size_t) simcall_file_write(const void* ptr, size_t size,
-                                      size_t nmemb, smx_file_t stream);
+                                      size_t nmemb, smx_file_t fd);
 XBT_PUBLIC(smx_file_t) simcall_file_open(const char* storage, const char* path);
 XBT_PUBLIC(int) simcall_file_close(smx_file_t fd);
 XBT_PUBLIC(int) simcall_file_unlink(smx_file_t fd);
index bf16d30..63f4992 100644 (file)
@@ -7,8 +7,8 @@
 #include "jmsg_file.h"
 #include "jxbt_utilities.h"
 
-void jfile_bind(JNIEnv *env, jobject jfile, msg_file_t stream) {
-  (*env)->SetLongField(env, jfile, jfile_field_bind, (intptr_t)stream);
+void jfile_bind(JNIEnv *env, jobject jfile, msg_file_t fd) {
+  (*env)->SetLongField(env, jfile, jfile_field_bind, (intptr_t)fd);
 }
 
 msg_file_t jfile_get_native(JNIEnv *env, jobject jfile) {
index cd77c27..f72453a 100644 (file)
@@ -227,10 +227,12 @@ typedef struct surf_network_model_extension_public {
 typedef struct surf_storage_model_extension_public {
   surf_action_t(*open) (void *storage, const char* mount, const char* path);
   surf_action_t(*close) (void *storage, surf_file_t fd);
-  surf_action_t(*read) (void *storage, void* ptr, double size, size_t nmemb, surf_file_t stream);
-  surf_action_t(*write) (void *storage, const void* ptr, size_t size, size_t nmemb, surf_file_t stream);
-  surf_action_t(*stat) (void *storage, surf_file_t stream);
-  surf_action_t(*unlink) (void *storage, surf_file_t stream);
+  surf_action_t(*read) (void *storage, void* ptr, double size, size_t nmemb,
+                        surf_file_t fd);
+  surf_action_t(*write) (void *storage, const void* ptr, size_t size,
+                         size_t nmemb, surf_file_t fd);
+  surf_action_t(*stat) (void *storage, surf_file_t fd);
+  surf_action_t(*unlink) (void *storage, surf_file_t fd);
   surf_action_t(*ls) (void *storage, const char *path);
   size_t (*get_size) (void *storage, surf_file_t fd);
 } s_surf_model_extension_storage_t;
@@ -260,12 +262,15 @@ typedef struct surf_workstation_model_extension_public {
                                           double rate);
   double (*get_link_bandwidth) (const void *link);                                         /**< Return the current bandwidth of a network link */
   double (*get_link_latency) (const void *link);                                           /**< Return the current latency of a network link */
-  surf_action_t(*open) (void *workstation, const char* storage, const char* path);
+  surf_action_t(*open) (void *workstation, const char* storage,
+                        const char* path);
   surf_action_t(*close) (void *workstation, surf_file_t fd);
-  surf_action_t(*read) (void *workstation, void* ptr, size_t size, size_t nmemb, surf_file_t stream);
-  surf_action_t(*write) (void *workstation, const void* ptr, size_t size, size_t nmemb, surf_file_t stream);
-  surf_action_t(*stat) (void *workstation, surf_file_t stream);
-  surf_action_t(*unlink) (void *workstation, surf_file_t stream);
+  surf_action_t(*read) (void *workstation, void* ptr, size_t size, size_t nmemb,
+                        surf_file_t fd);
+  surf_action_t(*write) (void *workstation, const void* ptr, size_t size,
+                         size_t nmemb, surf_file_t fd);
+  surf_action_t(*stat) (void *workstation, surf_file_t fd);
+  surf_action_t(*unlink) (void *workstation, surf_file_t fd);
   surf_action_t(*ls) (void *workstation, const char* mount, const char *path);
   size_t (*get_size) (void *workstation, surf_file_t fd);
 
index 5049e0f..cbbf2dd 100644 (file)
@@ -25,12 +25,12 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(msg_io, msg,
  * \param ptr buffer to where the data is copied
  * \param size of each element
  * \param nmemb is the number of elements of data to read
- * \param stream to read
+ * \param fd is a the file descriptor
  * \return the number of items successfully read
  */
-size_t MSG_file_read(void* ptr, size_t size, size_t nmemb,  msg_file_t stream)
+size_t MSG_file_read(void* ptr, size_t size, size_t nmemb, msg_file_t fd)
 {
-  return simcall_file_read(ptr, size, nmemb, stream->simdata->smx_file);
+  return simcall_file_read(ptr, size, nmemb, fd->simdata->smx_file);
 }
 
 /** \ingroup msg_file_management
@@ -39,12 +39,12 @@ size_t MSG_file_read(void* ptr, size_t size, size_t nmemb,  msg_file_t stream)
  * \param ptr buffer from where the data is copied
  * \param size of each element
  * \param nmemb is the number of elements of data to write
- * \param stream to write
+ * \param fd is a the file descriptor
  * \return the number of items successfully write
  */
-size_t MSG_file_write(const void* ptr, size_t size, size_t nmemb, msg_file_t stream)
+size_t MSG_file_write(const void* ptr, size_t size, size_t nmemb, msg_file_t fd)
 {
-  return simcall_file_write(ptr, size, nmemb, stream->simdata->smx_file);
+  return simcall_file_write(ptr, size, nmemb, fd->simdata->smx_file);
 }
 
 /** \ingroup msg_file_management
index 5106fcf..9822703 100644 (file)
@@ -17,14 +17,15 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(simix_io, simix,
 
 //SIMIX FILE READ
 void SIMIX_pre_file_read(smx_simcall_t simcall, void *ptr, size_t size,
-                        size_t nmemb, smx_file_t stream)
+                        size_t nmemb, smx_file_t fd)
 {
-  smx_action_t action = SIMIX_file_read(simcall->issuer, ptr, size, nmemb, stream);
+  smx_action_t action = SIMIX_file_read(simcall->issuer, ptr, size, nmemb, fd);
   xbt_fifo_push(action->simcalls, simcall);
   simcall->issuer->waiting_action = action;
 }
 
-smx_action_t SIMIX_file_read(smx_process_t process, void* ptr, size_t size, size_t nmemb, smx_file_t stream)
+smx_action_t SIMIX_file_read(smx_process_t process, void* ptr, size_t size,
+                             size_t nmemb, smx_file_t fd)
 {
   smx_action_t action;
   smx_host_t host = process->smx_host;
@@ -44,7 +45,9 @@ smx_action_t SIMIX_file_read(smx_process_t process, void* ptr, size_t size, size
 #endif
 
   action->io.host = host;
-  action->io.surf_io = surf_workstation_model->extension.workstation.read(host, ptr, size, nmemb, stream->surf_file);
+  action->io.surf_io =
+      surf_workstation_model->extension.workstation.read(host, ptr, size, nmemb,
+                                                         fd->surf_file);
 
   surf_workstation_model->action_data_set(action->io.surf_io, action);
   XBT_DEBUG("Create io action %p", action);
@@ -54,14 +57,15 @@ smx_action_t SIMIX_file_read(smx_process_t process, void* ptr, size_t size, size
 
 //SIMIX FILE WRITE
 void SIMIX_pre_file_write(smx_simcall_t simcall, const void *ptr, size_t size,
-                         size_t nmemb, smx_file_t stream)
+                         size_t nmemb, smx_file_t fd)
 {
-  smx_action_t action = SIMIX_file_write(simcall->issuer, ptr, size, nmemb, stream);
+  smx_action_t action = SIMIX_file_write(simcall->issuer, ptr, size, nmemb, fd);
   xbt_fifo_push(action->simcalls, simcall);
   simcall->issuer->waiting_action = action;
 }
 
-smx_action_t SIMIX_file_write(smx_process_t process, const void* ptr, size_t size, size_t nmemb, smx_file_t stream)
+smx_action_t SIMIX_file_write(smx_process_t process, const void* ptr,
+                              size_t size, size_t nmemb, smx_file_t fd)
 {
   smx_action_t action;
   smx_host_t host = process->smx_host;
@@ -81,7 +85,9 @@ smx_action_t SIMIX_file_write(smx_process_t process, const void* ptr, size_t siz
 #endif
 
   action->io.host = host;
-  action->io.surf_io = surf_workstation_model->extension.workstation.write(host, ptr, size, nmemb, stream->surf_file);
+  action->io.surf_io =
+      surf_workstation_model->extension.workstation.write(host, ptr, size,
+                                                          nmemb, fd->surf_file);
 
   surf_workstation_model->action_data_set(action->io.surf_io, action);
   XBT_DEBUG("Create io action %p", action);
index 6bc9f9f..3a85d32 100644 (file)
@@ -11,9 +11,9 @@
 #include "smx_smurf_private.h"
 
 void SIMIX_pre_file_read(smx_simcall_t simcall, void *ptr, size_t size,
-                        size_t nmemb, smx_file_t stream);
+                        size_t nmemb, smx_file_t fd);
 void SIMIX_pre_file_write(smx_simcall_t simcall, const void *ptr, size_t size,
-                         size_t nmemb, smx_file_t strea);
+                         size_t nmemb, smx_file_t fd);
 void SIMIX_pre_file_open(smx_simcall_t simcall, const char* mount,
                         const char* path);
 void SIMIX_pre_file_close(smx_simcall_t simcall, smx_file_t fd);
@@ -23,9 +23,9 @@ void SIMIX_pre_file_ls(smx_simcall_t simcall,
 size_t SIMIX_pre_file_get_size(smx_simcall_t simcall, smx_file_t fd);
 
 smx_action_t SIMIX_file_read(smx_process_t process, void* ptr, size_t size,
-                             size_t nmemb, smx_file_t stream);
+                             size_t nmemb, smx_file_t fd);
 smx_action_t SIMIX_file_write(smx_process_t process, const void* ptr,
-                              size_t size, size_t nmemb, smx_file_t stream);
+                              size_t size, size_t nmemb, smx_file_t fd);
 smx_action_t SIMIX_file_open(smx_process_t process, const char* storage,
                              const char* path);
 smx_action_t SIMIX_file_close(smx_process_t process, smx_file_t fd);
index e901819..6a7e590 100644 (file)
@@ -339,8 +339,8 @@ ACTION(SIMCALL_SEM_WOULD_BLOCK, sem_would_block, WITH_ANSWER, TINT(result), TSPE
 ACTION(SIMCALL_SEM_ACQUIRE, sem_acquire, WITHOUT_ANSWER, TVOID(result), TSPEC(sem, smx_sem_t)) sep \
 ACTION(SIMCALL_SEM_ACQUIRE_TIMEOUT, sem_acquire_timeout, WITHOUT_ANSWER, TVOID(result), TSPEC(sem, smx_sem_t), TDOUBLE(timeout)) sep \
 ACTION(SIMCALL_SEM_GET_CAPACITY, sem_get_capacity, WITH_ANSWER, TINT(result), TSPEC(sem, smx_sem_t)) sep \
-ACTION(SIMCALL_FILE_READ, file_read, WITHOUT_ANSWER, TDOUBLE(result), TPTR(ptr), TSIZE(size), TSIZE(nmemb), TSPEC(stream, smx_file_t)) sep \
-ACTION(SIMCALL_FILE_WRITE, file_write, WITHOUT_ANSWER, TSIZE(result), TCPTR(ptr), TSIZE(size), TSIZE(nmemb), TSPEC(stream, smx_file_t)) sep \
+ACTION(SIMCALL_FILE_READ, file_read, WITHOUT_ANSWER, TDOUBLE(result), TPTR(ptr), TSIZE(size), TSIZE(nmemb), TSPEC(fd, smx_file_t)) sep \
+ACTION(SIMCALL_FILE_WRITE, file_write, WITHOUT_ANSWER, TSIZE(result), TCPTR(ptr), TSIZE(size), TSIZE(nmemb), TSPEC(fd, smx_file_t)) sep \
 ACTION(SIMCALL_FILE_OPEN, file_open, WITHOUT_ANSWER, TSPEC(result, smx_file_t), TSTRING(mount), TSTRING(path)) sep \
 ACTION(SIMCALL_FILE_CLOSE, file_close, WITHOUT_ANSWER, TINT(result), TSPEC(fd, smx_file_t)) sep \
 ACTION(SIMCALL_FILE_UNLINK, file_unlink, WITHOUT_ANSWER, TINT(result), TSPEC(fd, smx_file_t)) sep \
index 7cff177..d7580c3 100644 (file)
@@ -1091,18 +1091,19 @@ int simcall_sem_get_capacity(smx_sem_t sem)
  * \ingroup simix_file_management
  *
  */
-double simcall_file_read(void* ptr, size_t size, size_t nmemb, smx_file_t stream)
+double simcall_file_read(void* ptr, size_t size, size_t nmemb, smx_file_t fd)
 {
-  return simcall_BODY_file_read(ptr, size, nmemb, stream);
+  return simcall_BODY_file_read(ptr, size, nmemb, fd);
 }
 
 /**
  * \ingroup simix_file_management
  *
  */
-size_t simcall_file_write(const void* ptr, size_t size, size_t nmemb, smx_file_t stream)
+size_t simcall_file_write(const void* ptr, size_t size, size_t nmemb,
+                          smx_file_t fd)
 {
-  return simcall_BODY_file_write(ptr, size, nmemb, stream);
+  return simcall_BODY_file_write(ptr, size, nmemb, fd);
 }
 
 /**
index 8d18f31..1e8c2a4 100644 (file)
@@ -81,19 +81,19 @@ static surf_action_t storage_action_ls(void *storage, const char* path)
   return action;
 }
 
-static surf_action_t storage_action_unlink(void *storage, surf_file_t stream)
+static surf_action_t storage_action_unlink(void *storage, surf_file_t fd)
 {
   surf_action_t action = storage_action_execute(storage,0, UNLINK);
 
   // Add memory to storage
-  ((storage_t)storage)->used_size -= stream->size;
+  ((storage_t)storage)->used_size -= fd->size;
 
   // Remove the file from storage
   xbt_dict_t content_dict = ((storage_t)storage)->content;
-  xbt_dict_remove(content_dict,stream->name);
+  xbt_dict_remove(content_dict,fd->name);
 
-  free(stream->name);
-  xbt_free(stream);
+  free(fd->name);
+  xbt_free(fd);
 
   return action;
 }
@@ -139,21 +139,24 @@ static surf_action_t storage_action_close(void *storage, surf_file_t fd)
   return action;
 }
 
-static surf_action_t storage_action_read(void *storage, void* ptr, double size, size_t nmemb, surf_file_t stream)
+static surf_action_t storage_action_read(void *storage, void* ptr, double size,
+                                         size_t nmemb, surf_file_t fd)
 {
-  if(size > stream->size)
-    size = stream->size;
+  if(size > fd->size)
+    size = fd->size;
   surf_action_t action = storage_action_execute(storage,size,READ);
   return action;
 }
 
-static surf_action_t storage_action_write(void *storage, const void* ptr, size_t size, size_t nmemb, surf_file_t stream)
+static surf_action_t storage_action_write(void *storage, const void* ptr,
+                                          size_t size, size_t nmemb,
+                                          surf_file_t fd)
 {
-  char *filename = stream->name;
-  XBT_DEBUG("\tWrite file '%s' size '%zu/%zu'",filename,size,stream->size);
+  char *filename = fd->name;
+  XBT_DEBUG("\tWrite file '%s' size '%zu/%zu'",filename,size,fd->size);
 
   surf_action_t action = storage_action_execute(storage,size,WRITE);
-  action->file = stream;
+  action->file = fd;
 
   // If the storage is full
   if(((storage_t)storage)->used_size==((storage_t)storage)->size) {
index 7d7c93b..dd68a9f 100644 (file)
@@ -343,39 +343,34 @@ static surf_action_t ws_action_close(void *workstation, surf_file_t fd)
   return model->extension.storage.close(st, fd);
 }
 
-static surf_action_t ws_action_read(void *workstation, void* ptr, size_t size, size_t nmemb, surf_file_t stream)
+static surf_action_t ws_action_read(void *workstation, void* ptr, size_t size,
+                                    size_t nmemb, surf_file_t fd)
 {
-  storage_t st = find_storage_on_mount_list(workstation, stream->storage);
+  storage_t st = find_storage_on_mount_list(workstation, fd->storage);
   XBT_DEBUG("READ on disk '%s'",st->generic_resource.name);
   surf_model_t model = st->generic_resource.model;
-  return model->extension.storage.read(st, ptr, (double)size, nmemb, stream);
+  return model->extension.storage.read(st, ptr, (double)size, nmemb, fd);
 }
 
-static surf_action_t ws_action_write(void *workstation, const void* ptr, size_t size, size_t nmemb, surf_file_t stream)
+static surf_action_t ws_action_write(void *workstation, const void* ptr,
+                                     size_t size, size_t nmemb, surf_file_t fd)
 {
-  storage_t st = find_storage_on_mount_list(workstation, stream->storage);
+  storage_t st = find_storage_on_mount_list(workstation, fd->storage);
   XBT_DEBUG("WRITE on disk '%s'",st->generic_resource.name);
   surf_model_t model = st->generic_resource.model;
-  return model->extension.storage.write(st,  ptr, size, nmemb, stream);
+  return model->extension.storage.write(st,  ptr, size, nmemb, fd);
 }
 
-static surf_action_t ws_action_stat(void *workstation, surf_file_t stream)
+static surf_action_t ws_action_unlink(void *workstation, surf_file_t fd)
 {
-  storage_t st = find_storage_on_mount_list(workstation, stream->storage);
-  XBT_DEBUG("STAT on disk '%s'",st->generic_resource.name);
-  surf_model_t model = st->generic_resource.model;
-  return model->extension.storage.stat(st,  stream);
-}
-
-static surf_action_t ws_action_unlink(void *workstation, surf_file_t stream)
-{
-  storage_t st = find_storage_on_mount_list(workstation, stream->storage);
+  storage_t st = find_storage_on_mount_list(workstation, fd->storage);
   XBT_DEBUG("UNLINK on disk '%s'",st->generic_resource.name);
   surf_model_t model = st->generic_resource.model;
-  return model->extension.storage.unlink(st,  stream);
+  return model->extension.storage.unlink(st, fd);
 }
 
-static surf_action_t ws_action_ls(void *workstation, const char* mount, const char *path)
+static surf_action_t ws_action_ls(void *workstation, const char* mount,
+                                  const char *path)
 {
   XBT_DEBUG("LS on mount '%s' and file '%s'",mount, path);
   storage_t st = find_storage_on_mount_list(workstation, mount);
@@ -383,9 +378,9 @@ static surf_action_t ws_action_ls(void *workstation, const char* mount, const ch
   return model->extension.storage.ls(st, path);
 }
 
-static size_t ws_file_get_size(void *workstation, surf_file_t stream)
+static size_t ws_file_get_size(void *workstation, surf_file_t fd)
 {
-  return stream->size;
+  return fd->size;
 }
 
 static void surf_workstation_model_init_internal(void)