Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
document existing coding convention in C, and stick to it
authorMartin Quinson <martin.quinson@ens-rennes.fr>
Sun, 15 Sep 2019 08:31:18 +0000 (10:31 +0200)
committerMartin Quinson <martin.quinson@ens-rennes.fr>
Sun, 15 Sep 2019 17:59:16 +0000 (19:59 +0200)
ChangeLog
README.coding
examples/deprecated/simdag/scheduling/sd_scheduling.c
include/simgrid/actor.h
include/simgrid/host.h
src/msg/msg_legacy.cpp
src/s4u/s4u_Actor.cpp
src/s4u/s4u_Host.cpp

index f1e5a2a..c0f5b21 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -16,8 +16,8 @@ S4U:
    - on_simulation_end: after simulation, before cleanups
    - on_deadlock: as the name implies.
  - C bindings:
-   - sg_{host,actor}_{set,get}_data() now all exist.
-     Use them to attach user data to the object.
+   - sg_{actor,host,link}_{data,data_set}() now all exist.
+     Use them to attach user data to the object and retrieve it.
 
 MSG:
  - convert a new set of functions to the S4U C interface and move the old MSG
index 6b3d048..44414b9 100644 (file)
@@ -35,6 +35,8 @@ SimGrid4 will follow the these rules:
     - Example: src/kernel/activity/Activity.cpp
                include/simgrid/activity/Activity.hpp
   C
+  - Field getters are named sg_object_field() eg sg_link_name()
+    Field setters are named sg_object_field_set() eg sg_link_data_set()
   - variables and functions are in snake_case()
   - typedefs do not hide the pointers, ie * must be explicit
     char * sg_host_get_name(sg_host_t * host);
