2 * This file is part of the libsigrok project.
4 * Copyright (C) 2016 Lars-Peter Clausen <lars@metafoo.de>
5 * Copyright (C) 2016 Aurelien Jacobs <aurel@gnuage.org>
6 * Copyright (C) 2017 Marcus Comstedt <marcus@mc.pp.se>
8 * This program is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
24 #include <libsigrok/libsigrok.h>
25 #include "libsigrok-internal.h"
28 * sr_driver_list is a special section contains pointers to all the hardware
29 * drivers built into the library. The __start and __stop symbols are
30 * created from driver_list_start.c and driver_list_stop.c, and point to the
31 * start and end of the section. They are used to iterate over the list of
34 SR_PRIV extern const struct sr_dev_driver *sr_driver_list__start[];
35 SR_PRIV extern const struct sr_dev_driver *sr_driver_list__stop[];
38 * Initialize the driver list in a fresh libsigrok context.
40 * @param ctx Pointer to a libsigrok context struct. Must not be NULL.
44 SR_API void sr_drivers_init(struct sr_context *ctx)
48 array = g_array_new(TRUE, FALSE, sizeof(struct sr_dev_driver *));
50 for (const struct sr_dev_driver **drivers = sr_driver_list__start + 1;
51 drivers < sr_driver_list__stop; drivers++)
52 g_array_append_val(array, *drivers);
54 ctx->driver_list = (struct sr_dev_driver **)array->data;
55 g_array_free(array, FALSE);