gitlab-ci: enable sanitizers for the meson builds
[mesa-waffle.git] / src / waffle / api / waffle_config.c
bloba25ac92c32a5fd73da89a25b6a4b41e7c1750716
1 // SPDX-FileCopyrightText: Copyright 2012 Intel Corporation
2 // SPDX-License-Identifier: BSD-2-Clause
4 #include "api_priv.h"
6 #include "wcore_config_attrs.h"
7 #include "wcore_config.h"
8 #include "wcore_display.h"
9 #include "wcore_error.h"
10 #include "wcore_platform.h"
12 WAFFLE_API struct waffle_config*
13 waffle_config_choose(
14 struct waffle_display *dpy,
15 const int32_t attrib_list[])
17 struct wcore_config *wc_self;
18 struct wcore_display *wc_dpy = wcore_display(dpy);
19 struct wcore_config_attrs attrs;
20 bool ok = true;
22 const struct api_object *obj_list[] = {
23 wc_dpy ? &wc_dpy->api : NULL,
26 if (!api_check_entry(obj_list, 1))
27 return NULL;
29 ok = wcore_config_attrs_parse(attrib_list, &attrs);
30 if (!ok)
31 return NULL;
33 wc_self = api_platform->vtbl->config.choose(api_platform, wc_dpy, &attrs);
34 if (!wc_self)
35 return NULL;
37 return waffle_config(wc_self);
40 WAFFLE_API bool
41 waffle_config_destroy(struct waffle_config *self)
43 struct wcore_config *wc_self = wcore_config(self);
45 const struct api_object *obj_list[] = {
46 wc_self ? &wc_self->api : NULL,
49 if (!api_check_entry(obj_list, 1))
50 return false;
52 return api_platform->vtbl->config.destroy(wc_self);
55 WAFFLE_API union waffle_native_config*
56 waffle_config_get_native(struct waffle_config *self)
58 struct wcore_config *wc_self = wcore_config(self);
60 const struct api_object *obj_list[] = {
61 wc_self ? &wc_self->api : NULL,
64 if (!api_check_entry(obj_list, 1))
65 return NULL;
67 if (api_platform->vtbl->config.get_native) {
68 return api_platform->vtbl->config.get_native(wc_self);
70 else {
71 wcore_error(WAFFLE_ERROR_UNSUPPORTED_ON_PLATFORM);
72 return NULL;