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 // FIXME: Roll back all transactions
36 ASSERT(!cc->is_active);
37 ASSERT(cc != &cf_default_context);
43 cf_switch_context(struct cf_context *cc)
45 struct ucwlib_context *uc = ucwlib_thread_context();
46 struct cf_context *prev = uc->cf_context;
51 ASSERT(!cc->is_active);
58 static void CONSTRUCTOR_WITH_PRIORITY(10100)
59 cf_init_default_context(void)
61 cf_init_context(&cf_default_context);
62 ucwlib_thread_context()->cf_context = &cf_default_context;
63 cf_default_context.is_active = 1;
67 cf_obtain_context(void)
69 return cf_get_context();