From 7ab149d8e90094106e2f9e7d87887b1c8dd6dfd3 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Mon, 3 Jun 2019 16:53:11 -0600 Subject: [PATCH] Various fixes to get a clean compile with the SDCC compiler. Compile is 'almost' clean. --- arch/z80/src/z180/z180_initialstate.c | 2 +- arch/z80/src/z180/z180_lowscc.c | 2 +- arch/z80/src/z180/z180_lowuart.c | 2 +- arch/z80/src/z180/z180_scc.c | 2 +- arch/z80/src/z80/z80_initialstate.c | 2 +- configs/Makefile | 3 +- configs/dummy.c | 59 +++++++++++++++++++++++++++ configs/z80sim/README.txt | 10 +++++ configs/z80sim/src/z80_serial.c | 7 ++-- configs/z8f64200100kit/README.txt | 4 ++ libs/libc/stdio/legacy_dtoa.c | 16 ++++---- libs/libc/stdio/legacy_libvsprintf.c | 5 ++- libs/libc/stdio/lib_dtoa_data.c | 7 ++-- libs/libc/stdio/lib_dtoa_engine.c | 5 ++- libs/libc/stdio/lib_dtoa_engine.h | 11 +++-- libs/libc/stdio/lib_libdtoa.c | 3 +- libs/libc/stdio/lib_libvscanf.c | 15 +++---- libs/libc/stdio/lib_libvsprintf.c | 15 +++---- sched/signal/sig_notification.c | 12 +++++- 19 files changed, 136 insertions(+), 46 deletions(-) create mode 100644 configs/dummy.c diff --git a/arch/z80/src/z180/z180_initialstate.c b/arch/z80/src/z180/z180_initialstate.c index f163738c91..2c54b5b3b2 100644 --- a/arch/z80/src/z180/z180_initialstate.c +++ b/arch/z80/src/z180/z180_initialstate.c @@ -42,7 +42,7 @@ #include #include -#include "chip/chip.h" +#include "chip.h" #include "up_internal.h" #include "up_arch.h" diff --git a/arch/z80/src/z180/z180_lowscc.c b/arch/z80/src/z180/z180_lowscc.c index 59caa4c561..c36bb9afc7 100644 --- a/arch/z80/src/z180/z180_lowscc.c +++ b/arch/z80/src/z180/z180_lowscc.c @@ -46,7 +46,7 @@ #include #include -#include "chip/chip.h" +#include "chip.h" #include "common/up_internal.h" #include "z180_config.h" diff --git a/arch/z80/src/z180/z180_lowuart.c b/arch/z80/src/z180/z180_lowuart.c index cd80e3987b..18de900abc 100644 --- a/arch/z80/src/z180/z180_lowuart.c +++ b/arch/z80/src/z180/z180_lowuart.c @@ -46,7 +46,7 @@ #include #include -#include "chip/chip.h" +#include "chip.h" #include "common/up_internal.h" #include "z180_config.h" diff --git a/arch/z80/src/z180/z180_scc.c b/arch/z80/src/z180/z180_scc.c index 72f5961edf..78c244043e 100644 --- a/arch/z80/src/z180/z180_scc.c +++ b/arch/z80/src/z180/z180_scc.c @@ -53,7 +53,7 @@ #include #include -#include "chip/chip.h" +#include "chip.h" #include "up_internal.h" #include "z180_config.h" diff --git a/arch/z80/src/z80/z80_initialstate.c b/arch/z80/src/z80/z80_initialstate.c index 7191f03ebe..00c058489d 100644 --- a/arch/z80/src/z80/z80_initialstate.c +++ b/arch/z80/src/z80/z80_initialstate.c @@ -42,7 +42,7 @@ #include #include -#include "chip/chip.h" +#include "chip.h" #include "up_internal.h" #include "up_arch.h" diff --git a/configs/Makefile b/configs/Makefile index 61341caa33..b0c3508f51 100644 --- a/configs/Makefile +++ b/configs/Makefile @@ -65,7 +65,7 @@ BOARD_INSTALLED = $(if $(wildcard $(BOARD_DIR)$(DELIM)Makefile),y,) # Basic CONFIG_ASRCS = -CONFIG_CSRCS = +CONFIG_CSRCS = dummy.c CONFIG_CXXSRCS = # boardctl support @@ -101,7 +101,6 @@ $(CXXOBJS): %$(OBJEXT): %.cxx $(call COMPILEXX, $<, $@) $(BIN): $(OBJS) - $(Q) touch $(BIN) # Archive may not exist $(call ARCHIVE, $@, $(OBJS)) .depend: Makefile $(SRCS) diff --git a/configs/dummy.c b/configs/dummy.c new file mode 100644 index 0000000000..2f312070ff --- /dev/null +++ b/configs/dummy.c @@ -0,0 +1,59 @@ +/**************************************************************************** + * configs/dummy.c + * + * Copyright (C) 2019 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * 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 NuttX 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. + * + ****************************************************************************/ + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: __configs_dummy + * + * Description: + * This is a dummy C file. It is used to generate a useless object. The + * purpose of the useless object is to assure that libconfigs.a/lib is + * created. Some archivers (ZDS-II, SDCC) require a non-empty library or + * they will generate errors + * + * Input Parameters: + * None + * + * Returned Value: + * None + * + ****************************************************************************/ + +void __configs_dummy(void) +{ +} diff --git a/configs/z80sim/README.txt b/configs/z80sim/README.txt index 0d29568fc3..6251483b5f 100644 --- a/configs/z80sim/README.txt +++ b/configs/z80sim/README.txt @@ -222,3 +222,13 @@ and install SDCC: sudo make install +Known compilation problems: + + CC: stdlib/lib_strtof.c + stdlib/lib_strtof.c:62:6: warning: #warning "Size of exponent is unknown" + stdlib/lib_strtof.c:76: error 122: dividing by ZERO + stdlib/lib_strtof.c:102: error 122: dividing by ZERO + stdlib/lib_strtof.c:76: error 122: dividing by ZERO + + Workaround: Remove lib_strtof.c from libs/libc/stdlib/Make.defs + diff --git a/configs/z80sim/src/z80_serial.c b/configs/z80sim/src/z80_serial.c index ee1f60570e..abe80c38ec 100644 --- a/configs/z80sim/src/z80_serial.c +++ b/configs/z80sim/src/z80_serial.c @@ -50,7 +50,6 @@ #include #include #include -#include #include "up_arch.h" #include "up_internal.h" @@ -113,22 +112,24 @@ static uart_dev_t g_uartport = { 1 }, /* closesem */ { 0 }, /* xmitsem */ { 0 }, /* recvsem */ + { 0 }, /* pollsem */ { /* xmit */ { 1 }, /* sem */ 0, /* head */ 0, /* tail */ CONFIG_UART_TXBUFSIZE, /* size */ - g_uarttxbuffer, /* buffer */ + g_uarttxbuffer /* buffer */ }, { /* recv */ { 1 }, /* sem */ 0, /* head */ 0, /* tail */ CONFIG_UART_RXBUFSIZE, /* size */ - g_uartrxbuffer, /* buffer */ + g_uartrxbuffer /* buffer */ }, &g_uart_ops, /* ops */ NULL, /* priv */ + NULL /* pollfds */ }; /**************************************************************************** diff --git a/configs/z8f64200100kit/README.txt b/configs/z8f64200100kit/README.txt index e0dbcee016..71132c6fd5 100644 --- a/configs/z8f64200100kit/README.txt +++ b/configs/z8f64200100kit/README.txt @@ -44,6 +44,10 @@ Other Versions the configs/z8f64200100kit/*/Make.defs file and also your PATH environment variable. + It has been a long time since the z8 port has been used. A lot has + changed so it would most likely require a modest effort to get the + compilation working again. + Configuration Subdirectories ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/libs/libc/stdio/legacy_dtoa.c b/libs/libc/stdio/legacy_dtoa.c index 3cb0e20ebe..ba668d4717 100644 --- a/libs/libc/stdio/legacy_dtoa.c +++ b/libs/libc/stdio/legacy_dtoa.c @@ -142,14 +142,14 @@ static FAR bigint_t *g_freelist[KMAX + 1]; static FAR bigint_t *g_p5s; #ifdef IEEE_ARITH -static const double g_bigtens[] = +static const double_t g_bigtens[] = { 1e16, 1e32, 1e64, 1e128, 1e256 }; # define n_bigtens 5 #else -static const double g_bigtens[] = +static const double_t g_bigtens[] = { 1e16, 1e32 }; @@ -767,7 +767,7 @@ static FAR bigint_t *diff(FAR bigint_t *a, FAR bigint_t *b) return c; } -static FAR bigint_t *d2b(double d, int *e, int *bits) +static FAR bigint_t *d2b(double_t d, int *e, int *bits) { FAR bigint_t *b; FAR unsigned long *x; @@ -900,7 +900,7 @@ static FAR bigint_t *d2b(double d, int *e, int *bits) return b; } -static const double tens[] = +static const double_t tens[] = { 1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 1e11, 1e12, 1e13, 1e14, 1e15, 1e16, 1e17, 1e18, 1e19, @@ -1082,7 +1082,7 @@ static int quorem(FAR bigint_t *b, FAR bigint_t *s) * calculation. */ -FAR char *__dtoa(double d, int mode, int ndigits, FAR int *decpt, +FAR char *__dtoa(double_t d, int mode, int ndigits, FAR int *decpt, FAR int *sign, FAR char **rve) { /* Arguments ndigits, decpt, sign are similar to those of ecvt and fcvt; @@ -1120,9 +1120,9 @@ FAR char *__dtoa(double d, int mode, int ndigits, FAR int *decpt, FAR bigint_t *s; FAR char *st; FAR char *st0; - double d2; - double ds; - double eps; + double_t d2; + double_t ds; + double_t eps; long l; unsigned long x; int denorm; diff --git a/libs/libc/stdio/legacy_libvsprintf.c b/libs/libc/stdio/legacy_libvsprintf.c index 089a525802..a220dae09b 100644 --- a/libs/libc/stdio/legacy_libvsprintf.c +++ b/libs/libc/stdio/legacy_libvsprintf.c @@ -39,6 +39,7 @@ #include +#include #include #include #include @@ -505,7 +506,7 @@ static int getusize(uint8_t fmt, uint16_t flags, unsigned int n) ****************************************************************************/ #ifdef CONFIG_LIBC_FLOATINGPOINT -static int getdblsize(uint8_t fmt, int trunc, uint16_t flags, double n) +static int getdblsize(uint8_t fmt, int trunc, uint16_t flags, double_t n) { struct lib_outstream_s nulloutstream; lib_nulloutstream(&nulloutstream); @@ -1561,7 +1562,7 @@ int lib_vsprintf(FAR struct lib_outstream_s *obj, FAR const IPTR char *src, #ifdef CONFIG_LIBC_FLOATINGPOINT else if (strchr("eEfgG", FMT_CHAR)) { - double dblval = va_arg(ap, double); + double_t dblval = va_arg(ap, double_t); int dblsize; if (FMT_CHAR == 'g' || FMT_CHAR == 'G') diff --git a/libs/libc/stdio/lib_dtoa_data.c b/libs/libc/stdio/lib_dtoa_data.c index 3588b6fafe..41e8874666 100644 --- a/libs/libc/stdio/lib_dtoa_data.c +++ b/libs/libc/stdio/lib_dtoa_data.c @@ -37,6 +37,7 @@ * Included Files ****************************************************************************/ +#include #include "lib_dtoa_engine.h" /**************************************************************************** @@ -68,7 +69,7 @@ * Public Data ****************************************************************************/ -const double g_dtoa_scale_up[] = +const double_t g_dtoa_scale_up[] = { #if DBL_MAX_10_EXP >= 1 1e1, @@ -123,7 +124,7 @@ const double g_dtoa_scale_up[] = #endif }; -const double g_dtoa_scale_down[] = +const double_t g_dtoa_scale_down[] = { #if DBL_MIN_10_EXP <= -1 1e-1, @@ -178,7 +179,7 @@ const double g_dtoa_scale_down[] = #endif }; -const double g_dtoa_round[] = +const double_t g_dtoa_round[] = { #if DBL_DIG >= 30 5e30, diff --git a/libs/libc/stdio/lib_dtoa_engine.c b/libs/libc/stdio/lib_dtoa_engine.c index ab6495d19e..a63b16a66f 100644 --- a/libs/libc/stdio/lib_dtoa_engine.c +++ b/libs/libc/stdio/lib_dtoa_engine.c @@ -37,6 +37,7 @@ * Included Files ****************************************************************************/ +#include #include #include "lib_dtoa_engine.h" @@ -63,7 +64,7 @@ * Public Functions ****************************************************************************/ -int __dtoa_engine(double x, FAR struct dtoa_s *dtoa, int max_digits, +int __dtoa_engine(double_t x, FAR struct dtoa_s *dtoa, int max_digits, int max_decimals) { int32_t exp = 0; @@ -92,7 +93,7 @@ int __dtoa_engine(double x, FAR struct dtoa_s *dtoa, int max_digits, } else { - double y; + double_t y; exp = MIN_MANT_EXP; diff --git a/libs/libc/stdio/lib_dtoa_engine.h b/libs/libc/stdio/lib_dtoa_engine.h index a60e939875..1a4c6588c6 100644 --- a/libs/libc/stdio/lib_dtoa_engine.h +++ b/libs/libc/stdio/lib_dtoa_engine.h @@ -40,9 +40,12 @@ * Included Files ****************************************************************************/ +#include #include #include +#include + /**************************************************************************** * Pre-processor Definitions ****************************************************************************/ @@ -175,15 +178,15 @@ struct dtoa_s * Public Data ****************************************************************************/ -extern const double g_dtoa_scale_up[]; -extern const double g_dtoa_scale_down[]; -extern const double g_dtoa_round[]; +extern const double_t g_dtoa_scale_up[]; +extern const double_t g_dtoa_scale_down[]; +extern const double_t g_dtoa_round[]; /**************************************************************************** * Public Function Prototypes ****************************************************************************/ -int __dtoa_engine(double x, FAR struct dtoa_s *dtoa, int max_digits, +int __dtoa_engine(double_t x, FAR struct dtoa_s *dtoa, int max_digits, int max_decimals); #endif /* __LIBS_LIBC_STDIO_LIB_DTOA_ENGINE_H */ diff --git a/libs/libc/stdio/lib_libdtoa.c b/libs/libc/stdio/lib_libdtoa.c index 1bab3656ad..ae215298f7 100644 --- a/libs/libc/stdio/lib_libdtoa.c +++ b/libs/libc/stdio/lib_libdtoa.c @@ -46,6 +46,7 @@ #include +#include #include #include #include @@ -158,7 +159,7 @@ static void lib_dtoa_string(FAR struct lib_outstream_s *obj, const char *str) ****************************************************************************/ static void lib_dtoa(FAR struct lib_outstream_s *obj, int fmt, int prec, - uint16_t flags, double value) + uint16_t flags, double_t value) { FAR char *digits; /* String returned by __dtoa */ FAR char *rve; /* Points to the end of the return value */ diff --git a/libs/libc/stdio/lib_libvscanf.c b/libs/libc/stdio/lib_libvscanf.c index df805bcd18..e1ce055f8e 100644 --- a/libs/libc/stdio/lib_libvscanf.c +++ b/libs/libc/stdio/lib_libvscanf.c @@ -43,6 +43,7 @@ #include +#include #include #include #include @@ -917,7 +918,7 @@ int lib_vscanf(FAR struct lib_instream_s *obj, FAR int *lastc, else if (strchr("aAfFeEgG", *fmt) != NULL) { #ifdef CONFIG_HAVE_DOUBLE - FAR double *pd = NULL; + FAR double_t *pd = NULL; #endif FAR float *pf = NULL; @@ -937,7 +938,7 @@ int lib_vscanf(FAR struct lib_instream_s *obj, FAR int *lastc, #ifdef CONFIG_HAVE_DOUBLE if (modifier >= L_MOD) { - pd = va_arg(ap, FAR double *); + pd = va_arg(ap, FAR double_t *); *pd = 0.0; } else @@ -970,7 +971,7 @@ int lib_vscanf(FAR struct lib_instream_s *obj, FAR int *lastc, bool stopconv; int errsave; # ifdef CONFIG_HAVE_DOUBLE - double dvalue; + double_t dvalue; # endif float fvalue; @@ -1055,7 +1056,7 @@ int lib_vscanf(FAR struct lib_instream_s *obj, FAR int *lastc, # ifdef CONFIG_HAVE_DOUBLE if (modifier >= L_MOD) { - /* Get the converted double value */ + /* Get the converted double_t value */ dvalue = strtod(tmp, &endptr); } @@ -1079,13 +1080,13 @@ int lib_vscanf(FAR struct lib_instream_s *obj, FAR int *lastc, { /* We have to check whether we need to return a float or - * a double. + * a double_t. */ # ifdef CONFIG_HAVE_DOUBLE if (modifier >= L_MOD) { - /* Return the double value */ + /* Return the double_t value */ linfo("Return %f to %p\n", dvalue, pd); *pd = dvalue; @@ -1095,7 +1096,7 @@ int lib_vscanf(FAR struct lib_instream_s *obj, FAR int *lastc, { /* Return the float value */ - linfo("Return %f to %p\n", (double)fvalue, pf); + linfo("Return %f to %p\n", (double_t)fvalue, pf); *pf = fvalue; } diff --git a/libs/libc/stdio/lib_libvsprintf.c b/libs/libc/stdio/lib_libvsprintf.c index 5076697adf..898ce4a8b7 100644 --- a/libs/libc/stdio/lib_libvsprintf.c +++ b/libs/libc/stdio/lib_libvsprintf.c @@ -42,6 +42,7 @@ #include +#include #include #include #include @@ -131,7 +132,7 @@ struct arg #ifdef CONFIG_LIBC_LONG_LONG unsigned long long ull; #endif - double d; + double_t d; FAR char *cp; } value; }; @@ -493,7 +494,7 @@ static int vsprintf_internal(FAR struct lib_outstream_s *stream, } else if (c >= 'e' && c <= 'g') { - double value; + double_t value; int exp; /* Exponent of master decimal digit */ int n; uint8_t sign; /* Sign character (or 0) */ @@ -542,14 +543,14 @@ static int vsprintf_internal(FAR struct lib_outstream_s *stream, } else { - value = va_arg(ap, double); + value = va_arg(ap, double_t); } #else - value = va_arg(ap, double); + value = va_arg(ap, double_t); #endif ndigs = __dtoa_engine(value, &_dtoa, ndigs, - ndecimal); + ndecimal); exp = _dtoa.exp; sign = 0; @@ -812,7 +813,7 @@ static int vsprintf_internal(FAR struct lib_outstream_s *stream, #else /* !CONFIG_LIBC_FLOATINGPOINT */ if ((c >= 'E' && c <= 'G') || (c >= 'e' && c <= 'g')) { - (void)va_arg(ap, double); + (void)va_arg(ap, double_t); pnt = "*float*"; size = sizeof("*float*") - 1; goto str_lpad; @@ -1228,7 +1229,7 @@ int lib_vsprintf(FAR struct lib_outstream_s *stream, break; case TYPE_DOUBLE: - arglist[i].value.d = va_arg(ap, double); + arglist[i].value.d = va_arg(ap, double_t); break; case TYPE_CHAR_POINTER: diff --git a/sched/signal/sig_notification.c b/sched/signal/sig_notification.c index b1f19c9786..38c1059718 100644 --- a/sched/signal/sig_notification.c +++ b/sched/signal/sig_notification.c @@ -44,8 +44,9 @@ #include -#include +#include #include +#include #include @@ -131,12 +132,19 @@ int nxsig_notification(pid_t pid, FAR struct sigevent *event, info.si_signo = event->sigev_signo; info.si_code = code; info.si_errno = OK; - info.si_value = event->sigev_value; #ifdef CONFIG_SCHED_HAVE_PARENT info.si_pid = rtcb->pid; info.si_status = OK; #endif + /* Some compilers (e.g., SDCC), do not permit assignment of aggregates. + * Use of memcpy() is overkill; We could just copy the larger of the + * nt and FAR void * members in the union. memcpy(), however, does + * not require that we know which is larger. + */ + + memcpy(&info.si_value, &event->sigev_value, sizeof(union sigval)); + /* Send the signal */ return nxsig_dispatch(pid, &info);