diff options
author | David Sidrane <david_s5@nscdg.com> | 2015-01-22 12:28:18 -1000 |
---|---|---|
committer | David Sidrane <david_s5@nscdg.com> | 2015-04-07 07:18:44 -1000 |
commit | 63d74fa1831183bb17f0b964d02997b9a588a615 (patch) | |
tree | 17bec548ab640ff1b50b40f22f2be011d0c5e23b | |
parent | d12b79606b9f8d67494231aebe971396e01e8372 (diff) | |
download | px4-firmware-63d74fa1831183bb17f0b964d02997b9a588a615.tar.gz px4-firmware-63d74fa1831183bb17f0b964d02997b9a588a615.tar.bz2 px4-firmware-63d74fa1831183bb17f0b964d02997b9a588a615.zip |
Added Support for C++ static initializers for all boards. Including compile time checking for proper C++ configuration and not calling up_cxxinitialize redundantly
-rw-r--r-- | src/drivers/boards/aerocore/aerocore_init.c | 15 | ||||
-rw-r--r-- | src/drivers/boards/aerocore/module.mk | 6 | ||||
-rw-r--r-- | src/drivers/boards/px4fmu-v1/module.mk | 6 | ||||
-rw-r--r-- | src/drivers/boards/px4fmu-v1/px4fmu_init.c | 14 | ||||
-rw-r--r-- | src/drivers/boards/px4fmu-v2/px4fmu2_init.c | 6 | ||||
-rw-r--r-- | src/drivers/boards/px4io-v1/module.mk | 6 | ||||
-rw-r--r-- | src/drivers/boards/px4io-v2/module.mk | 6 | ||||
-rw-r--r-- | src/modules/px4iofirmware/px4io.c | 11 |
8 files changed, 70 insertions, 0 deletions
diff --git a/src/drivers/boards/aerocore/aerocore_init.c b/src/drivers/boards/aerocore/aerocore_init.c index e370fa983..91dbe4b81 100644 --- a/src/drivers/boards/aerocore/aerocore_init.c +++ b/src/drivers/boards/aerocore/aerocore_init.c @@ -228,6 +228,21 @@ __EXPORT int nsh_archinitialize(void) stm32_configgpio(GPIO_ADC1_IN12); /* J1 breakout */ stm32_configgpio(GPIO_ADC1_IN13); /* J1 breakout */ +#if defined(CONFIG_HAVE_CXX) && defined(CONFIG_HAVE_CXXINITIALIZE) + + /* run C++ ctors before we go any further */ + + up_cxxinitialize(); + +# if defined(CONFIG_EXAMPLES_NSH_CXXINITIALIZE) +# error CONFIG_EXAMPLES_NSH_CXXINITIALIZE Must not be defined! Use CONFIG_HAVE_CXX and CONFIG_HAVE_CXXINITIALIZE. +# endif + +#else +# error platform is dependent on c++ both CONFIG_HAVE_CXX and CONFIG_HAVE_CXXINITIALIZE must be defined. +#endif + + /* configure the high-resolution time/callout interface */ hrt_init(); diff --git a/src/drivers/boards/aerocore/module.mk b/src/drivers/boards/aerocore/module.mk index 0a2d91009..05e3d878d 100644 --- a/src/drivers/boards/aerocore/module.mk +++ b/src/drivers/boards/aerocore/module.mk @@ -7,4 +7,10 @@ SRCS = aerocore_init.c \ aerocore_spi.c \ aerocore_led.c +ENABLE_CXXINITIALIZE=$(call check_nuttx_config ,"CONFIG_HAVE_CXX 1", $(NUTTX_CONFIG_H)) +ENABLE_CXXINITIALIZE+=$(call check_nuttx_config ,"CONFIG_HAVE_CXXINITIALIZE 1", $(NUTTX_CONFIG_H)) +ifeq ("$(ENABLE_CXXINITIALIZE)",$(nuttx_config_2true)) +SRCS += ../../../modules/systemlib/up_cxxinitialize.c +endif + MAXOPTIMIZATION = -Os diff --git a/src/drivers/boards/px4fmu-v1/module.mk b/src/drivers/boards/px4fmu-v1/module.mk index 5e1a27d5a..ff717fe92 100644 --- a/src/drivers/boards/px4fmu-v1/module.mk +++ b/src/drivers/boards/px4fmu-v1/module.mk @@ -9,4 +9,10 @@ SRCS = px4fmu_can.c \ px4fmu_usb.c \ px4fmu_led.c +ENABLE_CXXINITIALIZE=$(call check_nuttx_config ,"CONFIG_HAVE_CXX 1", $(NUTTX_CONFIG_H)) +ENABLE_CXXINITIALIZE+=$(call check_nuttx_config ,"CONFIG_HAVE_CXXINITIALIZE 1", $(NUTTX_CONFIG_H)) +ifeq ("$(ENABLE_CXXINITIALIZE)",$(nuttx_config_2true)) +SRCS += ../../../modules/systemlib/up_cxxinitialize.c +endif + MAXOPTIMIZATION = -Os diff --git a/src/drivers/boards/px4fmu-v1/px4fmu_init.c b/src/drivers/boards/px4fmu-v1/px4fmu_init.c index 0e22aaee0..c9d4cce1e 100644 --- a/src/drivers/boards/px4fmu-v1/px4fmu_init.c +++ b/src/drivers/boards/px4fmu-v1/px4fmu_init.c @@ -145,6 +145,20 @@ __EXPORT int nsh_archinitialize(void) stm32_configgpio(GPIO_ADC1_IN11); /* IN12 and IN13 further below */ +#if defined(CONFIG_HAVE_CXX) && defined(CONFIG_HAVE_CXXINITIALIZE) + + /* run C++ ctors before we go any further */ + + up_cxxinitialize(); + +# if defined(CONFIG_EXAMPLES_NSH_CXXINITIALIZE) +# error CONFIG_EXAMPLES_NSH_CXXINITIALIZE Must not be defined! Use CONFIG_HAVE_CXX and CONFIG_HAVE_CXXINITIALIZE. +# endif + +#else +# error platform is dependent on c++ both CONFIG_HAVE_CXX and CONFIG_HAVE_CXXINITIALIZE must be defined. +#endif + /* configure the high-resolution time/callout interface */ hrt_init(); diff --git a/src/drivers/boards/px4fmu-v2/px4fmu2_init.c b/src/drivers/boards/px4fmu-v2/px4fmu2_init.c index 7fc1cd1df..e32c18759 100644 --- a/src/drivers/boards/px4fmu-v2/px4fmu2_init.c +++ b/src/drivers/boards/px4fmu-v2/px4fmu2_init.c @@ -245,6 +245,12 @@ __EXPORT int nsh_archinitialize(void) up_cxxinitialize(); +# if defined(CONFIG_EXAMPLES_NSH_CXXINITIALIZE) +# error CONFIG_EXAMPLES_NSH_CXXINITIALIZE Must not be defined! Use CONFIG_HAVE_CXX and CONFIG_HAVE_CXXINITIALIZE. +# endif + +#else +# error platform is dependent on c++ both CONFIG_HAVE_CXX and CONFIG_HAVE_CXXINITIALIZE must be defined. #endif /* configure the high-resolution time/callout interface */ diff --git a/src/drivers/boards/px4io-v1/module.mk b/src/drivers/boards/px4io-v1/module.mk index a7a14dd07..52f17f3f2 100644 --- a/src/drivers/boards/px4io-v1/module.mk +++ b/src/drivers/boards/px4io-v1/module.mk @@ -5,4 +5,10 @@ SRCS = px4io_init.c \ px4io_pwm_servo.c +ENABLE_CXXINITIALIZE=$(call check_nuttx_config ,"CONFIG_HAVE_CXX 1", $(NUTTX_CONFIG_H)) +ENABLE_CXXINITIALIZE+=$(call check_nuttx_config ,"CONFIG_HAVE_CXXINITIALIZE 1", $(NUTTX_CONFIG_H)) +ifeq ("$(ENABLE_CXXINITIALIZE)",$(nuttx_config_2true)) +SRCS += ../../../modules/systemlib/up_cxxinitialize.c +endif + MAXOPTIMIZATION = -Os diff --git a/src/drivers/boards/px4io-v2/module.mk b/src/drivers/boards/px4io-v2/module.mk index 3f0e9a0b3..5613ad405 100644 --- a/src/drivers/boards/px4io-v2/module.mk +++ b/src/drivers/boards/px4io-v2/module.mk @@ -5,4 +5,10 @@ SRCS = px4iov2_init.c \ px4iov2_pwm_servo.c +ENABLE_CXXINITIALIZE=$(call check_nuttx_config ,"CONFIG_HAVE_CXX 1", $(NUTTX_CONFIG_H)) +ENABLE_CXXINITIALIZE+=$(call check_nuttx_config ,"CONFIG_HAVE_CXXINITIALIZE 1", $(NUTTX_CONFIG_H)) +ifeq ("$(ENABLE_CXXINITIALIZE)",$(nuttx_config_2true)) +SRCS += ../../../modules/systemlib/up_cxxinitialize.c +endif + MAXOPTIMIZATION = -Os diff --git a/src/modules/px4iofirmware/px4io.c b/src/modules/px4iofirmware/px4io.c index c31342262..a2f8965bd 100644 --- a/src/modules/px4iofirmware/px4io.c +++ b/src/modules/px4iofirmware/px4io.c @@ -226,9 +226,20 @@ calculate_fw_crc(void) int user_start(int argc, char *argv[]) { +#if defined(CONFIG_HAVE_CXX) && defined(CONFIG_HAVE_CXXINITIALIZE) + /* run C++ ctors before we go any further */ + up_cxxinitialize(); +# if defined(CONFIG_EXAMPLES_NSH_CXXINITIALIZE) +# error CONFIG_EXAMPLES_NSH_CXXINITIALIZE Must not be defined! Use CONFIG_HAVE_CXX and CONFIG_HAVE_CXXINITIALIZE. +# endif + +#else +# error platform is dependent on c++ both CONFIG_HAVE_CXX and CONFIG_HAVE_CXXINITIALIZE must be defined. +#endif + /* reset all to zero */ memset(&system_state, 0, sizeof(system_state)); |