Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Use a cleaner function type for get_link_latency functions.
[simgrid.git] / src / simix / smx_host.c
index 35aceeb..fd71067 100644 (file)
@@ -1,7 +1,5 @@
-/*     $Id$     */
-
-/* Copyright (c) 2007 Arnaud Legrand, Bruno Donassolo.
-   All rights reserved.                                          */
+/* Copyright (c) 2007, 2008, 2009, 2010. 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. */
@@ -25,10 +23,12 @@ smx_host_t __SIMIX_host_create(const char *name,
   smx_host->name = xbt_strdup(name);
   smx_host->data = data;
   smx_host->host = workstation;
-  smx_host->process_list = xbt_swag_new(xbt_swag_offset(proc, host_proc_hookup));
+  smx_host->process_list =
+      xbt_swag_new(xbt_swag_offset(proc, host_proc_hookup));
 
   /* Update global variables */
-  xbt_dict_set(simix_global->host, smx_host->name, smx_host, &__SIMIX_host_destroy);
+  xbt_dict_set(simix_global->host, smx_host->name, smx_host,
+               &__SIMIX_host_destroy);
 
   return smx_host;
 }
@@ -41,7 +41,7 @@ smx_host_t __SIMIX_host_create(const char *name,
  *     \param data User data
  *
  */
-void SIMIX_host_set_data(smx_host_t host, void *data)
+XBT_INLINE void SIMIX_host_set_data(smx_host_t host, void *data)
 {
   xbt_assert0((host != NULL), "Invalid parameters");
   xbt_assert0((host->data == NULL), "Data already set");
@@ -58,7 +58,7 @@ void SIMIX_host_set_data(smx_host_t host, void *data)
  * This functions checks whether \a host is a valid pointer or not and return the user data associated to \a host if it is possible.
  * \param host SIMIX host
  */
-void *SIMIX_host_get_data(smx_host_t host)
+XBT_INLINE void *SIMIX_host_get_data(smx_host_t host)
 {
   xbt_assert0((host != NULL), "Invalid parameters");
 
@@ -72,7 +72,7 @@ void *SIMIX_host_get_data(smx_host_t host)
  * This functions checks whether \a host is a valid pointer or not and return its name.
  * \param host SIMIX host
  */
-const char *SIMIX_host_get_name(smx_host_t host)
+XBT_INLINE const char *SIMIX_host_get_name(smx_host_t host)
 {
 
   xbt_assert0((host != NULL), "Invalid parameters");
@@ -87,7 +87,7 @@ const char *SIMIX_host_get_name(smx_host_t host)
  * Return the host,  more details in #SIMIX_process_get_host
  * \return SIMIX host
  */
-smx_host_t SIMIX_host_self(void)
+XBT_INLINE smx_host_t SIMIX_host_self(void)
 {
   return SIMIX_process_get_host(SIMIX_process_self());
 }
@@ -105,7 +105,8 @@ void __SIMIX_host_destroy(void *h)
 
   /* Clean Simulator data */
   if (xbt_swag_size(host->process_list) != 0) {
-    char *msg = bprintf("Shutting down host %s, but it's not empty:", host->name);
+    char *msg =
+        bprintf("Shutting down host %s, but it's not empty:", host->name);
     char *tmp;
     smx_process_t process = NULL;
 
@@ -131,7 +132,7 @@ void __SIMIX_host_destroy(void *h)
  *
  * \return Number of hosts
  */
-int SIMIX_host_get_number(void)
+XBT_INLINE int SIMIX_host_get_number(void)
 {
   return (xbt_dict_size(simix_global->host));
 }
@@ -151,7 +152,7 @@ smx_host_t *SIMIX_host_get_table(void)
   int i = 0;
 
   xbt_dict_foreach(simix_global->host, c, name, h)
-    res[i++] = h;
+      res[i++] = h;
 
   return res;
 }
@@ -161,7 +162,7 @@ smx_host_t *SIMIX_host_get_table(void)
  *
  * \return List of all hosts (as a #xbt_dict_t)
  */
-xbt_dict_t SIMIX_host_get_dict(void)
+XBT_INLINE xbt_dict_t SIMIX_host_get_dict(void)
 {
   return simix_global->host;
 }
@@ -173,7 +174,7 @@ xbt_dict_t SIMIX_host_get_dict(void)
  * \param host SIMIX host
  * \return Speed
  */
-double SIMIX_host_get_speed(smx_host_t host)
+XBT_INLINE double SIMIX_host_get_speed(smx_host_t host)
 {
   xbt_assert0((host != NULL), "Invalid parameters");
 
@@ -187,7 +188,7 @@ double SIMIX_host_get_speed(smx_host_t host)
  * Return the available speed (in Mflop/s).
  * \return Speed
  */
-double SIMIX_host_get_available_speed(smx_host_t host)
+XBT_INLINE double SIMIX_host_get_available_speed(smx_host_t host)
 {
   xbt_assert0((host != NULL), "Invalid parameters");
 
@@ -202,10 +203,11 @@ double SIMIX_host_get_available_speed(smx_host_t host)
  * \param name The name of an host.
  * \return The corresponding host
  */
-smx_host_t SIMIX_host_get_by_name(const char *name)
+XBT_INLINE smx_host_t SIMIX_host_get_by_name(const char *name)
 {
   xbt_assert0(((simix_global != NULL)
-               && (simix_global->host != NULL)), "Environment not set yet");
+               && (simix_global->host != NULL)),
+              "Environment not set yet");
 
   return xbt_dict_get_or_null(simix_global->host, name);
 }
@@ -216,11 +218,12 @@ smx_host_t SIMIX_host_get_by_name(const char *name)
  * \param host a host
  * \return the dynamic array consisting of property names
  */
-xbt_dict_t SIMIX_host_get_properties(smx_host_t host)
+XBT_INLINE xbt_dict_t SIMIX_host_get_properties(smx_host_t host)
 {
-  xbt_assert0((host != NULL), "Invalid parameters");
+  xbt_assert0((host != NULL), "Invalid parameters (simix host is NULL)");
 
-  return surf_workstation_model->extension.workstation.get_properties(host->host);
+  return surf_workstation_model->extension.
+      workstation.get_properties(host->host);
 }
 
 
@@ -231,9 +234,9 @@ xbt_dict_t SIMIX_host_get_properties(smx_host_t host)
  * \param host The SIMIX host
  * \return 1 if host is available or 0 if not.
  */
-int SIMIX_host_get_state(smx_host_t host)
+XBT_INLINE int SIMIX_host_get_state(smx_host_t host)
 {
-  xbt_assert0((host != NULL), "Invalid parameters");
+  xbt_assert0((host != NULL), "Invalid parameters (simix host is NULL)");
 
   return (surf_workstation_model->extension.workstation.
           get_state(host->host));