2 * UCW Library -- Configuration files: Contexts
4 * (c) 2012 Martin Mares <mj@ucw.cz>
6 * This software may be freely distributed and used according to the terms
7 * of the GNU Lesser General Public License.
12 #include <ucw/conf-internal.h>
13 #include <ucw/threads.h>
15 static struct cf_context cf_default_context;
18 cf_init_context(struct cf_context *cc)
21 clist_init(&cc->conf_entries);
27 struct cf_context *cc = xmalloc_zero(sizeof(*cc));
33 cf_free_context(struct cf_context *cc)
35 ASSERT(!cc->is_active);
36 ASSERT(cc != &cf_default_context);
42 cf_switch_context(struct cf_context *cc)
44 struct ucwlib_context *uc = ucwlib_thread_context();
45 struct cf_context *prev = uc->cf_context;
50 ASSERT(!cc->is_active);
57 static void CONSTRUCTOR_WITH_PRIORITY(10100)
58 cf_init_default_context(void)
60 cf_init_context(&cf_default_context);
61 ucwlib_thread_context()->cf_context = &cf_default_context;
62 cf_default_context.is_active = 1;
66 cf_obtain_context(void)
68 return cf_get_context();