2 * collectd - src/utils_cache.c
3 * Copyright (C) 2007-2010 Florian octo Forster
4 * Copyright (C) 2016 Sebastian tokkee Harl
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 * DEALINGS IN THE SOFTWARE.
25 * Florian octo Forster <octo at collectd.org>
26 * Sebastian tokkee Harl <sh at tokkee.org>
33 #include "utils_avltree.h"
34 #include "utils_cache.h"
35 #include "meta_data.h"
39 typedef struct cache_entry_s
41 char name[6 * DATA_MAX_NAME_LEN];
43 gauge_t *values_gauge;
45 /* Time contained in the package
46 * (for calculating rates) */
48 /* Time according to the local clock
49 * (for purging old entries) */
51 /* Interval in which the data is collected
52 * (for purging old entries) */
58 * +-----+-----+-----+-----+-----+-----+-----+-----+-----+----
59 * ! 0 ! 1 ! 2 ! 3 ! 4 ! 5 ! 6 ! 7 ! 8 ! ...
60 * +-----+-----+-----+-----+-----+-----+-----+-----+-----+----
61 * ! ds0 ! ds1 ! ds2 ! ds0 ! ds1 ! ds2 ! ds0 ! ds1 ! ds2 ! ...
62 * +-----+-----+-----+-----+-----+-----+-----+-----+-----+----
63 * ! t = 0 ! t = 1 ! t = 2 ! ...
64 * +-----------------+-----------------+-----------------+----
67 size_t history_index; /* points to the next position to write to. */
68 size_t history_length;
74 c_avl_iterator_t *iter;
80 static c_avl_tree_t *cache_tree = NULL;
81 static pthread_mutex_t cache_lock = PTHREAD_MUTEX_INITIALIZER;
83 static int cache_compare (const cache_entry_t *a, const cache_entry_t *b)
86 assert ((a != NULL) && (b != NULL));
88 return (strcmp (a->name, b->name));
89 } /* int cache_compare */
91 static cache_entry_t *cache_alloc (size_t values_num)
95 ce = calloc (1, sizeof (*ce));
98 ERROR ("utils_cache: cache_alloc: calloc failed.");
101 ce->values_num = values_num;
103 ce->values_gauge = calloc (values_num, sizeof (*ce->values_gauge));
104 ce->values_raw = calloc (values_num, sizeof (*ce->values_raw));
105 if ((ce->values_gauge == NULL) || (ce->values_raw == NULL))
107 sfree (ce->values_gauge);
108 sfree (ce->values_raw);
110 ERROR ("utils_cache: cache_alloc: calloc failed.");
115 ce->history_length = 0;
119 } /* cache_entry_t *cache_alloc */
121 static void cache_free (cache_entry_t *ce)
126 sfree (ce->values_gauge);
127 sfree (ce->values_raw);
129 if (ce->meta != NULL)
131 meta_data_destroy (ce->meta);
135 } /* void cache_free */
137 static void uc_check_range (const data_set_t *ds, cache_entry_t *ce)
139 for (size_t i = 0; i < ds->ds_num; i++)
141 if (isnan (ce->values_gauge[i]))
143 else if (ce->values_gauge[i] < ds->ds[i].min)
144 ce->values_gauge[i] = NAN;
145 else if (ce->values_gauge[i] > ds->ds[i].max)
146 ce->values_gauge[i] = NAN;
148 } /* void uc_check_range */
150 static int uc_insert (const data_set_t *ds, const value_list_t *vl,
156 /* `cache_lock' has been locked by `uc_update' */
158 key_copy = strdup (key);
159 if (key_copy == NULL)
161 ERROR ("uc_insert: strdup failed.");
165 ce = cache_alloc (ds->ds_num);
169 ERROR ("uc_insert: cache_alloc (%zu) failed.", ds->ds_num);
173 sstrncpy (ce->name, key, sizeof (ce->name));
175 for (size_t i = 0; i < ds->ds_num; i++)
177 switch (ds->ds[i].type)
179 case DS_TYPE_COUNTER:
180 ce->values_gauge[i] = NAN;
181 ce->values_raw[i].counter = vl->values[i].counter;
185 ce->values_gauge[i] = vl->values[i].gauge;
186 ce->values_raw[i].gauge = vl->values[i].gauge;
190 ce->values_gauge[i] = NAN;
191 ce->values_raw[i].derive = vl->values[i].derive;
194 case DS_TYPE_ABSOLUTE:
195 ce->values_gauge[i] = NAN;
196 if (vl->interval > 0)
197 ce->values_gauge[i] = ((double) vl->values[i].absolute)
198 / CDTIME_T_TO_DOUBLE (vl->interval);
199 ce->values_raw[i].absolute = vl->values[i].absolute;
203 /* This shouldn't happen. */
204 ERROR ("uc_insert: Don't know how to handle data source type %i.",
209 } /* switch (ds->ds[i].type) */
212 /* Prune invalid gauge data */
213 uc_check_range (ds, ce);
215 ce->last_time = vl->time;
216 ce->last_update = cdtime ();
217 ce->interval = vl->interval;
218 ce->state = STATE_OKAY;
220 if (c_avl_insert (cache_tree, key_copy, ce) != 0)
223 ERROR ("uc_insert: c_avl_insert failed.");
227 DEBUG ("uc_insert: Added %s to the cache.", key);
229 } /* int uc_insert */
233 if (cache_tree == NULL)
234 cache_tree = c_avl_create ((int (*) (const void *, const void *))
240 int uc_check_timeout (void)
246 cdtime_t *keys_time = NULL;
247 cdtime_t *keys_interval = NULL;
251 c_avl_iterator_t *iter;
255 pthread_mutex_lock (&cache_lock);
259 /* Build a list of entries to be flushed */
260 iter = c_avl_get_iterator (cache_tree);
261 while (c_avl_iterator_next (iter, (void *) &key, (void *) &ce) == 0)
266 /* If the entry is fresh enough, continue. */
267 if ((now - ce->last_update) < (ce->interval * timeout_g))
270 /* If entry has not been updated, add to `keys' array */
271 tmp = realloc ((void *) keys,
272 (keys_len + 1) * sizeof (char *));
275 ERROR ("uc_check_timeout: realloc failed.");
280 tmp_time = realloc (keys_time, (keys_len + 1) * sizeof (*keys_time));
281 if (tmp_time == NULL)
283 ERROR ("uc_check_timeout: realloc failed.");
286 keys_time = tmp_time;
288 tmp_time = realloc (keys_interval, (keys_len + 1) * sizeof (*keys_interval));
289 if (tmp_time == NULL)
291 ERROR ("uc_check_timeout: realloc failed.");
294 keys_interval = tmp_time;
296 keys[keys_len] = strdup (key);
297 if (keys[keys_len] == NULL)
299 ERROR ("uc_check_timeout: strdup failed.");
302 keys_time[keys_len] = ce->last_time;
303 keys_interval[keys_len] = ce->interval;
306 } /* while (c_avl_iterator_next) */
308 c_avl_iterator_destroy (iter);
309 pthread_mutex_unlock (&cache_lock);
313 /* realloc() may have been called for these. */
316 sfree (keys_interval);
320 /* Call the "missing" callback for each value. Do this before removing the
321 * value from the cache, so that callbacks can still access the data stored,
322 * including plugin specific meta data, rates, history, …. This must be done
323 * without holding the lock, otherwise we will run into a deadlock if a
324 * plugin calls the cache interface. */
325 for (int i = 0; i < keys_len; i++)
327 value_list_t vl = VALUE_LIST_INIT;
333 status = parse_identifier_vl (keys[i], &vl);
336 ERROR ("uc_check_timeout: parse_identifier_vl (\"%s\") failed.", keys[i]);
340 vl.time = keys_time[i];
341 vl.interval = keys_interval[i];
343 plugin_dispatch_missing (&vl);
344 } /* for (i = 0; i < keys_len; i++) */
346 /* Now actually remove all the values from the cache. We don't re-evaluate
347 * the timestamp again, so in theory it is possible we remove a value after
348 * it is updated here. */
349 pthread_mutex_lock (&cache_lock);
350 for (int i = 0; i < keys_len; i++)
355 status = c_avl_remove (cache_tree, keys[i],
356 (void *) &key, (void *) &ce);
359 ERROR ("uc_check_timeout: c_avl_remove (\"%s\") failed.", keys[i]);
367 } /* for (i = 0; i < keys_len; i++) */
368 pthread_mutex_unlock (&cache_lock);
372 sfree (keys_interval);
375 } /* int uc_check_timeout */
377 int uc_update (const data_set_t *ds, const value_list_t *vl)
379 char name[6 * DATA_MAX_NAME_LEN];
380 cache_entry_t *ce = NULL;
383 if (FORMAT_VL (name, sizeof (name), vl) != 0)
385 ERROR ("uc_update: FORMAT_VL failed.");
389 pthread_mutex_lock (&cache_lock);
391 status = c_avl_get (cache_tree, name, (void *) &ce);
392 if (status != 0) /* entry does not yet exist */
394 status = uc_insert (ds, vl, name);
395 pthread_mutex_unlock (&cache_lock);
400 assert (ce->values_num == ds->ds_num);
402 if (ce->last_time >= vl->time)
404 pthread_mutex_unlock (&cache_lock);
405 NOTICE ("uc_update: Value too old: name = %s; value time = %.3f; "
406 "last cache update = %.3f;",
408 CDTIME_T_TO_DOUBLE (vl->time),
409 CDTIME_T_TO_DOUBLE (ce->last_time));
413 for (size_t i = 0; i < ds->ds_num; i++)
415 switch (ds->ds[i].type)
417 case DS_TYPE_COUNTER:
419 counter_t diff = counter_diff (ce->values_raw[i].counter, vl->values[i].counter);
420 ce->values_gauge[i] = ((double) diff)
421 / (CDTIME_T_TO_DOUBLE (vl->time - ce->last_time));
422 ce->values_raw[i].counter = vl->values[i].counter;
427 ce->values_raw[i].gauge = vl->values[i].gauge;
428 ce->values_gauge[i] = vl->values[i].gauge;
433 derive_t diff = vl->values[i].derive - ce->values_raw[i].derive;
435 ce->values_gauge[i] = ((double) diff)
436 / (CDTIME_T_TO_DOUBLE (vl->time - ce->last_time));
437 ce->values_raw[i].derive = vl->values[i].derive;
441 case DS_TYPE_ABSOLUTE:
442 ce->values_gauge[i] = ((double) vl->values[i].absolute)
443 / (CDTIME_T_TO_DOUBLE (vl->time - ce->last_time));
444 ce->values_raw[i].absolute = vl->values[i].absolute;
448 /* This shouldn't happen. */
449 pthread_mutex_unlock (&cache_lock);
450 ERROR ("uc_update: Don't know how to handle data source type %i.",
453 } /* switch (ds->ds[i].type) */
455 DEBUG ("uc_update: %s: ds[%zu] = %lf", name, i, ce->values_gauge[i]);
458 /* Update the history if it exists. */
459 if (ce->history != NULL)
461 assert (ce->history_index < ce->history_length);
462 for (size_t i = 0; i < ce->values_num; i++)
464 size_t hist_idx = (ce->values_num * ce->history_index) + i;
465 ce->history[hist_idx] = ce->values_gauge[i];
468 assert (ce->history_length > 0);
469 ce->history_index = (ce->history_index + 1) % ce->history_length;
472 /* Prune invalid gauge data */
473 uc_check_range (ds, ce);
475 ce->last_time = vl->time;
476 ce->last_update = cdtime ();
477 ce->interval = vl->interval;
479 pthread_mutex_unlock (&cache_lock);
482 } /* int uc_update */
484 int uc_get_rate_by_name (const char *name, gauge_t **ret_values, size_t *ret_values_num)
488 cache_entry_t *ce = NULL;
491 pthread_mutex_lock (&cache_lock);
493 if (c_avl_get (cache_tree, name, (void *) &ce) == 0)
497 /* remove missing values from getval */
498 if (ce->state == STATE_MISSING)
504 ret_num = ce->values_num;
505 ret = malloc (ret_num * sizeof (*ret));
508 ERROR ("utils_cache: uc_get_rate_by_name: malloc failed.");
513 memcpy (ret, ce->values_gauge, ret_num * sizeof (gauge_t));
519 DEBUG ("utils_cache: uc_get_rate_by_name: No such value: %s", name);
523 pthread_mutex_unlock (&cache_lock);
528 *ret_values_num = ret_num;
532 } /* gauge_t *uc_get_rate_by_name */
534 gauge_t *uc_get_rate (const data_set_t *ds, const value_list_t *vl)
536 char name[6 * DATA_MAX_NAME_LEN];
541 if (FORMAT_VL (name, sizeof (name), vl) != 0)
543 ERROR ("utils_cache: uc_get_rate: FORMAT_VL failed.");
547 status = uc_get_rate_by_name (name, &ret, &ret_num);
551 /* This is important - the caller has no other way of knowing how many
552 * values are returned. */
553 if (ret_num != (size_t) ds->ds_num)
555 ERROR ("utils_cache: uc_get_rate: ds[%s] has %zu values, "
556 "but uc_get_rate_by_name returned %zu.",
557 ds->type, ds->ds_num, ret_num);
563 } /* gauge_t *uc_get_rate */
565 size_t uc_get_size (void) {
566 size_t size_arrays = 0;
568 pthread_mutex_lock (&cache_lock);
569 size_arrays = (size_t) c_avl_size (cache_tree);
570 pthread_mutex_unlock (&cache_lock);
572 return (size_arrays);
575 int uc_get_names (char ***ret_names, cdtime_t **ret_times, size_t *ret_number)
577 c_avl_iterator_t *iter;
579 cache_entry_t *value;
582 cdtime_t *times = NULL;
584 size_t size_arrays = 0;
588 if ((ret_names == NULL) || (ret_number == NULL))
591 pthread_mutex_lock (&cache_lock);
593 size_arrays = (size_t) c_avl_size (cache_tree);
596 /* Handle the "no values" case here, to avoid the error message when
597 * calloc() returns NULL. */
598 pthread_mutex_unlock (&cache_lock);
602 names = calloc (size_arrays, sizeof (*names));
603 times = calloc (size_arrays, sizeof (*times));
604 if ((names == NULL) || (times == NULL))
606 ERROR ("uc_get_names: calloc failed.");
609 pthread_mutex_unlock (&cache_lock);
613 iter = c_avl_get_iterator (cache_tree);
614 while (c_avl_iterator_next (iter, (void *) &key, (void *) &value) == 0)
616 /* remove missing values when list values */
617 if (value->state == STATE_MISSING)
620 /* c_avl_size does not return a number smaller than the number of elements
621 * returned by c_avl_iterator_next. */
622 assert (number < size_arrays);
624 if (ret_times != NULL)
625 times[number] = value->last_time;
627 names[number] = strdup (key);
628 if (names[number] == NULL)
635 } /* while (c_avl_iterator_next) */
637 c_avl_iterator_destroy (iter);
638 pthread_mutex_unlock (&cache_lock);
642 for (size_t i = 0; i < number; i++)
653 if (ret_times != NULL)
657 *ret_number = number;
660 } /* int uc_get_names */
662 int uc_get_state (const data_set_t *ds, const value_list_t *vl)
664 char name[6 * DATA_MAX_NAME_LEN];
665 cache_entry_t *ce = NULL;
666 int ret = STATE_ERROR;
668 if (FORMAT_VL (name, sizeof (name), vl) != 0)
670 ERROR ("uc_get_state: FORMAT_VL failed.");
671 return (STATE_ERROR);
674 pthread_mutex_lock (&cache_lock);
676 if (c_avl_get (cache_tree, name, (void *) &ce) == 0)
682 pthread_mutex_unlock (&cache_lock);
685 } /* int uc_get_state */
687 int uc_set_state (const data_set_t *ds, const value_list_t *vl, int state)
689 char name[6 * DATA_MAX_NAME_LEN];
690 cache_entry_t *ce = NULL;
693 if (FORMAT_VL (name, sizeof (name), vl) != 0)
695 ERROR ("uc_set_state: FORMAT_VL failed.");
696 return (STATE_ERROR);
699 pthread_mutex_lock (&cache_lock);
701 if (c_avl_get (cache_tree, name, (void *) &ce) == 0)
708 pthread_mutex_unlock (&cache_lock);
711 } /* int uc_set_state */
713 int uc_get_history_by_name (const char *name,
714 gauge_t *ret_history, size_t num_steps, size_t num_ds)
716 cache_entry_t *ce = NULL;
719 pthread_mutex_lock (&cache_lock);
721 status = c_avl_get (cache_tree, name, (void *) &ce);
724 pthread_mutex_unlock (&cache_lock);
728 if (((size_t) ce->values_num) != num_ds)
730 pthread_mutex_unlock (&cache_lock);
734 /* Check if there are enough values available. If not, increase the buffer
736 if (ce->history_length < num_steps)
740 tmp = realloc (ce->history, sizeof (*ce->history)
741 * num_steps * ce->values_num);
744 pthread_mutex_unlock (&cache_lock);
748 for (size_t i = ce->history_length * ce->values_num;
749 i < (num_steps * ce->values_num);
754 ce->history_length = num_steps;
755 } /* if (ce->history_length < num_steps) */
757 /* Copy the values to the output buffer. */
758 for (size_t i = 0; i < num_steps; i++)
763 if (i < ce->history_index)
764 src_index = ce->history_index - (i + 1);
766 src_index = ce->history_length + ce->history_index - (i + 1);
767 src_index = src_index * num_ds;
769 dst_index = i * num_ds;
771 memcpy (ret_history + dst_index, ce->history + src_index,
772 sizeof (*ret_history) * num_ds);
775 pthread_mutex_unlock (&cache_lock);
778 } /* int uc_get_history_by_name */
780 int uc_get_history (const data_set_t *ds, const value_list_t *vl,
781 gauge_t *ret_history, size_t num_steps, size_t num_ds)
783 char name[6 * DATA_MAX_NAME_LEN];
785 if (FORMAT_VL (name, sizeof (name), vl) != 0)
787 ERROR ("utils_cache: uc_get_history: FORMAT_VL failed.");
791 return (uc_get_history_by_name (name, ret_history, num_steps, num_ds));
792 } /* int uc_get_history */
794 int uc_get_hits (const data_set_t *ds, const value_list_t *vl)
796 char name[6 * DATA_MAX_NAME_LEN];
797 cache_entry_t *ce = NULL;
798 int ret = STATE_ERROR;
800 if (FORMAT_VL (name, sizeof (name), vl) != 0)
802 ERROR ("uc_get_hits: FORMAT_VL failed.");
803 return (STATE_ERROR);
806 pthread_mutex_lock (&cache_lock);
808 if (c_avl_get (cache_tree, name, (void *) &ce) == 0)
814 pthread_mutex_unlock (&cache_lock);
817 } /* int uc_get_hits */
819 int uc_set_hits (const data_set_t *ds, const value_list_t *vl, int hits)
821 char name[6 * DATA_MAX_NAME_LEN];
822 cache_entry_t *ce = NULL;
825 if (FORMAT_VL (name, sizeof (name), vl) != 0)
827 ERROR ("uc_set_hits: FORMAT_VL failed.");
828 return (STATE_ERROR);
831 pthread_mutex_lock (&cache_lock);
833 if (c_avl_get (cache_tree, name, (void *) &ce) == 0)
840 pthread_mutex_unlock (&cache_lock);
843 } /* int uc_set_hits */
845 int uc_inc_hits (const data_set_t *ds, const value_list_t *vl, int step)
847 char name[6 * DATA_MAX_NAME_LEN];
848 cache_entry_t *ce = NULL;
851 if (FORMAT_VL (name, sizeof (name), vl) != 0)
853 ERROR ("uc_inc_hits: FORMAT_VL failed.");
854 return (STATE_ERROR);
857 pthread_mutex_lock (&cache_lock);
859 if (c_avl_get (cache_tree, name, (void *) &ce) == 0)
863 ce->hits = ret + step;
866 pthread_mutex_unlock (&cache_lock);
869 } /* int uc_inc_hits */
874 uc_iter_t *uc_get_iterator (void)
878 iter = (uc_iter_t *) calloc(1, sizeof (*iter));
882 pthread_mutex_lock (&cache_lock);
884 iter->iter = c_avl_get_iterator (cache_tree);
885 if (iter->iter == NULL)
892 } /* uc_iter_t *uc_get_iterator */
894 int uc_iterator_next (uc_iter_t *iter, char **ret_name)
901 while ((status = c_avl_iterator_next (iter->iter,
902 (void *) &iter->name, (void *) &iter->entry)) == 0)
904 if (iter->entry->state == STATE_MISSING)
915 if (ret_name != NULL)
916 *ret_name = iter->name;
919 } /* int uc_iterator_next */
921 void uc_iterator_destroy (uc_iter_t *iter)
926 c_avl_iterator_destroy (iter->iter);
927 pthread_mutex_unlock (&cache_lock);
930 } /* void uc_iterator_destroy */
932 int uc_iterator_get_time (uc_iter_t *iter, cdtime_t *ret_time)
934 if ((iter == NULL) || (iter->entry == NULL) || (ret_time == NULL))
937 *ret_time = iter->entry->last_time;
939 } /* int uc_iterator_get_name */
941 int uc_iterator_get_values (uc_iter_t *iter, value_t **ret_values, size_t *ret_num)
943 if ((iter == NULL) || (iter->entry == NULL)
944 || (ret_values == NULL) || (ret_num == NULL))
947 *ret_values = calloc (iter->entry->values_num, sizeof(*iter->entry->values_raw));
948 if (*ret_values == NULL)
950 for (size_t i = 0; i < iter->entry->values_num; ++i)
951 *ret_values[i] = iter->entry->values_raw[i];
953 *ret_num = iter->entry->values_num;
956 } /* int uc_iterator_get_values */
958 int uc_iterator_get_interval (uc_iter_t *iter, cdtime_t *ret_interval)
960 if ((iter == NULL) || (iter->entry == NULL) || (ret_interval == NULL))
963 *ret_interval = iter->entry->interval;
965 } /* int uc_iterator_get_name */
968 * Meta data interface
970 /* XXX: This function will acquire `cache_lock' but will not free it! */
971 static meta_data_t *uc_get_meta (const value_list_t *vl) /* {{{ */
973 char name[6 * DATA_MAX_NAME_LEN];
974 cache_entry_t *ce = NULL;
977 status = FORMAT_VL (name, sizeof (name), vl);
980 ERROR ("utils_cache: uc_get_meta: FORMAT_VL failed.");
984 pthread_mutex_lock (&cache_lock);
986 status = c_avl_get (cache_tree, name, (void *) &ce);
989 pthread_mutex_unlock (&cache_lock);
994 if (ce->meta == NULL)
995 ce->meta = meta_data_create ();
997 if (ce->meta == NULL)
998 pthread_mutex_unlock (&cache_lock);
1001 } /* }}} meta_data_t *uc_get_meta */
1003 /* Sorry about this preprocessor magic, but it really makes this file much
1005 #define UC_WRAP(wrap_function) { \
1006 meta_data_t *meta; \
1008 meta = uc_get_meta (vl); \
1009 if (meta == NULL) return (-1); \
1010 status = wrap_function (meta, key); \
1011 pthread_mutex_unlock (&cache_lock); \
1014 int uc_meta_data_exists (const value_list_t *vl, const char *key)
1015 UC_WRAP (meta_data_exists)
1017 int uc_meta_data_delete (const value_list_t *vl, const char *key)
1018 UC_WRAP (meta_data_delete)
1021 /* We need a new version of this macro because the following functions take
1023 #define UC_WRAP(wrap_function) { \
1024 meta_data_t *meta; \
1026 meta = uc_get_meta (vl); \
1027 if (meta == NULL) return (-1); \
1028 status = wrap_function (meta, key, value); \
1029 pthread_mutex_unlock (&cache_lock); \
1032 int uc_meta_data_add_string (const value_list_t *vl,
1035 UC_WRAP(meta_data_add_string)
1036 int uc_meta_data_add_signed_int (const value_list_t *vl,
1039 UC_WRAP(meta_data_add_signed_int)
1040 int uc_meta_data_add_unsigned_int (const value_list_t *vl,
1043 UC_WRAP(meta_data_add_unsigned_int)
1044 int uc_meta_data_add_double (const value_list_t *vl,
1047 UC_WRAP(meta_data_add_double)
1048 int uc_meta_data_add_boolean (const value_list_t *vl,
1051 UC_WRAP(meta_data_add_boolean)
1053 int uc_meta_data_get_string (const value_list_t *vl,
1056 UC_WRAP(meta_data_get_string)
1057 int uc_meta_data_get_signed_int (const value_list_t *vl,
1060 UC_WRAP(meta_data_get_signed_int)
1061 int uc_meta_data_get_unsigned_int (const value_list_t *vl,
1064 UC_WRAP(meta_data_get_unsigned_int)
1065 int uc_meta_data_get_double (const value_list_t *vl,
1068 UC_WRAP(meta_data_get_double)
1069 int uc_meta_data_get_boolean (const value_list_t *vl,
1072 UC_WRAP(meta_data_get_boolean)
1075 /* vim: set sw=2 ts=8 sts=2 tw=78 : */