drivers: Remove dependency on linker implementation specific behaviour
This commit is contained in:
parent
9014d45968
commit
393375e1fe
13
Makefile.am
13
Makefile.am
|
@ -168,15 +168,22 @@ libsigrok_la_SOURCES += \
|
||||||
src/scale/kern.c
|
src/scale/kern.c
|
||||||
|
|
||||||
# Hardware drivers
|
# Hardware drivers
|
||||||
noinst_LTLIBRARIES = src/libdrivers.la
|
noinst_LTLIBRARIES = src/libdrivers.la \
|
||||||
|
src/libdrivers_head.la src/libdrivers_tail.la
|
||||||
|
|
||||||
src/libdrivers.o: src/libdrivers.la
|
src/libdrivers.o: src/libdrivers.la \
|
||||||
$(AM_V_CCLD)$(LINK) src/libdrivers.la
|
src/libdrivers_head.la src/libdrivers_tail.la
|
||||||
|
$(AM_V_CCLD)$(LINK) src/libdrivers_head.la src/libdrivers.la \
|
||||||
|
src/libdrivers_tail.la
|
||||||
src/libdrivers.lo: src/libdrivers.o
|
src/libdrivers.lo: src/libdrivers.o
|
||||||
$(AM_V_GEN)echo "# Generated by libtool" > $@
|
$(AM_V_GEN)echo "# Generated by libtool" > $@
|
||||||
$(AM_V_at)echo "pic_object='libdrivers.o'" >> $@
|
$(AM_V_at)echo "pic_object='libdrivers.o'" >> $@
|
||||||
$(AM_V_at)echo "non_pic_object='libdrivers.o'" >> $@
|
$(AM_V_at)echo "non_pic_object='libdrivers.o'" >> $@
|
||||||
|
|
||||||
|
src_libdrivers_head_la_SOURCES = src/driver_list_start.c
|
||||||
|
|
||||||
|
src_libdrivers_tail_la_SOURCES = src/driver_list_stop.c
|
||||||
|
|
||||||
src_libdrivers_la_SOURCES = src/drivers.c
|
src_libdrivers_la_SOURCES = src/drivers.c
|
||||||
|
|
||||||
if HW_AGILENT_DMM
|
if HW_AGILENT_DMM
|
||||||
|
|
|
@ -0,0 +1,33 @@
|
||||||
|
/*
|
||||||
|
* This file is part of the libsigrok project.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2017 Marcus Comstedt <marcus@mc.pp.se>
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <config.h>
|
||||||
|
#include <glib.h>
|
||||||
|
#include <libsigrok/libsigrok.h>
|
||||||
|
#include "libsigrok-internal.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This marks the start of the driver list. This file must be linked
|
||||||
|
* before any actual drivers.
|
||||||
|
*/
|
||||||
|
|
||||||
|
SR_PRIV const struct sr_dev_driver *sr_driver_list__start[]
|
||||||
|
__attribute__((section (SR_DRIVER_LIST_SECTION),
|
||||||
|
used, aligned(sizeof(struct sr_dev_driver *))))
|
||||||
|
= { NULL /* Dummy item, as zero length arrays are not allowed by C99 */ };
|
|
@ -0,0 +1,33 @@
|
||||||
|
/*
|
||||||
|
* This file is part of the libsigrok project.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2017 Marcus Comstedt <marcus@mc.pp.se>
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <config.h>
|
||||||
|
#include <glib.h>
|
||||||
|
#include <libsigrok/libsigrok.h>
|
||||||
|
#include "libsigrok-internal.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This marks the end of the driver list. This file must be linked
|
||||||
|
* after any actual drivers.
|
||||||
|
*/
|
||||||
|
|
||||||
|
SR_PRIV const struct sr_dev_driver *sr_driver_list__stop[]
|
||||||
|
__attribute__((section (SR_DRIVER_LIST_SECTION),
|
||||||
|
used, aligned(sizeof(struct sr_dev_driver *))))
|
||||||
|
= { NULL /* Dummy item, as zero length arrays are not allowed by C99 */ };
|
|
@ -3,6 +3,7 @@
|
||||||
*
|
*
|
||||||
* Copyright (C) 2016 Lars-Peter Clausen <lars@metafoo.de>
|
* Copyright (C) 2016 Lars-Peter Clausen <lars@metafoo.de>
|
||||||
* Copyright (C) 2016 Aurelien Jacobs <aurel@gnuage.org>
|
* Copyright (C) 2016 Aurelien Jacobs <aurel@gnuage.org>
|
||||||
|
* Copyright (C) 2017 Marcus Comstedt <marcus@mc.pp.se>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -26,17 +27,12 @@
|
||||||
/*
|
/*
|
||||||
* sr_driver_list is a special section contains pointers to all the hardware
|
* sr_driver_list is a special section contains pointers to all the hardware
|
||||||
* drivers built into the library. The __start and __stop symbols are
|
* 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
|
* created from driver_list_start.c and driver_list_stop.c, and point to the
|
||||||
* and end of the section. They are used to iterate over the list of all
|
* start and end of the section. They are used to iterate over the list of
|
||||||
* drivers.
|
* all drivers.
|
||||||
*/
|
*/
|
||||||
#ifdef __APPLE__
|
SR_PRIV extern const struct sr_dev_driver *sr_driver_list__start[];
|
||||||
extern struct sr_dev_driver *__start_sr_driver_list __asm("section$start$__DATA$__sr_driver_list");
|
SR_PRIV extern const struct sr_dev_driver *sr_driver_list__stop[];
|
||||||
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
|
|
||||||
|
|
||||||
/** @private
|
/** @private
|
||||||
* Initialize the driver list in a fresh libsigrok context.
|
* Initialize the driver list in a fresh libsigrok context.
|
||||||
|
@ -49,8 +45,8 @@ SR_API void sr_drivers_init(struct sr_context *ctx)
|
||||||
|
|
||||||
array = g_array_new(TRUE, FALSE, sizeof(struct sr_dev_driver *));
|
array = g_array_new(TRUE, FALSE, sizeof(struct sr_dev_driver *));
|
||||||
#ifdef HAVE_DRIVERS
|
#ifdef HAVE_DRIVERS
|
||||||
for (struct sr_dev_driver **drivers = &__start_sr_driver_list;
|
for (const struct sr_dev_driver **drivers = sr_driver_list__start + 1;
|
||||||
drivers < &__stop_sr_driver_list; drivers++)
|
drivers < sr_driver_list__stop; drivers++)
|
||||||
g_array_append_val(array, *drivers);
|
g_array_append_val(array, *drivers);
|
||||||
#endif
|
#endif
|
||||||
ctx->driver_list = (struct sr_dev_driver **)array->data;
|
ctx->driver_list = (struct sr_dev_driver **)array->data;
|
||||||
|
|
Loading…
Reference in New Issue