index be2963a..17972b6 100644 (file)
@@ -24,26 +24,26 @@ struct _HostAttribute {
 
 static double sg_host_get_available_at(sg_host_t host)
 {
-  HostAttribute attr = (HostAttribute)sg_host_get_data(host);
+  HostAttribute attr = (HostAttribute)sg_host_data(host);
   return attr->available_at;
 }
 
 static void sg_host_set_available_at(sg_host_t host, double time)
 {
-  HostAttribute attr = (HostAttribute)sg_host_get_data(host);
+  HostAttribute attr = (HostAttribute)sg_host_data(host);
   attr->available_at = time;
-  sg_host_set_data(host, attr);
+  sg_host_data_set(host, attr);
 }
 
 static SD_task_t sg_host_get_last_scheduled_task( sg_host_t host){
-  HostAttribute attr = (HostAttribute)sg_host_get_data(host);
+  HostAttribute attr = (HostAttribute)sg_host_data(host);
   return attr->last_scheduled_task;
 }
 
 static void sg_host_set_last_scheduled_task(sg_host_t host, SD_task_t task){
-  HostAttribute attr       = (HostAttribute)sg_host_get_data(host);
+  HostAttribute attr       = (HostAttribute)sg_host_data(host);
   attr->last_scheduled_task=task;
-  sg_host_set_data(host, attr);
+  sg_host_data_set(host, attr);
 }
 
 static xbt_dynar_t get_ready_tasks(xbt_dynar_t dax)
@@ -159,7 +159,7 @@ int main(int argc, char **argv)
   sg_host_t *hosts = sg_host_list();
 
   for (cursor = 0; cursor < total_nhosts; cursor++)
-    sg_host_set_data(hosts[cursor], xbt_new0(struct _HostAttribute, 1));
+    sg_host_data_set(hosts[cursor], xbt_new0(struct _HostAttribute, 1));
 
   /* load the DAX file */
   xbt_dynar_t dax = SD_daxload(argv[2]);
@@ -246,8 +246,8 @@ int main(int argc, char **argv)
   xbt_dynar_free_container(&dax);
 
   for (cursor = 0; cursor < total_nhosts; cursor++) {
-    free(sg_host_get_data(hosts[cursor]));
-    sg_host_set_data(hosts[cursor], NULL);
+    free(sg_host_data(hosts[cursor]));
+    sg_host_data_set(hosts[cursor], NULL);
   }
 
   xbt_free(hosts);
index ba67224..9b38ab5 100644 (file)
@@ -49,8 +49,8 @@ XBT_PUBLIC const char* sg_actor_self_get_name();
 XBT_PUBLIC void sg_actor_self_execute(double flops);
 XBT_PUBLIC void sg_actor_ref(sg_actor_t actor);
 XBT_PUBLIC void sg_actor_unref(sg_actor_t actor);
-XBT_PUBLIC void* sg_actor_get_data(sg_actor_t actor);
-XBT_PUBLIC void sg_actor_set_data(sg_actor_t actor, void* userdata);
+XBT_PUBLIC void* sg_actor_data(sg_actor_t actor);
+XBT_PUBLIC void sg_actor_data_set(sg_actor_t actor, void* userdata);
 
 SG_END_DECL()
 
index 30db249..fad40cd 100644 (file)
@@ -49,16 +49,16 @@ XBT_PUBLIC const char* sg_host_get_name(sg_host_t host);
  *
  * This functions returns the user data associated to @a host if any.
  */
-XBT_PUBLIC void* sg_host_get_data(sg_host_t host);
-XBT_ATTRIB_DEPRECATED_v327("Please use sg_host_get_data()") XBT_PUBLIC void* sg_host_user(sg_host_t host);
+XBT_PUBLIC void* sg_host_data(sg_host_t host);
+XBT_ATTRIB_DEPRECATED_v327("Please use sg_host_data()") XBT_PUBLIC void* sg_host_user(sg_host_t host);
 /** @brief Set the user data of a #sg_host_t.
  *
  * This functions attach @a data to @a host.
  */
-XBT_PUBLIC void sg_host_set_data(sg_host_t host, void* userdata);
-XBT_ATTRIB_DEPRECATED_v327("Please use sg_host_set_data()") XBT_PUBLIC
+XBT_PUBLIC void sg_host_data_set(sg_host_t host, void* userdata);
+XBT_ATTRIB_DEPRECATED_v327("Please use sg_host_data_set()") XBT_PUBLIC
     void sg_host_user_set(sg_host_t host, void* userdata);
-XBT_ATTRIB_DEPRECATED_v327("Please use sg_host_set_data(h, NULL)") XBT_PUBLIC void sg_host_user_destroy(sg_host_t host);
+XBT_ATTRIB_DEPRECATED_v327("Please use sg_host_data_set(h, NULL)") XBT_PUBLIC void sg_host_user_destroy(sg_host_t host);
 
 // ========= storage related functions ============
 /** @brief Return the list of mount point names on an host.
index 0456773..cd258f3 100644 (file)
@@ -282,11 +282,11 @@ const char* MSG_host_get_name(sg_host_t host)
 }
 void* MSG_host_get_data(sg_host_t host)
 {
-  return sg_host_get_data(host);
+  return sg_host_data(host);
 }
 void MSG_host_set_data(sg_host_t host, void* data)
 {
-  return sg_host_set_data(host, data);
+  return sg_host_data_set(host, data);
 }
 xbt_dict_t MSG_host_get_mounted_storage_list(sg_host_t host)
 {
index 64ce673..7187920 100644 (file)
@@ -742,12 +742,12 @@ void sg_actor_unref(sg_actor_t actor)
 }
 
 /** @brief Return the user data of a #sg_actor_t */
-void* sg_actor_get_data(sg_actor_t actor)
+void* sg_actor_data(sg_actor_t actor)
 {
   return actor->get_data();
 }
 /** @brief Set the user data of a #sg_actor_t */
-void sg_actor_set_data(sg_actor_t actor, void* userdata)
+void sg_actor_data_set(sg_actor_t actor, void* userdata)
 {
   actor->set_data(userdata);
 }
index 0453276..5e90311 100644 (file)
@@ -385,11 +385,11 @@ xbt_dynar_t sg_hosts_as_dynar()
 // ========= Layering madness ==============*
 
 // ========== User data Layer ==========
-void* sg_host_get_data(sg_host_t host)
+void* sg_host_data(sg_host_t host)
 {
   return host->get_data();
 }
-void sg_host_set_data(sg_host_t host, void* userdata)
+void sg_host_data_set(sg_host_t host, void* userdata)
 {
   host->set_data(userdata);
 }