diff --git a/.gitmodules b/.gitmodules index 630eac1ccd..303acdd8cb 100644 --- a/.gitmodules +++ b/.gitmodules @@ -49,11 +49,11 @@ [submodule "platforms/nuttx/NuttX/nuttx"] path = platforms/nuttx/NuttX/nuttx url = https://github.com/PX4/NuttX.git - branch = px4_firmware_nuttx-7.22+ + branch = px4_firmware_nuttx-7.28+ [submodule "platforms/nuttx/NuttX/apps"] path = platforms/nuttx/NuttX/apps url = https://github.com/PX4/NuttX-apps.git - branch = px4_firmware_nuttx-7.22+ + branch = px4_firmware_nuttx-7.28+ [submodule "cmake/configs/uavcan_board_ident"] path = cmake/configs/uavcan_board_ident url = https://github.com/PX4/uavcan_board_ident.git diff --git a/platforms/nuttx/NuttX/CMakeLists.txt b/platforms/nuttx/NuttX/CMakeLists.txt index 71c17fa763..7fa17e0ba9 100644 --- a/platforms/nuttx/NuttX/CMakeLists.txt +++ b/platforms/nuttx/NuttX/CMakeLists.txt @@ -32,10 +32,8 @@ file(GLOB_RECURSE copy_apps_files LIST_DIRECTORIES false ${CMAKE_CURRENT_SOURCE_DIR}/apps/*) -set(NUTTX_DIR ${CMAKE_CURRENT_BINARY_DIR}/nuttx) set(NUTTX_CONFIG_DIR ${PX4_BOARD_DIR}/nuttx-config) -set(NUTTX_CONFIGS_DIR ${PX4_SOURCE_DIR}/platforms/nuttx/nuttx-configs) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Make.defs.in ${NUTTX_DIR}/Make.defs) # copy nuttx to build directory @@ -61,24 +59,79 @@ add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/apps_copy.stamp ) set(APPS_DIR ${CMAKE_CURRENT_BINARY_DIR}/apps) +# If the board provides a Kconfig Use it or create an empty one +if(EXISTS ${NUTTX_CONFIG_DIR}/Kconfig) + add_custom_command( + OUTPUT ${NUTTX_DIR}/configs/dummy/Kconfig + COMMAND ${CMAKE_COMMAND} -E copy ${NUTTX_CONFIG_DIR}/Kconfig ${NUTTX_DIR}/configs/dummy/Kconfig + DEPENDS + ${CMAKE_CURRENT_BINARY_DIR}/nuttx_copy.stamp + ${CMAKE_CURRENT_BINARY_DIR}/apps_copy.stamp + ) +else() + add_custom_command( + OUTPUT ${NUTTX_DIR}/configs/dummy/Kconfig + COMMAND ${CMAKE_COMMAND} -E touch ${NUTTX_DIR}/configs/dummy/Kconfig + DEPENDS + ${CMAKE_CURRENT_BINARY_DIR}/nuttx_copy.stamp + ${CMAKE_CURRENT_BINARY_DIR}/apps_copy.stamp + ) +endif() + # copy PX4 board config into nuttx -add_custom_command( - OUTPUT ${NUTTX_DIR}/.config - COMMAND ${CMAKE_COMMAND} -E copy ${NUTTX_CONFIG_DIR}/${NUTTX_CONFIG}/defconfig ${NUTTX_DIR}/.config - COMMAND ${CMAKE_COMMAND} -E remove -f ${NUTTX_DIR}/include/nuttx/config.h - COMMAND ${CMAKE_COMMAND} -E remove_directory ${NUTTX_DIR}/configs/${PX4_BOARD} - COMMAND ${CMAKE_COMMAND} -E copy_directory ${NUTTX_CONFIG_DIR}/ ${NUTTX_DIR}/configs/${PX4_BOARD}/ - COMMAND ${CMAKE_COMMAND} -E make_directory ${NUTTX_DIR}/configs/${PX4_BOARD}/src - COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/nsh_romfsimg.h ${NUTTX_DIR}/configs/${PX4_BOARD}/include - DEPENDS - ${NUTTX_CONFIG_DIR}/${NUTTX_CONFIG}/defconfig - ${NUTTX_CONFIG_DIR}/include/board.h - ${NUTTX_CONFIG_DIR}/scripts/ld.script - ${CMAKE_CURRENT_BINARY_DIR}/nuttx_copy.stamp - ${CMAKE_CURRENT_BINARY_DIR}/apps_copy.stamp - WORKING_DIRECTORY ${NUTTX_DIR}/tools - COMMENT "Copying NuttX config ${NUTTX_CONFIG} and configuring" - ) +file(STRINGS ${NUTTX_CONFIG_DIR}/${NUTTX_CONFIG}/defconfig config_expanded REGEX "# Automatically generated file; DO NOT EDIT.") + +if ("x${config_expanded}" STREQUAL "x") + # copy PX4 board Compressed config into nuttx and inflate it + add_custom_command( + OUTPUT + ${NUTTX_DIR}/.config + ${NUTTX_DIR}/arch/arm/include/math.h + COMMAND ${CMAKE_COMMAND} -E copy ${NUTTX_CONFIG_DIR}/${NUTTX_CONFIG}/defconfig ${NUTTX_DIR}/.config + COMMAND kconfig-tweak --set-str CONFIG_APPS_DIR "../apps" + COMMAND ${CMAKE_COMMAND} -E remove -f ${NUTTX_DIR}/include/nuttx/config.h + COMMAND ${CMAKE_COMMAND} -E remove_directory ${NUTTX_DIR}/configs/${PX4_BOARD} + COMMAND ${CMAKE_COMMAND} -E copy_directory ${NUTTX_CONFIG_DIR}/ ${CMAKE_CURRENT_BINARY_DIR}/nuttx-config + COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/nuttx-config/src + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/math.h ${NUTTX_DIR}/arch/arm/include/ # copy arm math.h into NuttX source + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/nsh_romfsimg.h ${CMAKE_CURRENT_BINARY_DIR}/nuttx-config/include/ + COMMAND make --no-print-directory --silent -C ${NUTTX_DIR} CONFIG_ARCH_BOARD_CUSTOM=y olddefconfig + DEPENDS + ${NUTTX_CONFIG_DIR}/${NUTTX_CONFIG}/defconfig + ${NUTTX_CONFIG_DIR}/include/board.h + ${NUTTX_CONFIG_DIR}/scripts/ld.script + ${NUTTX_DIR}/configs/dummy/Kconfig + ${CMAKE_CURRENT_SOURCE_DIR}/math.h + ${CMAKE_CURRENT_SOURCE_DIR}/nsh_romfsimg.h + WORKING_DIRECTORY ${NUTTX_DIR} + COMMENT "Copying NuttX config ${NUTTX_CONFIG} and configuring" + ) +else() + # copy PX4 board config into nuttx + add_custom_command( + OUTPUT + ${NUTTX_DIR}/.config + ${NUTTX_DIR}/arch/arm/include/math.h + COMMAND ${CMAKE_COMMAND} -E copy ${NUTTX_CONFIG_DIR}/${NUTTX_CONFIG}/defconfig ${NUTTX_DIR}/.config + COMMAND ${CMAKE_COMMAND} -E remove -f ${NUTTX_DIR}/include/nuttx/config.h + COMMAND ${CMAKE_COMMAND} -E remove_directory ${NUTTX_DIR}/configs/${PX4_BOARD} + COMMAND ${CMAKE_COMMAND} -E copy_directory ${NUTTX_CONFIG_DIR}/ ${CMAKE_CURRENT_BINARY_DIR}/nuttx-config + COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/nuttx-config/src + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/math.h ${NUTTX_DIR}/arch/arm/include/ # copy arm math.h into NuttX source + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/nsh_romfsimg.h ${CMAKE_CURRENT_BINARY_DIR}/nuttx-config/include/ + DEPENDS + ${NUTTX_CONFIG_DIR}/${NUTTX_CONFIG}/defconfig + ${NUTTX_CONFIG_DIR}/include/board.h + ${NUTTX_CONFIG_DIR}/scripts/ld.script + ${CMAKE_CURRENT_BINARY_DIR}/nuttx_copy.stamp + ${CMAKE_CURRENT_BINARY_DIR}/apps_copy.stamp + ${NUTTX_DIR}/configs/dummy/Kconfig + ${CMAKE_CURRENT_SOURCE_DIR}/math.h + ${CMAKE_CURRENT_SOURCE_DIR}/nsh_romfsimg.h + WORKING_DIRECTORY ${NUTTX_DIR} + COMMENT "Copying NuttX uncompressed config ${NUTTX_CONFIG} and configuring" + ) +endif() # verbose build settings (V=1 or VERBOSE=1) option(PX4_NUTTX_VERBOSE "PX4 NuttX verbose build" off) @@ -196,8 +249,8 @@ add_nuttx_dir(configs configs y -D__KERNEL__) add_nuttx_dir(drivers drivers y -D__KERNEL__) add_nuttx_dir(fs fs y -D__KERNEL__) add_nuttx_dir(sched sched y -D__KERNEL__) -add_nuttx_dir(c libc n "") -add_nuttx_dir(cxx libxx n "") +add_nuttx_dir(c libs/libc n "") +add_nuttx_dir(xx libs/libxx n "") add_nuttx_dir(mm mm n "") if (CONFIG_NET) @@ -208,18 +261,27 @@ endif() add_custom_target(oldconfig COMMAND make --no-print-directory --silent -C ${NUTTX_DIR} CONFIG_ARCH_BOARD=${PX4_BOARD} oldconfig COMMAND cp ${NUTTX_DIR}/.config ${NUTTX_CONFIG_DIR}/${NUTTX_CONFIG}/defconfig - COMMAND ${PX4_SOURCE_DIR}/platforms/nuttx/NuttX/tools/nuttx_defconf_tool.sh ${NUTTX_CONFIG_DIR}/${NUTTX_CONFIG}/defconfig DEPENDS ${NUTTX_DIR}/.config WORKING_DIRECTORY ${NUTTX_DIR} COMMENT "Running NuttX make oldconfig for ${NUTTX_CONFIG}" USES_TERMINAL ) +# olddefconfig helper +add_custom_target(olddefconfig + COMMAND make --no-print-directory --silent -C ${NUTTX_DIR} CONFIG_ARCH_BOARD=${PX4_BOARD} olddefconfig + COMMAND cp ${NUTTX_DIR}/.config ${NUTTX_CONFIG_DIR}/${NUTTX_CONFIG}/defconfig + DEPENDS ${NUTTX_DIR}/.config + WORKING_DIRECTORY ${NUTTX_DIR} + COMMENT "Running NuttX make olddefconfig for ${NUTTX_CONFIG}" + USES_TERMINAL + ) + + # menuconfig helper add_custom_target(menuconfig COMMAND make --no-print-directory --silent -C ${NUTTX_DIR} CONFIG_ARCH_BOARD=${PX4_BOARD} menuconfig COMMAND cp ${NUTTX_DIR}/.config ${NUTTX_CONFIG_DIR}/${NUTTX_CONFIG}/defconfig - COMMAND cd ${PX4_SOURCE_DIR} && platforms/nuttx/NuttX/tools/nuttx_defconf_tool.sh ${NUTTX_CONFIG_DIR}/${NUTTX_CONFIG}/defconfig DEPENDS ${NUTTX_DIR}/.config WORKING_DIRECTORY ${NUTTX_DIR} COMMENT "Running NuttX make menuconfig for ${NUTTX_CONFIG}" @@ -235,3 +297,46 @@ add_custom_target(qconfig COMMENT "Running NuttX make qconfig for ${NUTTX_CONFIG}" USES_TERMINAL ) + +# savedefconfig helper needs apps Kconfig +add_custom_target(apps_kconfig + COMMAND + TOPDIR=${NUTTX_APPS_DIR} make ${nuttx_build_options} --no-print-directory -C platform board TOPDIR="${NUTTX_DIR}" APPDIR="${NUTTX_APPS_DIR}" + COMMAND + TOPDIR=${NUTTX_APPS_DIR} make ${nuttx_build_options} --no-print-directory Kconfig ${nuttx_build_output} + DEPENDS + ${NUTTX_DIR}/configs/dummy/Kconfig + WORKING_DIRECTORY ${NUTTX_APPS_DIR} + COMMENT "Running Kconfig Build on Apps" +) + +# savedefconfig helper +add_custom_target(savedefconfig + COMMAND + APPSDIR=${NUTTX_APPS_DIR} kconfig-conf --savedefconfig defconfig.tmp ${NUTTX_DIR}/Kconfig + COMMAND + sed -i -e "/CONFIG_APPS_DIR=/d" defconfig.tmp # remove CONFIG_APPS_DIR + COMMAND + grep "CONFIG_ARCH=" .config >> defconfig.tmp || true # preserve CONFIG_ARCH= + COMMAND + grep "^CONFIG_ARCH_CHIP_" .config >> defconfig.tmp || true # preserve CONFIG_ARCH_CHIP_ + COMMAND + grep "^CONFIG_ARCH_CHIP=" .config >> defconfig.tmp || true # PX4 Build preserve CONFIG_ARCH_CHIP= + COMMAND + grep "^CONFIG_ARCH_FAMILY=" .config >> defconfig.tmp || true # PX4 Build preserve CONFIG_ARCH_FAMILY + COMMAND + grep "CONFIG_ARCH_BOARD=" .config >> defconfig.tmp || true # preserve CONFIG_ARCH_BOARD + COMMAND + grep "^CONFIG_ARCH_CUSTOM" .config >> defconfig.tmp || true # preserve CONFIG_ARCH_CUSTOM + COMMAND + cat defconfig.tmp | LC_ALL=C sort | uniq > defconfig.updated # sort and save back to original defconfig + COMMAND + ${CMAKE_COMMAND} -E copy_if_different defconfig.updated ${NUTTX_CONFIG_DIR}/${NUTTX_CONFIG}/defconfig + COMMAND + ${CMAKE_COMMAND} -E remove -f defconfig.tmp defconfig.updated # cleanup + DEPENDS + apps_kconfig + ${NUTTX_DIR}/.config + COMMENT "Compressing .config and saving back to ${NUTTX_CONFIG_DIR}/${NUTTX_CONFIG}/defconfig" + WORKING_DIRECTORY ${NUTTX_DIR} +) diff --git a/platforms/nuttx/NuttX/Make.defs.in b/platforms/nuttx/NuttX/Make.defs.in index 52651c7dae..0212ec6cd0 100644 --- a/platforms/nuttx/NuttX/Make.defs.in +++ b/platforms/nuttx/NuttX/Make.defs.in @@ -115,6 +115,7 @@ CXXFLAGS = $(ARCHXXINCLUDES) \ -fno-builtin \ -fno-exceptions \ -fno-rtti \ + -nostdinc++ \ -Wno-double-promotion \ -Wno-missing-declarations diff --git a/platforms/nuttx/NuttX/apps b/platforms/nuttx/NuttX/apps index d19cc40bdc..6fb399fd65 160000 --- a/platforms/nuttx/NuttX/apps +++ b/platforms/nuttx/NuttX/apps @@ -1 +1 @@ -Subproject commit d19cc40bdca5416a0891798f4b13bfa14f07abeb +Subproject commit 6fb399fd65aacd8399ea1d11e397fda37ac01cde diff --git a/platforms/nuttx/NuttX/include/cxx/new b/platforms/nuttx/NuttX/include/cxx/new new file mode 100644 index 0000000000..40774777f0 --- /dev/null +++ b/platforms/nuttx/NuttX/include/cxx/new @@ -0,0 +1,37 @@ +/**************************************************************************** + * + * Copyright (C) 2019 PX4 Development Team. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name PX4 nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +inline void* operator new (std::size_t, void* ptr) { return ptr; } +inline void* operator new[](std::size_t, void* ptr) { return ptr; } +inline void operator delete (void*, void*) {} +inline void operator delete[](void*, void*) {} diff --git a/platforms/nuttx/NuttX/math.h b/platforms/nuttx/NuttX/math.h new file mode 100644 index 0000000000..9e888a6502 --- /dev/null +++ b/platforms/nuttx/NuttX/math.h @@ -0,0 +1,579 @@ +#ifndef _MATH_H_ + +#define _MATH_H_ + +#include +#include "_ansi.h" + +_BEGIN_STD_C + +/* Natural log of 2 */ +#define _M_LN2 0.693147180559945309417 + +#if defined(__GNUC__) && \ + ( (__GNUC__ >= 4) || \ + ( (__GNUC__ >= 3) && defined(__GNUC_MINOR__) && (__GNUC_MINOR__ >= 3) ) ) + + /* gcc >= 3.3 implicitly defines builtins for HUGE_VALx values. */ + +# ifndef HUGE_VAL +# define HUGE_VAL (__builtin_huge_val()) +# endif + +# ifndef HUGE_VALF +# define HUGE_VALF (__builtin_huge_valf()) +# endif + +# ifndef HUGE_VALL +# define HUGE_VALL (__builtin_huge_vall()) +# endif + +# ifndef INFINITY +# define INFINITY (__builtin_inff()) +# endif + +# ifndef NAN +# define NAN (__builtin_nanf("")) +# endif + +#else /* !gcc >= 3.3 */ + + /* No builtins. Use fixed defines instead. (All 3 HUGE plus the INFINITY + * * and NAN macros are required to be constant expressions. Using a variable-- + * * even a static const--does not meet this requirement, as it cannot be + * * evaluated at translation time.) + * * The infinities are done using numbers that are far in excess of + * * something that would be expected to be encountered in a floating-point + * * implementation. (A more certain way uses values from float.h, but that is + * * avoided because system includes are not supposed to include each other.) + * * This method might produce warnings from some compilers. (It does in + * * newer GCCs, but not for ones that would hit this #else.) If this happens, + * * please report details to the Newlib mailing list. */ + + #ifndef HUGE_VAL + #define HUGE_VAL (1.0e999999999) + #endif + + #ifndef HUGE_VALF + #define HUGE_VALF (1.0e999999999F) + #endif + + #if !defined(HUGE_VALL) && defined(_HAVE_LONG_DOUBLE) + #define HUGE_VALL (1.0e999999999L) + #endif + + #if !defined(INFINITY) + #define INFINITY (HUGE_VALF) + #endif + + #if !defined(NAN) + #if defined(__GNUC__) && defined(__cplusplus) + /* Exception: older g++ versions warn about the divide by 0 used in the + * * normal case (even though older gccs do not). This trick suppresses the + * * warning, but causes errors for plain gcc, so is only used in the one + * * special case. */ + static const union { __ULong __i[1]; float __d; } __Nanf = {0x7FC00000}; + #define NAN (__Nanf.__d) + #else + #define NAN (0.0F/0.0F) + #endif + #endif + +#endif /* !gcc >= 3.3 */ + +/* Reentrant ANSI C functions. */ + +#ifndef __math_68881 +extern double atan (double); +extern double cos (double); +extern double sin (double); +extern double tan (double); +extern double tanh (double); +extern double frexp (double, int *); +extern double modf (double, double *); +extern double ceil (double); +extern double fabs (double); +extern double floor (double); +#endif /* ! defined (__math_68881) */ + +/* Non reentrant ANSI C functions. */ + +#ifndef _REENT_ONLY +#ifndef __math_68881 +extern double acos (double); +extern double asin (double); +extern double atan2 (double, double); +extern double cosh (double); +extern double sinh (double); +extern double exp (double); +extern double ldexp (double, int); +extern double log (double); +extern double log10 (double); +extern double pow (double, double); +extern double sqrt (double); +extern double fmod (double, double); +#endif /* ! defined (__math_68881) */ +#endif /* ! defined (_REENT_ONLY) */ + +#if !defined(__STRICT_ANSI__) || defined(__cplusplus) || __STDC_VERSION__ >= 199901L + +/* ISO C99 types and macros. */ + +#ifndef FLT_EVAL_METHOD +#define FLT_EVAL_METHOD 0 +typedef float float_t; +typedef double double_t; +#endif /* FLT_EVAL_METHOD */ + +#define FP_NAN 0 +#define FP_INFINITE 1 +#define FP_ZERO 2 +#define FP_SUBNORMAL 3 +#define FP_NORMAL 4 + +#ifndef FP_ILOGB0 +# define FP_ILOGB0 (-INT_MAX) +#endif +#ifndef FP_ILOGBNAN +# define FP_ILOGBNAN INT_MAX +#endif + +#ifndef MATH_ERRNO +# define MATH_ERRNO 1 +#endif +#ifndef MATH_ERREXCEPT +# define MATH_ERREXCEPT 2 +#endif +#ifndef math_errhandling +# define math_errhandling MATH_ERRNO +#endif + +extern int __isinff (float x); +extern int __isinfd (double x); +extern int __isnanf (float x); +extern int __isnand (double x); +extern int __fpclassifyf (float x); +extern int __fpclassifyd (double x); +extern int __signbitf (float x); +extern int __signbitd (double x); + +#define fpclassify(__x) \ + ((sizeof(__x) == sizeof(float)) ? __fpclassifyf(__x) : \ + __fpclassifyd(__x)) + +#ifndef isfinite + #define isfinite(__y) \ + (__extension__ ({int __cy = fpclassify(__y); \ + __cy != FP_INFINITE && __cy != FP_NAN;})) +#endif + +/* Note: isinf and isnan were once functions in newlib that took double + * * arguments. C99 specifies that these names are reserved for macros + * * supporting multiple floating point types. Thus, they are + * * now defined as macros. Implementations of the old functions + * * taking double arguments still exist for compatibility purposes + * * (prototypes for them are in ). */ +#ifndef isinf + #define isinf(y) (fpclassify(y) == FP_INFINITE) +#endif + +#ifndef isnan + #define isnan(y) (fpclassify(y) == FP_NAN) +#endif + +#define isnormal(y) (fpclassify(y) == FP_NORMAL) +#define signbit(__x) \ + ((sizeof(__x) == sizeof(float)) ? __signbitf(__x) : \ + __signbitd(__x)) + +#define isgreater(x,y) \ + (__extension__ ({__typeof__(x) __x = (x); __typeof__(y) __y = (y); \ + !isunordered(__x,__y) && (__x > __y);})) +#define isgreaterequal(x,y) \ + (__extension__ ({__typeof__(x) __x = (x); __typeof__(y) __y = (y); \ + !isunordered(__x,__y) && (__x >= __y);})) +#define isless(x,y) \ + (__extension__ ({__typeof__(x) __x = (x); __typeof__(y) __y = (y); \ + !isunordered(__x,__y) && (__x < __y);})) +#define islessequal(x,y) \ + (__extension__ ({__typeof__(x) __x = (x); __typeof__(y) __y = (y); \ + !isunordered(__x,__y) && (__x <= __y);})) +#define islessgreater(x,y) \ + (__extension__ ({__typeof__(x) __x = (x); __typeof__(y) __y = (y); \ + !isunordered(__x,__y) && (__x < __y || __x > __y);})) + +#define isunordered(a,b) \ + (__extension__ ({__typeof__(a) __a = (a); __typeof__(b) __b = (b); \ + fpclassify(__a) == FP_NAN || fpclassify(__b) == FP_NAN;})) + +/* Non ANSI double precision functions. */ + +extern double infinity (void); +extern double nan (const char *); +extern int finite (double); +extern double copysign (double, double); +extern double logb (double); +extern int ilogb (double); + +extern double asinh (double); +extern double cbrt (double); +extern double nextafter (double, double); +extern double rint (double); +extern double scalbn (double, int); + +extern double exp2 (double); +extern double scalbln (double, long int); +extern double tgamma (double); +extern double nearbyint (double); +extern long int lrint (double); +extern long long int llrint (double); +extern double round (double); +extern long int lround (double); +extern long long int llround (double); +extern double trunc (double); +extern double remquo (double, double, int *); +extern double fdim (double, double); +extern double fmax (double, double); +extern double fmin (double, double); +extern double fma (double, double, double); + +#ifndef __math_68881 +extern double log1p (double); +extern double expm1 (double); +#endif /* ! defined (__math_68881) */ + +#ifndef _REENT_ONLY +extern double acosh (double); +extern double atanh (double); +extern double remainder (double, double); +extern double gamma (double); +extern double lgamma (double); +extern double erf (double); +extern double erfc (double); +extern double log2 (double); + +#ifndef __math_68881 +extern double hypot (double, double); +#endif + +#endif /* ! defined (_REENT_ONLY) */ + +/* Single precision versions of ANSI functions. */ + +extern float atanf (float); +extern float cosf (float); +extern float sinf (float); +extern float tanf (float); +extern float tanhf (float); +extern float frexpf (float, int *); +extern float modff (float, float *); +extern float ceilf (float); +extern float fabsf (float); +extern float floorf (float); + +#ifndef _REENT_ONLY +extern float acosf (float); +extern float asinf (float); +extern float atan2f (float, float); +extern float coshf (float); +extern float sinhf (float); +extern float expf (float); +extern float ldexpf (float, int); +extern float logf (float); +extern float log10f (float); +extern float powf (float, float); +extern float sqrtf (float); +extern float fmodf (float, float); +#endif /* ! defined (_REENT_ONLY) */ + +/* Other single precision functions. */ + +extern float exp2f (float); +extern float scalblnf (float, long int); +extern float tgammaf (float); +extern float nearbyintf (float); +extern long int lrintf (float); +extern long long llrintf (float); +extern float roundf (float); +extern long int lroundf (float); +extern long long int llroundf (float); +extern float truncf (float); +extern float remquof (float, float, int *); +extern float fdimf (float, float); +extern float fmaxf (float, float); +extern float fminf (float, float); +extern float fmaf (float, float, float); + +extern float infinityf (void); +extern float nanf (const char *); +extern int finitef (float); +extern float copysignf (float, float); +extern float logbf (float); +extern int ilogbf (float); + +extern float asinhf (float); +extern float cbrtf (float); +extern float nextafterf (float, float); +extern float rintf (float); +extern float scalbnf (float, int); +extern float log1pf (float); +extern float expm1f (float); + +#ifndef _REENT_ONLY +extern float acoshf (float); +extern float atanhf (float); +extern float remainderf (float, float); +extern float gammaf (float); +extern float lgammaf (float); +extern float erff (float); +extern float erfcf (float); +extern float log2f (float); +extern float hypotf (float, float); +#endif /* ! defined (_REENT_ONLY) */ + +/* On platforms where long double equals double. */ +#ifdef _LDBL_EQ_DBL +/* Reentrant ANSI C functions. */ +#ifndef __math_68881 +extern long double atanl (long double); +extern long double cosl (long double); +extern long double sinl (long double); +extern long double tanl (long double); +extern long double tanhl (long double); +extern long double frexpl (long double value, int *); +extern long double modfl (long double, long double *); +extern long double ceill (long double); +extern long double fabsl (long double); +extern long double floorl (long double); +extern long double log1pl (long double); +extern long double expm1l (long double); +#endif /* ! defined (__math_68881) */ +/* Non reentrant ANSI C functions. */ +#ifndef _REENT_ONLY +#ifndef __math_68881 +extern long double acosl (long double); +extern long double asinl (long double); +extern long double atan2l (long double, long double); +extern long double coshl (long double); +extern long double sinhl (long double); +extern long double expl (long double); +extern long double ldexpl (long double, int); +extern long double logl (long double); +extern long double log2l (long double); +extern long double log10l (long double); +extern long double powl (long double, long double); +extern long double sqrtl (long double); +extern long double fmodl (long double, long double); +extern long double hypotl (long double, long double); +#endif /* ! defined (__math_68881) */ +#endif /* ! defined (_REENT_ONLY) */ +extern long double copysignl (long double, long double); +extern long double nanl (const char *); +extern int ilogbl (long double); +extern long double asinhl (long double); +extern long double cbrtl (long double); +extern long double nextafterl (long double, long double); +extern long double rintl (long double); +extern long double scalbnl (long double, int); +extern long double exp2l (long double); +extern long double scalblnl (long double, long); +extern long double tgammal (long double); +extern long double nearbyintl (long double); +extern long int lrintl (long double); +extern long long int llrintl (long double); +extern long double roundl (long double); +extern long lroundl (long double); +extern long long int llroundl (long double); +extern long double truncl (long double); +extern long double remquol (long double, long double, int *); +extern long double fdiml (long double, long double); +extern long double fmaxl (long double, long double); +extern long double fminl (long double, long double); +extern long double fmal (long double, long double, long double); +#ifndef _REENT_ONLY +extern long double acoshl (long double); +extern long double atanhl (long double); +extern long double remainderl (long double, long double); +extern long double lgammal (long double); +extern long double erfl (long double); +extern long double erfcl (long double); +#endif /* ! defined (_REENT_ONLY) */ +#else /* !_LDBL_EQ_DBL */ +#ifdef __i386__ +/* Other long double precision functions. */ +extern _LONG_DOUBLE rintl (_LONG_DOUBLE); +extern long int lrintl (_LONG_DOUBLE); +extern long long llrintl (_LONG_DOUBLE); +#endif /* __i386__ */ +#endif /* !_LDBL_EQ_DBL */ + +#endif /* !defined (__STRICT_ANSI__) || defined(__cplusplus) || __STDC_VERSION__ >= 199901L */ + +#if !defined (__STRICT_ANSI__) || defined(__cplusplus) + +extern double drem (double, double); +extern void sincos (double, double *, double *); +extern double gamma_r (double, int *); +extern double lgamma_r (double, int *); + +extern double y0 (double); +extern double y1 (double); +extern double yn (int, double); +extern double j0 (double); +extern double j1 (double); +extern double jn (int, double); + +extern float dremf (float, float); +extern void sincosf (float, float *, float *); +extern float gammaf_r (float, int *); +extern float lgammaf_r (float, int *); + +extern float y0f (float); +extern float y1f (float); +extern float ynf (int, float); +extern float j0f (float); +extern float j1f (float); +extern float jnf (int, float); + +/* GNU extensions */ +# ifndef exp10 +extern double exp10 (double); +# endif +# ifndef pow10 +extern double pow10 (double); +# endif +# ifndef exp10f +extern float exp10f (float); +# endif +# ifndef pow10f +extern float pow10f (float); +# endif + +#endif /* !defined (__STRICT_ANSI__) || defined(__cplusplus) */ + +#ifndef __STRICT_ANSI__ + +/* The gamma functions use a global variable, signgam. */ +#ifndef _REENT_ONLY +#define signgam (*__signgam()) +extern int *__signgam (void); +#endif /* ! defined (_REENT_ONLY) */ + +#define __signgam_r(ptr) _REENT_SIGNGAM(ptr) + +/* The exception structure passed to the matherr routine. */ +/* We have a problem when using C++ since `exception' is a reserved + * name in C++. */ +#ifdef __cplusplus +struct __exception +#else +struct exception +#endif +{ + int type; + char *name; + double arg1; + double arg2; + double retval; + int err; +}; + +#ifdef __cplusplus +extern int matherr (struct __exception *e); +#else +extern int matherr (struct exception *e); +#endif + +/* Values for the type field of struct exception. */ + +#define DOMAIN 1 +#define SING 2 +#define OVERFLOW 3 +#define UNDERFLOW 4 +#define TLOSS 5 +#define PLOSS 6 + +/* Useful constants. */ + +#define MAXFLOAT 3.40282347e+38F + +#define M_E 2.7182818284590452354 +#define M_LOG2E 1.4426950408889634074 +#define M_LOG10E 0.43429448190325182765 +#define M_LN2 _M_LN2 +#define M_LN10 2.30258509299404568402 +#define M_PI 3.14159265358979323846 +#define M_TWOPI (M_PI * 2.0) +#define M_PI_2 1.57079632679489661923 +#define M_PI_4 0.78539816339744830962 +#define M_3PI_4 2.3561944901923448370E0 +#define M_SQRTPI 1.77245385090551602792981 +#define M_1_PI 0.31830988618379067154 +#define M_2_PI 0.63661977236758134308 +#define M_2_SQRTPI 1.12837916709551257390 +#define M_DEG_TO_RAD 0.01745329251994 +#define M_RAD_TO_DEG 57.2957795130823 +#define M_SQRT2 1.41421356237309504880 +#define M_SQRT1_2 0.70710678118654752440 +#define M_LN2LO 1.9082149292705877000E-10 +#define M_LN2HI 6.9314718036912381649E-1 +#define M_SQRT3 1.73205080756887719000 +#define M_IVLN10 0.43429448190325182765 /* 1 / log(10) */ +#define M_LOG2_E _M_LN2 +#define M_INVLN2 1.4426950408889633870E0 /* 1 / log(2) */ + + +#define M_E_F 2.7182818284590452354f +#define M_LOG2E_F 1.4426950408889634074f +#define M_LOG10E_F 0.43429448190325182765f +#define M_LN2_F _M_LN2_F +#define M_LN10_F 2.30258509299404568402f +#define M_PI_F 3.14159265358979323846f +#define M_TWOPI_F (M_PI_F * 2.0f) +#define M_PI_2_F 1.57079632679489661923f +#define M_PI_4_F 0.78539816339744830962f +#define M_3PI_4_F 2.3561944901923448370E0f +#define M_SQRTPI_F 1.77245385090551602792981f +#define M_1_PI_F 0.31830988618379067154f +#define M_2_PI_F 0.63661977236758134308f +#define M_2_SQRTPI_F 1.12837916709551257390f +#define M_DEG_TO_RAD_F 0.01745329251994f +#define M_RAD_TO_DEG_F 57.2957795130823f +#define M_SQRT2_F 1.41421356237309504880f +#define M_SQRT1_2_F 0.70710678118654752440f +#define M_LN2LO_F 1.9082149292705877000E-10f +#define M_LN2HI_F 6.9314718036912381649E-1f +#define M_SQRT3_F 1.73205080756887719000f +#define M_IVLN10_F 0.43429448190325182765f /* 1 / log(10) */ +#define M_LOG2_E_F _M_LN2_F +#define M_INVLN2_F 1.4426950408889633870E0f /* 1 / log(2) */ + +/* Global control over fdlibm error handling. */ + +enum __fdlibm_version +{ + __fdlibm_ieee = -1, + __fdlibm_svid, + __fdlibm_xopen, + __fdlibm_posix +}; + +#define _LIB_VERSION_TYPE enum __fdlibm_version +#define _LIB_VERSION __fdlib_version + +extern __IMPORT _LIB_VERSION_TYPE _LIB_VERSION; + +#define _IEEE_ __fdlibm_ieee +#define _SVID_ __fdlibm_svid +#define _XOPEN_ __fdlibm_xopen +#define _POSIX_ __fdlibm_posix + +#endif /* ! defined (__STRICT_ANSI__) */ + +_END_STD_C + +#ifdef __FAST_MATH__ +#include +#endif + +#endif /* _MATH_H_ */ diff --git a/platforms/nuttx/NuttX/nuttx b/platforms/nuttx/NuttX/nuttx index c225d4a691..a5682a6335 160000 --- a/platforms/nuttx/NuttX/nuttx +++ b/platforms/nuttx/NuttX/nuttx @@ -1 +1 @@ -Subproject commit c225d4a691ef4572839b19635a84f2d9bf07ea74 +Subproject commit a5682a6335b7201bce75b66aa994314342bb4463 diff --git a/platforms/nuttx/cmake/px4_impl_os.cmake b/platforms/nuttx/cmake/px4_impl_os.cmake index 3bbfbfb51d..6501d403a2 100644 --- a/platforms/nuttx/cmake/px4_impl_os.cmake +++ b/platforms/nuttx/cmake/px4_impl_os.cmake @@ -53,7 +53,9 @@ function(px4_os_add_flags) include_directories(BEFORE SYSTEM ${PX4_BINARY_DIR}/NuttX/nuttx/include + ${PX4_BINARY_DIR}/NuttX/nuttx/include/cxx + ${PX4_SOURCE_DIR}/platforms/nuttx/NuttX/include/cxx ) include_directories( @@ -64,6 +66,12 @@ function(px4_os_add_flags) ${PX4_BINARY_DIR}/NuttX/apps/include ) + # NuttX's disables inline below C99 (comiler.h), but __STDC_VERSION__ isn't set for C++ + add_compile_options($<$:-D__STDC_VERSION__=199901L>) + + # prevent using the toolchain's std c++ library + add_compile_options($<$:-nostdinc++>) + add_definitions( -D__PX4_NUTTX -D__DF_NUTTX diff --git a/src/drivers/uavcan/CMakeLists.txt b/src/drivers/uavcan/CMakeLists.txt index 57275a6ca4..ac12dc5f67 100644 --- a/src/drivers/uavcan/CMakeLists.txt +++ b/src/drivers/uavcan/CMakeLists.txt @@ -36,7 +36,6 @@ px4_add_git_submodule(TARGET git_uavcan PATH "libuavcan") set(UAVCAN_USE_CPP03 ON CACHE BOOL "uavcan cpp03") if(CONFIG_ARCH_CHIP) - if (${CONFIG_ARCH_CHIP} MATCHES "kinetis") set(UAVCAN_PLATFORM "kinetis") set(UAVCAN_TIMER 1) @@ -53,14 +52,15 @@ endif() string(TOUPPER "${PX4_PLATFORM}" OS_UPPER) string(TOUPPER "${UAVCAN_PLATFORM}" UAVCAN_PLATFORM_UPPER) add_definitions( + -DUAVCAN_${UAVCAN_PLATFORM_UPPER}_${OS_UPPER}=1 + -DUAVCAN_${UAVCAN_PLATFORM_UPPER}_NUM_IFACES=${config_uavcan_num_ifaces} + -DUAVCAN_${UAVCAN_PLATFORM_UPPER}_TIMER_NUMBER=${UAVCAN_TIMER} -DUAVCAN_CPP_VERSION=UAVCAN_CPP03 + -DUAVCAN_DRIVER=uavcan_${UAVCAN_PLATFORM} + -DUAVCAN_IMPLEMENT_PLACEMENT_NEW=1 -DUAVCAN_MEM_POOL_BLOCK_SIZE=48 -DUAVCAN_NO_ASSERTIONS -DUAVCAN_PLATFORM=${UAVCAN_PLATFORM} - -DUAVCAN_DRIVER=uavcan_${UAVCAN_PLATFORM} - -DUAVCAN_${UAVCAN_PLATFORM_UPPER}_${OS_UPPER}=1 - -DUAVCAN_${UAVCAN_PLATFORM_UPPER}_NUM_IFACES=${config_uavcan_num_ifaces} - -DUAVCAN_${UAVCAN_PLATFORM_UPPER}_TIMER_NUMBER=${UAVCAN_TIMER} ) add_subdirectory(libuavcan EXCLUDE_FROM_ALL) diff --git a/src/lib/ecl b/src/lib/ecl index acde4ebcc3..721f5e61a5 160000 --- a/src/lib/ecl +++ b/src/lib/ecl @@ -1 +1 @@ -Subproject commit acde4ebcc38692213ee475c392f68ecb0b853818 +Subproject commit 721f5e61a5965a08a34b2875d2bdc0b5d3b80601