]>
Commit | Line | Data |
---|---|---|
5d8b3913 AJ |
1 | /* |
2 | * This file is part of the libsigrok project. | |
3 | * | |
4 | * Copyright (C) 2016 Lars-Peter Clausen <lars@metafoo.de> | |
5 | * Copyright (C) 2016 Aurelien Jacobs <aurel@gnuage.org> | |
393375e1 | 6 | * Copyright (C) 2017 Marcus Comstedt <marcus@mc.pp.se> |
5d8b3913 AJ |
7 | * |
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. | |
12 | * | |
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. | |
17 | * | |
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/>. | |
20 | */ | |
21 | ||
bf85ea21 | 22 | #include <config.h> |
5d8b3913 AJ |
23 | #include <glib.h> |
24 | #include <libsigrok/libsigrok.h> | |
25 | #include "libsigrok-internal.h" | |
26 | ||
27 | /* | |
d8292397 GS |
28 | * The special __sr_driver_list section contains pointers to all hardware |
29 | * drivers which were built into the library according to its configuration | |
30 | * (will depend on the availability of dependencies, as well as user provided | |
31 | * specs). The __start and __stop symbols point to the start and end of the | |
32 | * section. They are used to iterate over the list of all drivers which were | |
33 | * included in the library. | |
5d8b3913 | 34 | */ |
393375e1 MC |
35 | SR_PRIV extern const struct sr_dev_driver *sr_driver_list__start[]; |
36 | SR_PRIV extern const struct sr_dev_driver *sr_driver_list__stop[]; | |
5d8b3913 | 37 | |
82b9f3d1 | 38 | /** |
5d8b3913 AJ |
39 | * Initialize the driver list in a fresh libsigrok context. |
40 | * | |
41 | * @param ctx Pointer to a libsigrok context struct. Must not be NULL. | |
82b9f3d1 UH |
42 | * |
43 | * @private | |
5d8b3913 | 44 | */ |
ced48274 | 45 | SR_API void sr_drivers_init(struct sr_context *ctx) |
5d8b3913 | 46 | { |
5d8b3913 AJ |
47 | GArray *array; |
48 | ||
49 | array = g_array_new(TRUE, FALSE, sizeof(struct sr_dev_driver *)); | |
bf85ea21 | 50 | #ifdef HAVE_DRIVERS |
393375e1 MC |
51 | for (const struct sr_dev_driver **drivers = sr_driver_list__start + 1; |
52 | drivers < sr_driver_list__stop; drivers++) | |
5d8b3913 | 53 | g_array_append_val(array, *drivers); |
bf85ea21 | 54 | #endif |
5d8b3913 AJ |
55 | ctx->driver_list = (struct sr_dev_driver **)array->data; |
56 | g_array_free(array, FALSE); | |
57 | } |