return __uuid_generate_time_internal(out, num, cont_offset);
}
+#define CS_MIN (1<<6)
+#define CS_MAX (1<<18)
+#define CS_FACTOR 2
+
/*
* Generate time-based UUID and store it to @out
*
static int uuid_generate_time_generic(uuid_t out) {
#ifdef HAVE_TLS
/* thread local cache for uuidd based requests */
- const int cs_min = (1<<6);
- const int cs_max = (1<<18);
- const int cs_factor = 2;
THREAD_LOCAL int num = 0;
- THREAD_LOCAL int cache_size = cs_min;
+ THREAD_LOCAL int cache_size = CS_MIN;
THREAD_LOCAL int last_used = 0;
THREAD_LOCAL struct uuid uu;
THREAD_LOCAL time_t last_time = 0;
* Start with a small cache size to cover short running applications
* and adjust the cache size over the runntime.
*/
- if ((last_used == cache_size) && (cache_size < cs_max))
- cache_size *= cs_factor;
- else if ((last_used < (cache_size / cs_factor)) && (cache_size > cs_min))
- cache_size /= cs_factor;
+ if ((last_used == cache_size) && (cache_size < CS_MAX))
+ cache_size *= CS_FACTOR;
+ else if ((last_used < (cache_size / CS_FACTOR)) && (cache_size > CS_MIN))
+ cache_size /= CS_FACTOR;
num = cache_size;
}
/* request to daemon failed, reset cache */
num = 0;
- cache_size = cs_min;
+ cache_size = CS_MIN;
}
if (num > 0) { /* serve uuid from cache */
uu.time_low++;