Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
kill the portable header
[simgrid.git] / src / xbt / dict.c
index 5d220dc..28c1165 100644 (file)
@@ -98,7 +98,7 @@ void xbt_dict_free(xbt_dict_t * dict)
 /**
  * Returns the amount of elements in the dict
  */
-XBT_INLINE unsigned int xbt_dict_size(xbt_dict_t dict)
+inline unsigned int xbt_dict_size(xbt_dict_t dict)
 {
   return (dict ? (unsigned int) dict->count : (unsigned int) 0);
 }
@@ -163,7 +163,7 @@ static void xbt_dict_rehash(xbt_dict_t dict)
  * Set the \a data in the structure under the \a key, which can be any kind
  * of data, as long as its length is provided in \a key_len.
  */
-XBT_INLINE void xbt_dict_set_ext(xbt_dict_t dict,
+inline void xbt_dict_set_ext(xbt_dict_t dict,
                                  const char *key, int key_len,
                                  void *data, void_f_pvoid_t free_ctn)
 {
@@ -218,7 +218,7 @@ XBT_INLINE void xbt_dict_set_ext(xbt_dict_t dict,
  * set the \a data in the structure under the \a key, which is a
  * null terminated string.
  */
-XBT_INLINE void xbt_dict_set(xbt_dict_t dict,
+inline void xbt_dict_set(xbt_dict_t dict,
                              const char *key, void *data,
                              void_f_pvoid_t free_ctn)
 {
@@ -236,7 +236,7 @@ XBT_INLINE void xbt_dict_set(xbt_dict_t dict,
  *
  * Search the given \a key. Throws not_found_error when not found.
  */
-XBT_INLINE void *xbt_dict_get_ext(xbt_dict_t dict, const char *key, int key_len)
+inline void *xbt_dict_get_ext(xbt_dict_t dict, const char *key, int key_len)
 {
   unsigned int hash_code = xbt_str_hash_ext(key, key_len);
   xbt_dictelm_t current = dict->table[hash_code & dict->table_size];
@@ -307,7 +307,7 @@ char *xbt_dict_get_elm_key(xbt_dictelm_t elm)
  * Check xbt_dict_get_or_null() for a version returning NULL without exception when
  * not found.
  */
-XBT_INLINE void *xbt_dict_get(xbt_dict_t dict, const char *key)
+inline void *xbt_dict_get(xbt_dict_t dict, const char *key)
 {
   return xbt_dict_get_elm(dict, key)->content;
 }
@@ -322,7 +322,7 @@ XBT_INLINE void *xbt_dict_get(xbt_dict_t dict, const char *key)
  * Check xbt_dict_get_or_null() for a version returning NULL without exception when
  * not found.
  */
-XBT_INLINE xbt_dictelm_t xbt_dict_get_elm(xbt_dict_t dict, const char *key)
+inline xbt_dictelm_t xbt_dict_get_elm(xbt_dict_t dict, const char *key)
 {
   xbt_dictelm_t current = xbt_dict_get_elm_or_null(dict, key);
 
@@ -335,7 +335,7 @@ XBT_INLINE xbt_dictelm_t xbt_dict_get_elm(xbt_dict_t dict, const char *key)
 /**
  * \brief like xbt_dict_get(), but returning NULL when not found
  */
-XBT_INLINE void *xbt_dict_get_or_null(xbt_dict_t dict, const char *key)
+inline void *xbt_dict_get_or_null(xbt_dict_t dict, const char *key)
 {
   xbt_dictelm_t current = xbt_dict_get_elm_or_null(dict, key);
 
@@ -347,7 +347,7 @@ XBT_INLINE void *xbt_dict_get_or_null(xbt_dict_t dict, const char *key)
 /**
  * \brief like xbt_dict_get_elm(), but returning NULL when not found
  */
-XBT_INLINE xbt_dictelm_t xbt_dict_get_elm_or_null(xbt_dict_t dict, const char *key)
+inline xbt_dictelm_t xbt_dict_get_elm_or_null(xbt_dict_t dict, const char *key)
 {
   unsigned int hash_code = xbt_str_hash(key);
   xbt_dictelm_t current = dict->table[hash_code & dict->table_size];
@@ -368,7 +368,7 @@ XBT_INLINE xbt_dictelm_t xbt_dict_get_elm_or_null(xbt_dict_t dict, const char *k
  *
  * Remove the entry associated with the given \a key (throws not_found)
  */
-XBT_INLINE void xbt_dict_remove_ext(xbt_dict_t dict, const char *key, int key_len)
+inline void xbt_dict_remove_ext(xbt_dict_t dict, const char *key, int key_len)
 {
   unsigned int hash_code = xbt_str_hash_ext(key, key_len);
   xbt_dictelm_t previous = NULL;
@@ -407,48 +407,11 @@ XBT_INLINE void xbt_dict_remove_ext(xbt_dict_t dict, const char *key, int key_le
  *
  * Remove the entry associated with the given \a key
  */
-XBT_INLINE void xbt_dict_remove(xbt_dict_t dict, const char *key)
+inline void xbt_dict_remove(xbt_dict_t dict, const char *key)
 {
   xbt_dict_remove_ext(dict, key, strlen(key));
 }
 
-#ifdef XBT_USE_DEPRECATED
-/**
- * \brief Add data to the dict (arbitrary key)
- * \param dict the container
- * \param key the key to set the new data
- * \param data the data to add in the dict
- *
- * Set the \a data in the structure under the \a key.
- * Both \a data and \a key are considered as uintptr_t.
- */
-XBT_INLINE void xbt_dicti_set(xbt_dict_t dict,
-                              uintptr_t key, uintptr_t data)
-{
-  xbt_dict_set_ext(dict, (void *)&key, sizeof key, (void*)data, NULL);
-}
-
-/**
- * \brief Retrieve data from the dict (key considered as a uintptr_t)
- *
- * \param dict the dealer of data
- * \param key the key to find data
- * \return the data that we are looking for (or 0 if not found)
- *
- * Mixing uintptr_t keys with regular keys in the same dict is discouraged
- */
-XBT_INLINE uintptr_t xbt_dicti_get(xbt_dict_t dict, uintptr_t key)
-{
-  return (uintptr_t)xbt_dict_get_or_null_ext(dict, (void *)&key, sizeof key);
-}
-
-/** Remove a uintptr_t key from the dict */
-XBT_INLINE void xbt_dicti_remove(xbt_dict_t dict, uintptr_t key)
-{
-  xbt_dict_remove_ext(dict, (void *)&key, sizeof key);
-}
-#endif
-
 /** @brief Remove all data from the dict */
 void xbt_dict_reset(xbt_dict_t dict)
 {
@@ -474,7 +437,7 @@ void xbt_dict_reset(xbt_dict_t dict)
  * \brief Return the number of elements in the dict.
  * \param dict a dictionary
  */
-XBT_INLINE int xbt_dict_length(xbt_dict_t dict)
+inline int xbt_dict_length(xbt_dict_t dict)
 {
   return dict->count;
 }
@@ -488,7 +451,7 @@ void xbt_dict_dump_output_string(void *s)
 /**
  * \brief test if the dict is empty or not
  */
-XBT_INLINE int xbt_dict_is_empty(xbt_dict_t dict)
+inline int xbt_dict_is_empty(xbt_dict_t dict)
 {
   return !dict || (xbt_dict_length(dict) == 0);
 }
@@ -640,9 +603,8 @@ void xbt_dict_postexit(void)
 #ifdef SIMGRID_TEST
 #include "xbt.h"
 #include "xbt/ex.h"
-#include "src/portable.h"
+#include "src/internal_config.h"
 
-#define PRINTF_STR(a) (a)?:"(null)"
 
 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(xbt_dict);
 
@@ -653,8 +615,7 @@ static void debuged_add_ext(xbt_dict_t head, const char *key,
 {
   char *data = xbt_strdup(data_to_fill);
 
-  xbt_test_log("Add %s under %s", PRINTF_STR(data_to_fill),
-                PRINTF_STR(key));
+  xbt_test_log("Add %s under %s", data_to_fill, key);
 
   xbt_dict_set(head, key, data, free_f);
   if (XBT_LOG_ISENABLED(xbt_dict, xbt_log_priority_debug)) {
@@ -717,7 +678,7 @@ static void search(xbt_dict_t head, const char *key)
 static void debuged_remove(xbt_dict_t head, const char *key)
 {
 
-  xbt_test_add("Remove '%s'", PRINTF_STR(key));
+  xbt_test_add("Remove '%s'", key);
   xbt_dict_remove(head, key);
   /*  xbt_dict_dump(head,(void (*)(void*))&printf); */
 }
@@ -732,10 +693,9 @@ static void traverse(xbt_dict_t head)
 
   xbt_dict_foreach(head, cursor, key, data) {
     if (!key || !data || strcmp(key, data)) {
-      xbt_test_log("Seen #%d:  %s->%s", ++i, PRINTF_STR(key),
-                    PRINTF_STR(data));
+      xbt_test_log("Seen #%d:  %s->%s", ++i, key, data);
     } else {
-      xbt_test_log("Seen #%d:  %s", ++i, PRINTF_STR(key));
+      xbt_test_log("Seen #%d:  %s", ++i, key);
     }
     xbt_test_assert(!data || !strcmp(key, data),
                      "Key(%s) != value(%s). Aborting", key, data);
@@ -1012,9 +972,9 @@ XBT_TEST_UNIT("nulldata", test_dict_nulldata, "NULL data management")
 
     xbt_dict_foreach(head, cursor, key, data) {
       if (!key || !data || strcmp(key, data)) {
-        xbt_test_log("Seen:  %s->%s", PRINTF_STR(key), PRINTF_STR(data));
+        xbt_test_log("Seen:  %s->%s", key, data);
       } else {
-        xbt_test_log("Seen:  %s", PRINTF_STR(key));
+        xbt_test_log("Seen:  %s", key);
       }
 
       if (!strcmp(key, "null"))