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>
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
22 #include <libsigrok/libsigrok.h>
23 #include "libsigrok-internal.h"
26 * sr_driver_list is a special section contains pointers to all the hardware
27 * drivers built into the library. The __start and __stop symbols are
28 * auto-generated by the linker (OSX needs a little help) and point to the start
29 * and end of the section. They are used to iterate over the list of all
33 extern struct sr_dev_driver *__start_sr_driver_list __asm("section$start$__DATA$__sr_driver_list");
34 extern struct sr_dev_driver *__stop_sr_driver_list __asm("section$end$__DATA$__sr_driver_list");
36 extern struct sr_dev_driver *__start_sr_driver_list;
37 extern struct sr_dev_driver *__stop_sr_driver_list;
41 * Initialize the driver list in a fresh libsigrok context.
43 * @param ctx Pointer to a libsigrok context struct. Must not be NULL.
45 SR_PRIV void sr_drivers_init(struct sr_context *ctx)
47 struct sr_dev_driver **drivers;
50 array = g_array_new(TRUE, FALSE, sizeof(struct sr_dev_driver *));
51 for (drivers = &__start_sr_driver_list; drivers < &__stop_sr_driver_list;
53 g_array_append_val(array, *drivers);
54 ctx->driver_list = (struct sr_dev_driver **)array->data;
55 g_array_free(array, FALSE);