X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Fdrivers.c;h=30d6308a5ba57348c4c2e3695f83e6066b293864;hb=7a38cdf76678a64f6bfc9178e623f9f9cecfcd4b;hp=c6165b6360c71778b63b5ffcf7b656a6b06a72a2;hpb=d9251a2c9f1ca4380c27240ccca90c9f9ed46d3f;p=libsigrok.git diff --git a/src/drivers.c b/src/drivers.c index c6165b63..30d6308a 100644 --- a/src/drivers.c +++ b/src/drivers.c @@ -3,6 +3,7 @@ * * Copyright (C) 2016 Lars-Peter Clausen * Copyright (C) 2016 Aurelien Jacobs + * Copyright (C) 2017 Marcus Comstedt * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -26,22 +27,19 @@ /* * sr_driver_list is a special section contains pointers to all the hardware * drivers built into the library. The __start and __stop symbols are - * auto-generated by the linker (OSX needs a little help) and point to the start - * and end of the section. They are used to iterate over the list of all - * drivers. + * created from driver_list_start.c and driver_list_stop.c, and point to the + * start and end of the section. They are used to iterate over the list of + * all drivers. */ -#ifdef __APPLE__ -extern struct sr_dev_driver *__start_sr_driver_list __asm("section$start$__DATA$__sr_driver_list"); -extern struct sr_dev_driver *__stop_sr_driver_list __asm("section$end$__DATA$__sr_driver_list"); -#else -extern struct sr_dev_driver *__start_sr_driver_list; -extern struct sr_dev_driver *__stop_sr_driver_list; -#endif +SR_PRIV extern const struct sr_dev_driver *sr_driver_list__start[]; +SR_PRIV extern const struct sr_dev_driver *sr_driver_list__stop[]; -/** @private +/** * Initialize the driver list in a fresh libsigrok context. * * @param ctx Pointer to a libsigrok context struct. Must not be NULL. + * + * @private */ SR_API void sr_drivers_init(struct sr_context *ctx) { @@ -49,8 +47,8 @@ SR_API void sr_drivers_init(struct sr_context *ctx) array = g_array_new(TRUE, FALSE, sizeof(struct sr_dev_driver *)); #ifdef HAVE_DRIVERS - for (struct sr_dev_driver **drivers = &__start_sr_driver_list; - drivers < &__stop_sr_driver_list; drivers++) + for (const struct sr_dev_driver **drivers = sr_driver_list__start + 1; + drivers < sr_driver_list__stop; drivers++) g_array_append_val(array, *drivers); #endif ctx->driver_list = (struct sr_dev_driver **)array->data;