From 16229b3985452d086f98889a27ff132aa9f45651 Mon Sep 17 00:00:00 2001 From: David Sidrane Date: Mon, 12 Dec 2016 13:08:21 -1000 Subject: [PATCH] Build time patching of Uptream NuttX --- nuttx-patches/Fixed-Shadow-wanings.patch | 62 ++ nuttx-patches/c++11.patch | 106 ++++ nuttx-patches/ctype_cctype_.patch | 20 + nuttx-patches/export_insitu.patch | 56 ++ nuttx-patches/fixStdint.patch | 24 + nuttx-patches/math.h.patch | 583 ++++++++++++++++++ nuttx-patches/nsh_parse.patch | 271 ++++++++ .../silence-jobserver-warnings.patch | 40 ++ nuttx-patches/static_asset-fix.patch | 13 + nuttx-patches/wip_inflight_to_upstream.patch | 0 10 files changed, 1175 insertions(+) create mode 100644 nuttx-patches/Fixed-Shadow-wanings.patch create mode 100644 nuttx-patches/c++11.patch create mode 100644 nuttx-patches/ctype_cctype_.patch create mode 100644 nuttx-patches/export_insitu.patch create mode 100644 nuttx-patches/fixStdint.patch create mode 100644 nuttx-patches/math.h.patch create mode 100644 nuttx-patches/nsh_parse.patch create mode 100644 nuttx-patches/silence-jobserver-warnings.patch create mode 100644 nuttx-patches/static_asset-fix.patch create mode 100644 nuttx-patches/wip_inflight_to_upstream.patch diff --git a/nuttx-patches/Fixed-Shadow-wanings.patch b/nuttx-patches/Fixed-Shadow-wanings.patch new file mode 100644 index 0000000000..bbc24c2dd3 --- /dev/null +++ b/nuttx-patches/Fixed-Shadow-wanings.patch @@ -0,0 +1,62 @@ +diff --git NuttX/nuttx/include/signal.h NuttX/nuttx/include/signal.h +index bd8ee9f..7ee242a 100644 +--- NuttX/nuttx/include/signal.h ++++ NuttX/nuttx/include/signal.h +@@ -282,8 +282,11 @@ extern "C" + + int kill(pid_t pid, int signo); + int raise(int signo); ++#pragma GCC diagnostic push ++#pragma GCC diagnostic ignored "-Wshadow" + int sigaction(int signo, FAR const struct sigaction *act, + FAR struct sigaction *oact); ++#pragma GCC diagnostic pop + int sigaddset(FAR sigset_t *set, int signo); + int sigdelset(FAR sigset_t *set, int signo); + int sigemptyset(FAR sigset_t *set); +diff --git NuttX/nuttx/include/stdlib.h NuttX/nuttx/include/stdlib.h +index aa259c9..f2b0640 100644 +--- NuttX/nuttx/include/stdlib.h ++++ NuttX/nuttx/include/stdlib.h +@@ -202,7 +202,10 @@ FAR void *zalloc(size_t); + FAR void *calloc(size_t, size_t); + + #ifdef CONFIG_CAN_PASS_STRUCTS ++#pragma GCC diagnostic push ++#pragma GCC diagnostic ignored "-Wshadow" + struct mallinfo mallinfo(void); ++#pragma GCC diagnostic pop + #else + int mallinfo(FAR struct mallinfo *info); + #endif +diff --git NuttX/nuttx/include/sys/stat.h NuttX/nuttx/include/sys/stat.h +index 3f2658b..41c8604 100644 +--- NuttX/nuttx/include/sys/stat.h ++++ NuttX/nuttx/include/sys/stat.h +@@ -131,7 +131,10 @@ extern "C" + + int mkdir(FAR const char *pathname, mode_t mode); + int mkfifo(FAR const char *pathname, mode_t mode); ++#pragma GCC diagnostic push ++#pragma GCC diagnostic ignored "-Wshadow" + int stat(const char *path, FAR struct stat *buf); ++#pragma GCC diagnostic pop + #if 0 /* Not yet supported */ + int fstat(int fd, FAR struct stat *buf); + #endif +diff --git NuttX/nuttx/include/sys/statfs.h NuttX/nuttx/include/sys/statfs.h +index 1d1786a..12f802b 100644 +--- NuttX/nuttx/include/sys/statfs.h ++++ NuttX/nuttx/include/sys/statfs.h +@@ -139,8 +139,11 @@ extern "C" + * form of the struct statfs. + */ + ++#pragma GCC diagnostic push ++#pragma GCC diagnostic ignored "-Wshadow" + int statfs(FAR const char *path, FAR struct statfs *buf); + int fstatfs(int fd, FAR struct statfs *buf); ++#pragma GCC diagnostic pop + + #undef EXTERN + #if defined(__cplusplus) diff --git a/nuttx-patches/c++11.patch b/nuttx-patches/c++11.patch new file mode 100644 index 0000000000..26008aa736 --- /dev/null +++ b/nuttx-patches/c++11.patch @@ -0,0 +1,106 @@ +diff --git NuttX/nuttx/include/cxx/cwchar NuttX/nuttx/include/cxx/cwchar +index 67716ab..a6c6cfe 100755 +--- NuttX/nuttx/include/cxx/cwchar ++++ NuttX/nuttx/include/cxx/cwchar +@@ -46,13 +46,100 @@ + // Namespace + //*************************************************************************** + ++/* N.B. The following definitions are enabled at this time to allow the PX4 ++ * development to continue until there is a SAFE solution to foreign ++ * (non-nuttx) header file inclusion. There is a potential of a binary ++ * incompatibility and runtime errors, memory overwrites or corruption ++ * VVVVVVVVVVVVVVVVVVVVVVVVVV Begin Warning VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV ++ */ + namespace std + { +-#if 0 // Not defined ++#if __cplusplus >= 201103L + using ::mbstate_t; + #endif ++/*^^^^^^^^^^^^^^^^^^^^^^^^^ End Warning ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ ++ + using ::wint_t; + using ::size_t; + }; + ++/* N.B. The following definitions are enabled at this time to allow the PX4 ++ * development to continue until there is a SAFE solution to foreign ++ * (non-nuttx) header file inclusion. There is a potential of a binary ++ * incompatibility and runtime errors, memory overwrites or corruption ++ * ++ * These functions are not implemented, but listed here to allow compilation ++ * Any resulting linker error will require the implementation of the offending ++ * function(s) Code contributions are welcome. ++ * VVVVVVVVVVVVVVVVVVVVVVVVVV Begin Warning VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV ++ */ ++ ++#if __cplusplus >= 201103L ++ ++wint_t btowc(int); ++int fwprintf(FILE *, const wchar_t *, ...); ++int fwscanf(FILE *, const wchar_t *, ...); ++wint_t fgetwc(FILE *); ++wchar_t *fgetws(wchar_t *, int, FILE *); ++wint_t fputwc(wchar_t, FILE *); ++int fputws(const wchar_t *, FILE *); ++int fwide(FILE *, int); ++wint_t getwc(FILE *); ++wint_t getwchar(void); ++int mbsinit(const mbstate_t *); ++size_t mbrlen(const char *, size_t, mbstate_t *); ++size_t mbrtowc(wchar_t *, const char *, size_t, ++ mbstate_t *); ++size_t mbsrtowcs(wchar_t *, const char **, size_t, ++ mbstate_t *); ++wint_t putwc(wchar_t, FILE *); ++wint_t putwchar(wchar_t); ++int swprintf(wchar_t *, size_t, const wchar_t *, ...); ++int swscanf(const wchar_t *, const wchar_t *, ...); ++wint_t ungetwc(wint_t, FILE *); ++int vfwprintf(FILE *, const wchar_t *, va_list); ++int vwprintf(const wchar_t *, va_list); ++int vswprintf(wchar_t *, size_t, const wchar_t *, ++ va_list); ++size_t wcrtomb(char *, wchar_t, mbstate_t *); ++wchar_t *wcscat(wchar_t *, const wchar_t *); ++wchar_t *wcschr(const wchar_t *, wchar_t); ++int wcscmp(const wchar_t *, const wchar_t *); ++int wcscoll(const wchar_t *, const wchar_t *); ++wchar_t *wcscpy(wchar_t *, const wchar_t *); ++size_t wcscspn(const wchar_t *, const wchar_t *); ++size_t wcsftime(wchar_t *, size_t, const wchar_t *, ++ const struct tm *); ++size_t wcslen(const wchar_t *); ++wchar_t *wcsncat(wchar_t *, const wchar_t *, size_t); ++int wcsncmp(const wchar_t *, const wchar_t *, size_t); ++wchar_t *wcsncpy(wchar_t *, const wchar_t *, size_t); ++wchar_t *wcspbrk(const wchar_t *, const wchar_t *); ++wchar_t *wcsrchr(const wchar_t *, wchar_t); ++size_t wcsrtombs(char *, const wchar_t **, size_t, ++ mbstate_t *); ++size_t wcsspn(const wchar_t *, const wchar_t *); ++wchar_t *wcsstr(const wchar_t *, const wchar_t *); ++double wcstod(const wchar_t *, wchar_t **); ++wchar_t *wcstok(wchar_t *, const wchar_t *, wchar_t **); ++long int wcstol(const wchar_t *, wchar_t **, int); ++unsigned long int wcstoul(const wchar_t *, wchar_t **, int); ++wchar_t *wcswcs(const wchar_t *, const wchar_t *); ++int wcswidth(const wchar_t *, size_t); ++size_t wcsxfrm(wchar_t *, const wchar_t *, size_t); ++int wctob(wint_t); ++int wcwidth(wchar_t); ++wchar_t *wmemchr(const wchar_t *, wchar_t, size_t); ++int wmemcmp(const wchar_t *, const wchar_t *, size_t); ++wchar_t *wmemcpy(wchar_t *, const wchar_t *, size_t); ++wchar_t *wmemmove(wchar_t *, const wchar_t *, size_t); ++wchar_t *wmemset(wchar_t *, wchar_t, size_t); ++int wprintf(const wchar_t *, ...); ++int wscanf(const wchar_t *, ...); ++int vfwscanf(FILE *, const wchar_t *, va_list); ++int vswscanf(const wchar_t *, const wchar_t *, va_list); ++int vwscanf(const wchar_t *, va_list); ++float wcstof(const wchar_t *, wchar_t **); ++#endif ++/*^^^^^^^^^^^^^^^^^^^^^^^^^ End Warning ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ + #endif // __INCLUDE_CXX_CWCHAR diff --git a/nuttx-patches/ctype_cctype_.patch b/nuttx-patches/ctype_cctype_.patch new file mode 100644 index 0000000000..bfccf94cc3 --- /dev/null +++ b/nuttx-patches/ctype_cctype_.patch @@ -0,0 +1,20 @@ +diff --git NuttX/nuttx/include/ctype.h NuttX/nuttx/include/ctype.h +index dcf918b..65706b7 100644 +--- NuttX/nuttx/include/ctype.h ++++ NuttX/nuttx/include/ctype.h +@@ -50,6 +50,8 @@ + /**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ ++#pragma GCC diagnostic push ++#pragma GCC diagnostic ignored "-Wshadow" + + /**************************************************************************** + * Name: isspace +@@ -340,5 +342,6 @@ extern "C" + #ifdef __cplusplus + } + #endif ++#pragma GCC diagnostic pop + + #endif /* __INCLUDE_CTYPE_H */ diff --git a/nuttx-patches/export_insitu.patch b/nuttx-patches/export_insitu.patch new file mode 100644 index 0000000000..f1c54466b6 --- /dev/null +++ b/nuttx-patches/export_insitu.patch @@ -0,0 +1,56 @@ +diff --git NuttX/nuttx/tools/mkexport.sh NuttX/nuttx/tools/mkexport.sh +index 348a14c..3cc9182 100755 +--- NuttX/nuttx/tools/mkexport.sh ++++ NuttX/nuttx/tools/mkexport.sh +@@ -34,19 +34,23 @@ + + # Get the input parameter list + +-USAGE="USAGE: $0 [-d] [-z] [-u] [-w|wy|wn] -t [-x ] -l \"lib1 [lib2 [lib3 ...]]\"" ++USAGE="USAGE: $0 [-d] [-e] [-z] [-u] [-w|wy|wn] -t [-x ] -l \"lib1 [lib2 [lib3 ...]]\"" + unset TOPDIR + unset LIBLIST + unset TGZ + USRONLY=n + WINTOOL=n + LIBEXT=.a ++INSITU=y + + while [ ! -z "$1" ]; do + case $1 in + -d ) + set -x + ;; ++ -e ) ++ INSITU=n ++ ;; + -l ) + shift + LIBLIST=$1 +@@ -373,13 +377,17 @@ done + cd "${TOPDIR}" || \ + { echo "MK: 'cd ${TOPDIR}' failed"; exit 1; } + +-if [ "X${TGZ}" = "Xy" ]; then +- tar cvf "${EXPORTSUBDIR}.tar" "${EXPORTSUBDIR}" 1>/dev/null 2>&1 +- gzip -f "${EXPORTSUBDIR}.tar" +-else +- zip -r "${EXPORTSUBDIR}.zip" "${EXPORTSUBDIR}" 1>/dev/null 2>&1 +-fi ++# Should we leave the export insitu ++ ++if [ "X${INSITU}" = "Xn" ]; then ++ if [ "X${TGZ}" = "Xy" ]; then ++ tar cvf "${EXPORTSUBDIR}.tar" "${EXPORTSUBDIR}" 1>/dev/null 2>&1 ++ gzip -f "${EXPORTSUBDIR}.tar" ++ else ++ zip -r "${EXPORTSUBDIR}.zip" "${EXPORTSUBDIR}" 1>/dev/null 2>&1 ++ fi + +-# Clean up after ourselves ++ # Clean up after ourselves + +-rm -rf "${EXPORTSUBDIR}" ++ rm -rf "${EXPORTSUBDIR}" ++fi +\ No newline at end of file diff --git a/nuttx-patches/fixStdint.patch b/nuttx-patches/fixStdint.patch new file mode 100644 index 0000000000..eb9c6c6056 --- /dev/null +++ b/nuttx-patches/fixStdint.patch @@ -0,0 +1,24 @@ +diff --git NuttX/nuttx/include/cxx/cstdint NuttX/nuttx/include/cxx/cstdint +index d662c5d..95334e9 100644 +--- NuttX/nuttx/include/cxx/cstdint ++++ NuttX/nuttx/include/cxx/cstdint +@@ -46,6 +46,9 @@ + // Namespace + //*************************************************************************** + ++ #define GCC_VERSION (__GNUC__ * 10000 \ ++ + __GNUC_MINOR__ * 100 \ ++ + __GNUC_PATCHLEVEL__) + namespace std + { + using ::int8_t; +@@ -72,7 +75,9 @@ namespace std + using ::uint_fast64_t; + using ::uint_least8_t; + using ::uint_least16_t; ++#if GCC_VERSION <= 40804 + using ::uint_least32_t; ++#endif + using ::uint_least64_t; + using ::uintmax_t; + using ::uintptr_t; diff --git a/nuttx-patches/math.h.patch b/nuttx-patches/math.h.patch new file mode 100644 index 0000000000..18650027ec --- /dev/null +++ b/nuttx-patches/math.h.patch @@ -0,0 +1,583 @@ +diff -ruN NuttX/nuttx/arch/arm/include/math.h NuttX/nuttx/arch/arm/include/math.h +--- NuttX/nuttx/arch/arm/include/math.h 1969-12-31 14:00:00.000000000 -1000 ++++ NuttX/nuttx/arch/arm/include/math.h 2014-12-25 17:33:53.404950574 -1000 +@@ -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 _PARAMS((double)); ++extern double cos _PARAMS((double)); ++extern double sin _PARAMS((double)); ++extern double tan _PARAMS((double)); ++extern double tanh _PARAMS((double)); ++extern double frexp _PARAMS((double, int *)); ++extern double modf _PARAMS((double, double *)); ++extern double ceil _PARAMS((double)); ++extern double fabs _PARAMS((double)); ++extern double floor _PARAMS((double)); ++#endif /* ! defined (__math_68881) */ ++ ++/* Non reentrant ANSI C functions. */ ++ ++#ifndef _REENT_ONLY ++#ifndef __math_68881 ++extern double acos _PARAMS((double)); ++extern double asin _PARAMS((double)); ++extern double atan2 _PARAMS((double, double)); ++extern double cosh _PARAMS((double)); ++extern double sinh _PARAMS((double)); ++extern double exp _PARAMS((double)); ++extern double ldexp _PARAMS((double, int)); ++extern double log _PARAMS((double)); ++extern double log10 _PARAMS((double)); ++extern double pow _PARAMS((double, double)); ++extern double sqrt _PARAMS((double)); ++extern double fmod _PARAMS((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 _PARAMS((void)); ++extern double nan _PARAMS((const char *)); ++extern int finite _PARAMS((double)); ++extern double copysign _PARAMS((double, double)); ++extern double logb _PARAMS((double)); ++extern int ilogb _PARAMS((double)); ++ ++extern double asinh _PARAMS((double)); ++extern double cbrt _PARAMS((double)); ++extern double nextafter _PARAMS((double, double)); ++extern double rint _PARAMS((double)); ++extern double scalbn _PARAMS((double, int)); ++ ++extern double exp2 _PARAMS((double)); ++extern double scalbln _PARAMS((double, long int)); ++extern double tgamma _PARAMS((double)); ++extern double nearbyint _PARAMS((double)); ++extern long int lrint _PARAMS((double)); ++extern long long int llrint _PARAMS((double)); ++extern double round _PARAMS((double)); ++extern long int lround _PARAMS((double)); ++extern long long int llround _PARAMS((double)); ++extern double trunc _PARAMS((double)); ++extern double remquo _PARAMS((double, double, int *)); ++extern double fdim _PARAMS((double, double)); ++extern double fmax _PARAMS((double, double)); ++extern double fmin _PARAMS((double, double)); ++extern double fma _PARAMS((double, double, double)); ++ ++#ifndef __math_68881 ++extern double log1p _PARAMS((double)); ++extern double expm1 _PARAMS((double)); ++#endif /* ! defined (__math_68881) */ ++ ++#ifndef _REENT_ONLY ++extern double acosh _PARAMS((double)); ++extern double atanh _PARAMS((double)); ++extern double remainder _PARAMS((double, double)); ++extern double gamma _PARAMS((double)); ++extern double lgamma _PARAMS((double)); ++extern double erf _PARAMS((double)); ++extern double erfc _PARAMS((double)); ++extern double log2 _PARAMS((double)); ++ ++#ifndef __math_68881 ++extern double hypot _PARAMS((double, double)); ++#endif ++ ++#endif /* ! defined (_REENT_ONLY) */ ++ ++/* Single precision versions of ANSI functions. */ ++ ++extern float atanf _PARAMS((float)); ++extern float cosf _PARAMS((float)); ++extern float sinf _PARAMS((float)); ++extern float tanf _PARAMS((float)); ++extern float tanhf _PARAMS((float)); ++extern float frexpf _PARAMS((float, int *)); ++extern float modff _PARAMS((float, float *)); ++extern float ceilf _PARAMS((float)); ++extern float fabsf _PARAMS((float)); ++extern float floorf _PARAMS((float)); ++ ++#ifndef _REENT_ONLY ++extern float acosf _PARAMS((float)); ++extern float asinf _PARAMS((float)); ++extern float atan2f _PARAMS((float, float)); ++extern float coshf _PARAMS((float)); ++extern float sinhf _PARAMS((float)); ++extern float expf _PARAMS((float)); ++extern float ldexpf _PARAMS((float, int)); ++extern float logf _PARAMS((float)); ++extern float log10f _PARAMS((float)); ++extern float powf _PARAMS((float, float)); ++extern float sqrtf _PARAMS((float)); ++extern float fmodf _PARAMS((float, float)); ++#endif /* ! defined (_REENT_ONLY) */ ++ ++/* Other single precision functions. */ ++ ++extern float exp2f _PARAMS((float)); ++extern float scalblnf _PARAMS((float, long int)); ++extern float tgammaf _PARAMS((float)); ++extern float nearbyintf _PARAMS((float)); ++extern long int lrintf _PARAMS((float)); ++extern long long llrintf _PARAMS((float)); ++extern float roundf _PARAMS((float)); ++extern long int lroundf _PARAMS((float)); ++extern long long int llroundf _PARAMS((float)); ++extern float truncf _PARAMS((float)); ++extern float remquof _PARAMS((float, float, int *)); ++extern float fdimf _PARAMS((float, float)); ++extern float fmaxf _PARAMS((float, float)); ++extern float fminf _PARAMS((float, float)); ++extern float fmaf _PARAMS((float, float, float)); ++ ++extern float infinityf _PARAMS((void)); ++extern float nanf _PARAMS((const char *)); ++extern int finitef _PARAMS((float)); ++extern float copysignf _PARAMS((float, float)); ++extern float logbf _PARAMS((float)); ++extern int ilogbf _PARAMS((float)); ++ ++extern float asinhf _PARAMS((float)); ++extern float cbrtf _PARAMS((float)); ++extern float nextafterf _PARAMS((float, float)); ++extern float rintf _PARAMS((float)); ++extern float scalbnf _PARAMS((float, int)); ++extern float log1pf _PARAMS((float)); ++extern float expm1f _PARAMS((float)); ++ ++#ifndef _REENT_ONLY ++extern float acoshf _PARAMS((float)); ++extern float atanhf _PARAMS((float)); ++extern float remainderf _PARAMS((float, float)); ++extern float gammaf _PARAMS((float)); ++extern float lgammaf _PARAMS((float)); ++extern float erff _PARAMS((float)); ++extern float erfcf _PARAMS((float)); ++extern float log2f _PARAMS((float)); ++extern float hypotf _PARAMS((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 _PARAMS((long double)); ++extern long double cosl _PARAMS((long double)); ++extern long double sinl _PARAMS((long double)); ++extern long double tanl _PARAMS((long double)); ++extern long double tanhl _PARAMS((long double)); ++extern long double frexpl _PARAMS((long double value, int *)); ++extern long double modfl _PARAMS((long double, long double *)); ++extern long double ceill _PARAMS((long double)); ++extern long double fabsl _PARAMS((long double)); ++extern long double floorl _PARAMS((long double)); ++extern long double log1pl _PARAMS((long double)); ++extern long double expm1l _PARAMS((long double)); ++#endif /* ! defined (__math_68881) */ ++/* Non reentrant ANSI C functions. */ ++#ifndef _REENT_ONLY ++#ifndef __math_68881 ++extern long double acosl _PARAMS((long double)); ++extern long double asinl _PARAMS((long double)); ++extern long double atan2l _PARAMS((long double, long double)); ++extern long double coshl _PARAMS((long double)); ++extern long double sinhl _PARAMS((long double)); ++extern long double expl _PARAMS((long double)); ++extern long double ldexpl _PARAMS((long double, int)); ++extern long double logl _PARAMS((long double)); ++extern long double log2l _PARAMS((long double)); ++extern long double log10l _PARAMS((long double)); ++extern long double powl _PARAMS((long double, long double)); ++extern long double sqrtl _PARAMS((long double)); ++extern long double fmodl _PARAMS((long double, long double)); ++extern long double hypotl _PARAMS((long double, long double)); ++#endif /* ! defined (__math_68881) */ ++#endif /* ! defined (_REENT_ONLY) */ ++extern long double copysignl _PARAMS((long double, long double)); ++extern long double nanl _PARAMS((const char *)); ++extern int ilogbl _PARAMS((long double)); ++extern long double asinhl _PARAMS((long double)); ++extern long double cbrtl _PARAMS((long double)); ++extern long double nextafterl _PARAMS((long double, long double)); ++extern long double rintl _PARAMS((long double)); ++extern long double scalbnl _PARAMS((long double, int)); ++extern long double exp2l _PARAMS((long double)); ++extern long double scalblnl _PARAMS((long double, long)); ++extern long double tgammal _PARAMS((long double)); ++extern long double nearbyintl _PARAMS((long double)); ++extern long int lrintl _PARAMS((long double)); ++extern long long int llrintl _PARAMS((long double)); ++extern long double roundl _PARAMS((long double)); ++extern long lroundl _PARAMS((long double)); ++extern long long int llroundl _PARAMS((long double)); ++extern long double truncl _PARAMS((long double)); ++extern long double remquol _PARAMS((long double, long double, int *)); ++extern long double fdiml _PARAMS((long double, long double)); ++extern long double fmaxl _PARAMS((long double, long double)); ++extern long double fminl _PARAMS((long double, long double)); ++extern long double fmal _PARAMS((long double, long double, long double)); ++#ifndef _REENT_ONLY ++extern long double acoshl _PARAMS((long double)); ++extern long double atanhl _PARAMS((long double)); ++extern long double remainderl _PARAMS((long double, long double)); ++extern long double lgammal _PARAMS((long double)); ++extern long double erfl _PARAMS((long double)); ++extern long double erfcl _PARAMS((long double)); ++#endif /* ! defined (_REENT_ONLY) */ ++#else /* !_LDBL_EQ_DBL */ ++#ifdef __i386__ ++/* Other long double precision functions. */ ++extern _LONG_DOUBLE rintl _PARAMS((_LONG_DOUBLE)); ++extern long int lrintl _PARAMS((_LONG_DOUBLE)); ++extern long long llrintl _PARAMS((_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 _PARAMS((double, double)); ++extern void sincos _PARAMS((double, double *, double *)); ++extern double gamma_r _PARAMS((double, int *)); ++extern double lgamma_r _PARAMS((double, int *)); ++ ++extern double y0 _PARAMS((double)); ++extern double y1 _PARAMS((double)); ++extern double yn _PARAMS((int, double)); ++extern double j0 _PARAMS((double)); ++extern double j1 _PARAMS((double)); ++extern double jn _PARAMS((int, double)); ++ ++extern float dremf _PARAMS((float, float)); ++extern void sincosf _PARAMS((float, float *, float *)); ++extern float gammaf_r _PARAMS((float, int *)); ++extern float lgammaf_r _PARAMS((float, int *)); ++ ++extern float y0f _PARAMS((float)); ++extern float y1f _PARAMS((float)); ++extern float ynf _PARAMS((int, float)); ++extern float j0f _PARAMS((float)); ++extern float j1f _PARAMS((float)); ++extern float jnf _PARAMS((int, float)); ++ ++/* GNU extensions */ ++# ifndef exp10 ++extern double exp10 _PARAMS((double)); ++# endif ++# ifndef pow10 ++extern double pow10 _PARAMS((double)); ++# endif ++# ifndef exp10f ++extern float exp10f _PARAMS((float)); ++# endif ++# ifndef pow10f ++extern float pow10f _PARAMS((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 _PARAMS((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 _PARAMS((struct __exception *e)); ++#else ++extern int matherr _PARAMS((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/nuttx-patches/nsh_parse.patch b/nuttx-patches/nsh_parse.patch new file mode 100644 index 0000000000..27466cba0d --- /dev/null +++ b/nuttx-patches/nsh_parse.patch @@ -0,0 +1,271 @@ +diff --git NuttX/apps/nshlib/nsh_parse.c NuttX/apps/nshlib/nsh_parse.c +index 30f7ef5..f6fa2e0 100644 +--- NuttX/apps/nshlib/nsh_parse.c ++++ NuttX/apps/nshlib/nsh_parse.c +@@ -156,9 +156,9 @@ static FAR char *nsh_envexpand(FAR struct nsh_vtbl_s *vtbl, + #endif + + static FAR char *nsh_argexpand(FAR struct nsh_vtbl_s *vtbl, FAR char *cmdline, +- FAR char **allocation); ++ FAR char **allocation, int* isenvvar); + static FAR char *nsh_argument(FAR struct nsh_vtbl_s *vtbl, char **saveptr, +- FAR NSH_MEMLIST_TYPE *memlist); ++ FAR NSH_MEMLIST_TYPE *memlist, int* isenvvar); + + #ifndef CONFIG_NSH_DISABLESCRIPT + #ifndef CONFIG_NSH_DISABLE_LOOPS +@@ -1009,7 +1009,7 @@ static FAR char *nsh_envexpand(FAR struct nsh_vtbl_s *vtbl, + + #if defined(CONFIG_NSH_ARGCAT) && defined(HAVE_MEMLIST) + static FAR char *nsh_argexpand(FAR struct nsh_vtbl_s *vtbl, FAR char *cmdline, +- FAR char **allocation) ++ FAR char **allocation, int* isenvvar) + { + FAR char *working = cmdline; + FAR char *argument = NULL; +@@ -1128,8 +1128,8 @@ static FAR char *nsh_argexpand(FAR struct nsh_vtbl_s *vtbl, FAR char *cmdline, + *allocation = argument; + + /* Find the end of the environment variable reference. If the +- * dollar sign ('$') is followed by a right bracket ('{') then the +- * variable name is terminated with the left bracket character ++ * dollar sign ('$') is followed by a left bracket ('{') then the ++ * variable name is terminated with the right bracket character + * ('}'). Otherwise, the variable name goes to the end of the + * argument. + */ +@@ -1167,6 +1167,10 @@ static FAR char *nsh_argexpand(FAR struct nsh_vtbl_s *vtbl, FAR char *cmdline, + * nsh_envexpand will return the NULL string. + */ + ++ if (isenvvar) { ++ *isenvvar = 1; ++ } ++ + envstr = nsh_envexpand(vtbl, ptr); + + /* Concatenate the result of the operation with the accumulated +@@ -1187,7 +1191,7 @@ static FAR char *nsh_argexpand(FAR struct nsh_vtbl_s *vtbl, FAR char *cmdline, + + #else + static FAR char *nsh_argexpand(FAR struct nsh_vtbl_s *vtbl, FAR char *cmdline, +- FAR char **allocation) ++ FAR char **allocation, int* isenvvar) + { + FAR char *argument = (FAR char *)g_nullstring; + +@@ -1223,6 +1227,9 @@ static FAR char *nsh_argexpand(FAR struct nsh_vtbl_s *vtbl, FAR char *cmdline, + + if (*cmdline == '$') + { ++ if (isenvvar) { ++ *isenvvar = 1; ++ } + argument = nsh_envexpand(vtbl, cmdline + 1); + } + else +@@ -1245,7 +1252,7 @@ static FAR char *nsh_argexpand(FAR struct nsh_vtbl_s *vtbl, FAR char *cmdline, + ****************************************************************************/ + + static FAR char *nsh_argument(FAR struct nsh_vtbl_s *vtbl, FAR char **saveptr, +- FAR NSH_MEMLIST_TYPE *memlist) ++ FAR NSH_MEMLIST_TYPE *memlist, int* isenvvar) + { + FAR char *pbegin = *saveptr; + FAR char *pend = NULL; +@@ -1317,6 +1324,13 @@ static FAR char *nsh_argument(FAR struct nsh_vtbl_s *vtbl, FAR char **saveptr, + + pbegin++; + term = "\""; ++ ++ /* If this is an environment variable in double quotes, we don't want it split into ++ * multiple argument should CONFIG_NSH_ENABLEPX4PARSING be defined ++ * So just invalidate the flag pointer which would otherwise communictate such ++ * back up the call tree. ++ */ ++ isenvvar = NULL; + } + else + { +@@ -1376,11 +1390,11 @@ static FAR char *nsh_argument(FAR struct nsh_vtbl_s *vtbl, FAR char **saveptr, + + /* Perform expansions as necessary for the argument */ + +- argument = nsh_argexpand(vtbl, pbegin, &allocation); ++ argument = nsh_argexpand(vtbl, pbegin, &allocation, isenvvar); + } + + /* If any memory was allocated for this argument, make sure that it is +- * added to the list of memory to be freed at the end of commend ++ * added to the list of memory to be freed at the end of command + * processing. + */ + +@@ -1497,7 +1511,7 @@ static int nsh_loop(FAR struct nsh_vtbl_s *vtbl, FAR char **ppcmd, + + /* Get the cmd following the "while" or "until" */ + +- *ppcmd = nsh_argument(vtbl, saveptr, memlist); ++ *ppcmd = nsh_argument(vtbl, saveptr, memlist, 0); + if (!*ppcmd) + { + nsh_output(vtbl, g_fmtarginvalid, "if"); +@@ -1554,7 +1568,7 @@ static int nsh_loop(FAR struct nsh_vtbl_s *vtbl, FAR char **ppcmd, + { + /* Get the cmd following the "do" -- there may or may not be one */ + +- *ppcmd = nsh_argument(vtbl, saveptr, memlist); ++ *ppcmd = nsh_argument(vtbl, saveptr, memlist, 0); + + /* Verify that "do" is valid in this context */ + +@@ -1574,7 +1588,7 @@ static int nsh_loop(FAR struct nsh_vtbl_s *vtbl, FAR char **ppcmd, + { + /* Get the cmd following the "done" -- there should be one */ + +- *ppcmd = nsh_argument(vtbl, saveptr, memlist); ++ *ppcmd = nsh_argument(vtbl, saveptr, memlist, 0); + if (*ppcmd) + { + nsh_output(vtbl, g_fmtarginvalid, "done"); +@@ -1679,7 +1693,7 @@ static int nsh_itef(FAR struct nsh_vtbl_s *vtbl, FAR char **ppcmd, + { + /* Get the cmd following the if */ + +- *ppcmd = nsh_argument(vtbl, saveptr, memlist); ++ *ppcmd = nsh_argument(vtbl, saveptr, memlist, 0); + if (!*ppcmd) + { + nsh_output(vtbl, g_fmtarginvalid, "if"); +@@ -1717,7 +1731,7 @@ static int nsh_itef(FAR struct nsh_vtbl_s *vtbl, FAR char **ppcmd, + { + /* Get the cmd following the "then" -- there may or may not be one */ + +- *ppcmd = nsh_argument(vtbl, saveptr, memlist); ++ *ppcmd = nsh_argument(vtbl, saveptr, memlist, 0); + + /* Verify that "then" is valid in this context */ + +@@ -1736,7 +1750,7 @@ static int nsh_itef(FAR struct nsh_vtbl_s *vtbl, FAR char **ppcmd, + { + /* Get the cmd following the "else" -- there may or may not be one */ + +- *ppcmd = nsh_argument(vtbl, saveptr, memlist); ++ *ppcmd = nsh_argument(vtbl, saveptr, memlist, 0); + + /* Verify that "else" is valid in this context */ + +@@ -1755,7 +1769,7 @@ static int nsh_itef(FAR struct nsh_vtbl_s *vtbl, FAR char **ppcmd, + { + /* Get the cmd following the fi -- there should be one */ + +- *ppcmd = nsh_argument(vtbl, saveptr, memlist); ++ *ppcmd = nsh_argument(vtbl, saveptr, memlist, 0); + if (*ppcmd) + { + nsh_output(vtbl, g_fmtarginvalid, "fi"); +@@ -1827,10 +1841,10 @@ static int nsh_nice(FAR struct nsh_vtbl_s *vtbl, FAR char **ppcmd, + + /* Get the cmd (or -d option of nice command) */ + +- cmd = nsh_argument(vtbl, saveptr, memlist); ++ cmd = nsh_argument(vtbl, saveptr, memlist, 0); + if (cmd && strcmp(cmd, "-d") == 0) + { +- FAR char *val = nsh_argument(vtbl, saveptr, memlist); ++ FAR char *val = nsh_argument(vtbl, saveptr, memlist, 0); + if (val) + { + char *endptr; +@@ -1841,7 +1855,7 @@ static int nsh_nice(FAR struct nsh_vtbl_s *vtbl, FAR char **ppcmd, + nsh_output(vtbl, g_fmtarginvalid, "nice"); + return ERROR; + } +- cmd = nsh_argument(vtbl, saveptr, memlist); ++ cmd = nsh_argument(vtbl, saveptr, memlist, 0); + } + } + +@@ -1909,7 +1923,7 @@ static int nsh_parse_cmdparm(FAR struct nsh_vtbl_s *vtbl, FAR char *cmdline, + /* Parse out the command at the beginning of the line */ + + saveptr = cmdline; +- cmd = nsh_argument(vtbl, &saveptr, &memlist); ++ cmd = nsh_argument(vtbl, &saveptr, &memlist, 0); + + /* Check if any command was provided -OR- if command processing is + * currently disabled. +@@ -1943,7 +1957,7 @@ static int nsh_parse_cmdparm(FAR struct nsh_vtbl_s *vtbl, FAR char *cmdline, + argv[0] = cmd; + for (argc = 1; argc < MAX_ARGV_ENTRIES-1; argc++) + { +- argv[argc] = nsh_argument(vtbl, &saveptr, &memlist); ++ argv[argc] = nsh_argument(vtbl, &saveptr, &memlist, 0); + if (!argv[argc]) + { + break; +@@ -2010,7 +2024,7 @@ static int nsh_parse_command(FAR struct nsh_vtbl_s *vtbl, FAR char *cmdline) + /* Parse out the command at the beginning of the line */ + + saveptr = cmdline; +- cmd = nsh_argument(vtbl, &saveptr, &memlist); ++ cmd = nsh_argument(vtbl, &saveptr, &memlist, 0); + + #ifndef CONFIG_NSH_DISABLESCRIPT + #ifndef CONFIG_NSH_DISABLE_LOOPS +@@ -2078,15 +2092,54 @@ static int nsh_parse_command(FAR struct nsh_vtbl_s *vtbl, FAR char *cmdline) + */ + + argv[0] = cmd; ++ ++#define CONFIG_NSH_ENABLEPX4PARSING ++ + for (argc = 1; argc < MAX_ARGV_ENTRIES-1; argc++) + { +- argv[argc] = nsh_argument(vtbl, &saveptr, &memlist); ++ int isenvvar = 0; /* flag for if an enviroment variable gets expanded */ ++ argv[argc] = nsh_argument(vtbl, &saveptr, &memlist, &isenvvar); + if (!argv[argc]) + { + break; + } ++ ++#ifdef CONFIG_NSH_ENABLEPX4PARSING ++ if (isenvvar) ++ { ++ while (argc < MAX_ARGV_ENTRIES-1) /* TODO: check this bounds check is correct */ ++ { ++ FAR char *pbegin = argv[argc]; ++ ++ /* Find the end of the current token */ ++ for (; *pbegin && !strchr(g_token_separator, *pbegin); pbegin++); ++ ++ /* If end of string, we've processed the last token and we're done */ ++ if ('\0' == *pbegin) ++ { ++ break; ++ } ++ ++ /* Terminate the token to complete the argv variable */ ++ *pbegin = '\0'; ++ ++ /* We've inserted an extra parameter, so bump the count */ ++ argc++; ++ ++ /* Move to the next character in the string of tokens */ ++ pbegin++; ++ ++ /* Throw away any extra separator chars between tokens */ ++ for (; *pbegin && strchr(g_token_separator, *pbegin) != NULL; pbegin++); ++ ++ /* Prepare to loop again on the next argument token */ ++ argv[argc] = pbegin; ++ } ++ } ++#endif /* CONFIG_NSH_ENABLEPX4PARSING */ + } + ++ /* Last argument vector must be empty */ + argv[argc] = NULL; + + /* Check if the command should run in background */ diff --git a/nuttx-patches/silence-jobserver-warnings.patch b/nuttx-patches/silence-jobserver-warnings.patch new file mode 100644 index 0000000000..29ad48cf29 --- /dev/null +++ b/nuttx-patches/silence-jobserver-warnings.patch @@ -0,0 +1,40 @@ +diff --git NuttX/apps/Makefile NuttX/apps/Makefile +index 4093b0e..3bdc36a 100644 +--- NuttX/apps/Makefile ++++ NuttX/apps/Makefile +@@ -79,13 +79,13 @@ all: $(BIN) + .PHONY: import install dirlinks context context_serialize context_rest .depdirs preconfig depend clean distclean + + define MAKE_template +- $(Q) $(MAKE) -C $(1) $(2) TOPDIR="$(TOPDIR)" APPDIR="$(APPDIR)" BIN_DIR="$(BIN_DIR)" ++ +$(Q) $(MAKE) -C $(1) $(2) TOPDIR="$(TOPDIR)" APPDIR="$(APPDIR)" BIN_DIR="$(BIN_DIR)" + + endef + + define SDIR_template + $(1)_$(2): +- $(Q) $(MAKE) -C $(1) $(2) TOPDIR="$(TOPDIR)" APPDIR="$(APPDIR)" BIN_DIR="$(BIN_DIR)" ++ +$(Q) $(MAKE) -C $(1) $(2) TOPDIR="$(TOPDIR)" APPDIR="$(APPDIR)" BIN_DIR="$(BIN_DIR)" + + endef + +@@ -108,7 +108,7 @@ install: $(BIN_DIR) .install + .import: $(BIN) install + + import: +- $(Q) $(MAKE) .import TOPDIR="$(APPDIR)$(DELIM)import" ++ +$(Q) $(MAKE) .import TOPDIR="$(APPDIR)$(DELIM)import" + + dirlinks: + $(Q) $(MAKE) -C platform dirlinks TOPDIR="$(TOPDIR)" APPDIR="$(APPDIR)" +@@ -116,8 +116,8 @@ dirlinks: + context_rest: $(foreach SDIR, $(CONFIGURED_APPS), $(SDIR)_context) + + context_serialize: +- $(Q) $(MAKE) -C builtin context TOPDIR="$(TOPDIR)" APPDIR="$(APPDIR)" +- $(Q) $(MAKE) context_rest ++ +$(Q) $(MAKE) -C builtin context TOPDIR="$(TOPDIR)" APPDIR="$(APPDIR)" ++ +$(Q) $(MAKE) context_rest + + context: context_serialize + diff --git a/nuttx-patches/static_asset-fix.patch b/nuttx-patches/static_asset-fix.patch new file mode 100644 index 0000000000..5e1ab2d410 --- /dev/null +++ b/nuttx-patches/static_asset-fix.patch @@ -0,0 +1,13 @@ +diff --git NuttX/nuttx/include/assert.h NuttX/nuttx/include/assert.h +index 88254f6..b9fb6c2 100644 +--- NuttX/nuttx/include/assert.h ++++ NuttX/nuttx/include/assert.h +@@ -94,7 +94,7 @@ + */ + + #ifndef __cplusplus +-# define static_assert _Static_assert ++//# define static_assert _Static_assert + #endif + + /**************************************************************************** diff --git a/nuttx-patches/wip_inflight_to_upstream.patch b/nuttx-patches/wip_inflight_to_upstream.patch new file mode 100644 index 0000000000..e69de29bb2