From c917cd4dbb31508628a8079e2720787b52b1f14b Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Mon, 2 Mar 2020 10:50:34 +1100 Subject: [PATCH] AP_HAL_Linux: make a static-const hal references references to external symbol --- libraries/AP_HAL_Linux/AnalogIn_Navio2.cpp | 2 +- libraries/AP_HAL_Linux/GPIO.cpp | 2 +- libraries/AP_HAL_Linux/GPIO_RPI.cpp | 2 +- libraries/AP_HAL_Linux/GPIO_Sysfs.cpp | 2 +- libraries/AP_HAL_Linux/HAL_Linux_Class.cpp | 6 +++--- libraries/AP_HAL_Linux/I2CDevice.cpp | 4 ++-- libraries/AP_HAL_Linux/Led_Sysfs.cpp | 2 +- libraries/AP_HAL_Linux/PWM_Sysfs.cpp | 2 +- libraries/AP_HAL_Linux/Perf.cpp | 2 +- libraries/AP_HAL_Linux/RCOutput_AeroIO.cpp | 2 +- libraries/AP_HAL_Linux/RCOutput_Bebop.cpp | 2 +- libraries/AP_HAL_Linux/RCOutput_PCA9685.cpp | 2 +- libraries/AP_HAL_Linux/SPIDevice.cpp | 4 ++-- libraries/AP_Notify/RCOutputRGBLed.cpp | 2 +- 14 files changed, 18 insertions(+), 18 deletions(-) diff --git a/libraries/AP_HAL_Linux/AnalogIn_Navio2.cpp b/libraries/AP_HAL_Linux/AnalogIn_Navio2.cpp index c568332ee9..93e586d938 100644 --- a/libraries/AP_HAL_Linux/AnalogIn_Navio2.cpp +++ b/libraries/AP_HAL_Linux/AnalogIn_Navio2.cpp @@ -7,7 +7,7 @@ #include "AnalogIn_Navio2.h" -static const AP_HAL::HAL &hal = AP_HAL::get_HAL(); +extern const AP_HAL::HAL& hal; #define ADC_BASE_PATH "/sys/kernel/rcio/adc" diff --git a/libraries/AP_HAL_Linux/GPIO.cpp b/libraries/AP_HAL_Linux/GPIO.cpp index 4a29a4c485..69ba89282c 100644 --- a/libraries/AP_HAL_Linux/GPIO.cpp +++ b/libraries/AP_HAL_Linux/GPIO.cpp @@ -4,7 +4,7 @@ using namespace Linux; -static const AP_HAL::HAL& hal = AP_HAL::get_HAL(); +extern const AP_HAL::HAL& hal; DigitalSource::DigitalSource(uint8_t v) : _v(v) diff --git a/libraries/AP_HAL_Linux/GPIO_RPI.cpp b/libraries/AP_HAL_Linux/GPIO_RPI.cpp index 13f143b31b..a140b54aa0 100644 --- a/libraries/AP_HAL_Linux/GPIO_RPI.cpp +++ b/libraries/AP_HAL_Linux/GPIO_RPI.cpp @@ -36,7 +36,7 @@ using namespace Linux; -static const AP_HAL::HAL &hal = AP_HAL::get_HAL(); +extern const AP_HAL::HAL& hal; GPIO_RPI::GPIO_RPI() { diff --git a/libraries/AP_HAL_Linux/GPIO_Sysfs.cpp b/libraries/AP_HAL_Linux/GPIO_Sysfs.cpp index bca92728a9..eab54f49de 100644 --- a/libraries/AP_HAL_Linux/GPIO_Sysfs.cpp +++ b/libraries/AP_HAL_Linux/GPIO_Sysfs.cpp @@ -21,7 +21,7 @@ using namespace Linux; -static const AP_HAL::HAL& hal = AP_HAL::get_HAL(); +extern const AP_HAL::HAL& hal; #define UINT32_MAX_STR "4294967295" diff --git a/libraries/AP_HAL_Linux/HAL_Linux_Class.cpp b/libraries/AP_HAL_Linux/HAL_Linux_Class.cpp index 854f1583bf..54dba27a67 100644 --- a/libraries/AP_HAL_Linux/HAL_Linux_Class.cpp +++ b/libraries/AP_HAL_Linux/HAL_Linux_Class.cpp @@ -409,14 +409,14 @@ void HAL_Linux::setup_signal_handlers() const sigaction(SIGINT, &sa, NULL); } -static HAL_Linux halInstance; +HAL_Linux hal_linux; void HAL_Linux::exit_signal_handler(int signum) { - halInstance._should_exit = true; + hal_linux._should_exit = true; } const AP_HAL::HAL &AP_HAL::get_HAL() { - return halInstance; + return hal_linux; } diff --git a/libraries/AP_HAL_Linux/I2CDevice.cpp b/libraries/AP_HAL_Linux/I2CDevice.cpp index f995c3e1a6..ce59a8e8bd 100644 --- a/libraries/AP_HAL_Linux/I2CDevice.cpp +++ b/libraries/AP_HAL_Linux/I2CDevice.cpp @@ -56,9 +56,9 @@ #define I2C_RDRW_IOCTL_MAX_MSGS 42 #endif -namespace Linux { +extern const AP_HAL::HAL& hal; -static const AP_HAL::HAL &hal = AP_HAL::get_HAL(); +namespace Linux { /* * TODO: move to Util or other upper class to be used by others diff --git a/libraries/AP_HAL_Linux/Led_Sysfs.cpp b/libraries/AP_HAL_Linux/Led_Sysfs.cpp index 5758cf6043..898b157048 100644 --- a/libraries/AP_HAL_Linux/Led_Sysfs.cpp +++ b/libraries/AP_HAL_Linux/Led_Sysfs.cpp @@ -26,7 +26,7 @@ #include -static const AP_HAL::HAL &hal = AP_HAL::get_HAL(); +extern const AP_HAL::HAL& hal; namespace Linux { diff --git a/libraries/AP_HAL_Linux/PWM_Sysfs.cpp b/libraries/AP_HAL_Linux/PWM_Sysfs.cpp index fad21d72fe..680f82ec51 100644 --- a/libraries/AP_HAL_Linux/PWM_Sysfs.cpp +++ b/libraries/AP_HAL_Linux/PWM_Sysfs.cpp @@ -26,7 +26,7 @@ #include #include -static const AP_HAL::HAL &hal = AP_HAL::get_HAL(); +extern const AP_HAL::HAL& hal; namespace Linux { diff --git a/libraries/AP_HAL_Linux/Perf.cpp b/libraries/AP_HAL_Linux/Perf.cpp index 274b02108c..12c39d5aa9 100644 --- a/libraries/AP_HAL_Linux/Perf.cpp +++ b/libraries/AP_HAL_Linux/Perf.cpp @@ -33,7 +33,7 @@ using namespace Linux; -static const AP_HAL::HAL &hal = AP_HAL::get_HAL(); +extern const AP_HAL::HAL& hal; Perf *Perf::_singleton; diff --git a/libraries/AP_HAL_Linux/RCOutput_AeroIO.cpp b/libraries/AP_HAL_Linux/RCOutput_AeroIO.cpp index 4616dd23d8..1f61cf7325 100644 --- a/libraries/AP_HAL_Linux/RCOutput_AeroIO.cpp +++ b/libraries/AP_HAL_Linux/RCOutput_AeroIO.cpp @@ -91,7 +91,7 @@ using namespace Linux; * uint16_t duty = 1823; */ -static const AP_HAL::HAL &hal = AP_HAL::get_HAL(); +extern const AP_HAL::HAL& hal; RCOutput_AeroIO::RCOutput_AeroIO() : _freq_buffer(new uint16_t[PWM_CHAN_COUNT]) diff --git a/libraries/AP_HAL_Linux/RCOutput_Bebop.cpp b/libraries/AP_HAL_Linux/RCOutput_Bebop.cpp index 984245d792..88a674fde9 100644 --- a/libraries/AP_HAL_Linux/RCOutput_Bebop.cpp +++ b/libraries/AP_HAL_Linux/RCOutput_Bebop.cpp @@ -81,7 +81,7 @@ enum BLDC_STATUS { using namespace Linux; -static const AP_HAL::HAL& hal = AP_HAL::get_HAL(); +extern const AP_HAL::HAL& hal; RCOutput_Bebop::RCOutput_Bebop(AP_HAL::OwnPtr dev) : _dev(std::move(dev)) diff --git a/libraries/AP_HAL_Linux/RCOutput_PCA9685.cpp b/libraries/AP_HAL_Linux/RCOutput_PCA9685.cpp index 8364932efb..4198df15cf 100644 --- a/libraries/AP_HAL_Linux/RCOutput_PCA9685.cpp +++ b/libraries/AP_HAL_Linux/RCOutput_PCA9685.cpp @@ -54,7 +54,7 @@ using namespace Linux; #define PWM_CHAN_COUNT 16 -static const AP_HAL::HAL& hal = AP_HAL::get_HAL(); +extern const AP_HAL::HAL& hal; RCOutput_PCA9685::RCOutput_PCA9685(AP_HAL::OwnPtr dev, bool external_clock, diff --git a/libraries/AP_HAL_Linux/SPIDevice.cpp b/libraries/AP_HAL_Linux/SPIDevice.cpp index cd06293e01..ca4be42d21 100644 --- a/libraries/AP_HAL_Linux/SPIDevice.cpp +++ b/libraries/AP_HAL_Linux/SPIDevice.cpp @@ -39,9 +39,9 @@ #define DEBUG 0 -namespace Linux { +extern const AP_HAL::HAL& hal; -static const AP_HAL::HAL &hal = AP_HAL::get_HAL(); +namespace Linux { #define MHZ (1000U*1000U) #define KHZ (1000U) diff --git a/libraries/AP_Notify/RCOutputRGBLed.cpp b/libraries/AP_Notify/RCOutputRGBLed.cpp index a52d03edce..bbd864f435 100644 --- a/libraries/AP_Notify/RCOutputRGBLed.cpp +++ b/libraries/AP_Notify/RCOutputRGBLed.cpp @@ -20,7 +20,7 @@ #include #include -static const AP_HAL::HAL& hal = AP_HAL::get_HAL(); +extern const AP_HAL::HAL& hal; #define LED_OFF 0 #define LED_FULL_BRIGHT 255