From 622c272ea3cc83e718e0e7c61e24a8b785d55ee7 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Mon, 3 Jun 2019 18:16:23 -0600 Subject: [PATCH] Clean up some variouis compiler problems using SDCC to compiler Z180. --- arch/z80/include/irq.h | 16 ---------- arch/z80/include/z180/limits.h | 6 +++- arch/z80/include/z180/types.h | 6 +++- arch/z80/src/common/up_doirq.c | 2 ++ arch/z80/src/z180/z180_mmu.c | 9 +++--- arch/z80/src/z180/z180_schedulesigaction.c | 8 +++-- configs/p112/README.txt | 35 +++++++++++++++------- configs/p112/src/.gitignore | 16 +++++++++- configs/z80sim/README.txt | 2 ++ include/nuttx/lib/float.h | 22 ++++++++++---- libs/libc/signal/sig_psignal.c | 13 ++++++++ 11 files changed, 94 insertions(+), 41 deletions(-) diff --git a/arch/z80/include/irq.h b/arch/z80/include/irq.h index da9131cab8..2bffd7b2cf 100644 --- a/arch/z80/include/irq.h +++ b/arch/z80/include/irq.h @@ -47,21 +47,5 @@ #include #include -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Public Types - ****************************************************************************/ - -/**************************************************************************** - * Public Data - ****************************************************************************/ - -/**************************************************************************** - * Public Function Prototypes - ****************************************************************************/ - #endif /* __ARCH_Z80_INCLUDE_IRQ_H */ diff --git a/arch/z80/include/z180/limits.h b/arch/z80/include/z180/limits.h index 283c10e33a..7c58487d25 100644 --- a/arch/z80/include/z180/limits.h +++ b/arch/z80/include/z180/limits.h @@ -1,7 +1,7 @@ /**************************************************************************** * arch/z80/include/z180/limits.h * - * Copyright (C) 2012 Gregory Nutt. All rights reserved. + * Copyright (C) 2012, 2019 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -73,6 +73,10 @@ #define LONG_MAX 2147483647L #define ULONG_MAX 4294967295UL +#define LLONG_MIN (-LLONG_MAX - 1) +#define LLONG_MAX 9223372036854775807LL +#define ULLONG_MAX 18446744073709551615ULL + /* A pointer is 2 bytes */ #define PTR_MIN (-PTR_MAX - 1) diff --git a/arch/z80/include/z180/types.h b/arch/z80/include/z180/types.h index 16460dca5c..0e723b333a 100644 --- a/arch/z80/include/z180/types.h +++ b/arch/z80/include/z180/types.h @@ -1,7 +1,7 @@ /**************************************************************************** * arch/z80/include/z180/types.h * - * Copyright (C) 2012 Gregory Nutt. All rights reserved. + * Copyright (C) 2012, 2019 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -80,6 +80,10 @@ typedef unsigned int _uint16_t; typedef signed long _int32_t; typedef unsigned long _uint32_t; +typedef signed long long _int64_t; +typedef unsigned long long _uint64_t; +#define __INT64_DEFINED + /* A pointer is 2 bytes */ typedef signed int _intptr_t; diff --git a/arch/z80/src/common/up_doirq.c b/arch/z80/src/common/up_doirq.c index 878594a126..36f848ce0e 100644 --- a/arch/z80/src/common/up_doirq.c +++ b/arch/z80/src/common/up_doirq.c @@ -47,6 +47,8 @@ #include #include +#include + #include "chip/switch.h" #include "up_internal.h" diff --git a/arch/z80/src/z180/z180_mmu.c b/arch/z80/src/z180/z180_mmu.c index acc9065b94..fa435c7c08 100644 --- a/arch/z80/src/z180/z180_mmu.c +++ b/arch/z80/src/z180/z180_mmu.c @@ -44,9 +44,10 @@ #include #include +#include #include -#include +#include #include #include "up_internal.h" @@ -273,7 +274,7 @@ int up_addrenv_create(size_t textsize, size_t datasize, size_t heapsize, /* Now allocate the physical memory to back up the address environment */ - alloc = (uintptr_t)gran_alloc(npages); + alloc = (uintptr_t)gran_alloc(g_physhandle, npages); if (alloc == NULL) { serr("ERROR: Failed to allocate %d pages\n", npages); @@ -522,7 +523,7 @@ int up_addrenv_coherent(FAR const group_addrenv_t *addrenv) ****************************************************************************/ int up_addrenv_clone(FAR const group_addrenv_t *src, - FAR group_addrenv_t *dest); + FAR group_addrenv_t *dest) { DEBUGASSERT(src && dest); @@ -582,7 +583,7 @@ int up_addrenv_attach(FAR struct task_group_s *group, FAR struct tcb_s *tcb) * ****************************************************************************/ -int up_addrenv_detach(FAR struct task_group_s *group, FAR struct tcb_s *tcb); +int up_addrenv_detach(FAR struct task_group_s *group, FAR struct tcb_s *tcb) { /* There is nothing that needs to be done */ diff --git a/arch/z80/src/z180/z180_schedulesigaction.c b/arch/z80/src/z180/z180_schedulesigaction.c index bbe52d17f2..9c8e21a8c8 100644 --- a/arch/z80/src/z180/z180_schedulesigaction.c +++ b/arch/z80/src/z180/z180_schedulesigaction.c @@ -44,9 +44,12 @@ #include #include +#include #include -#include "chip/switch.h" +#include + +#include "switch.h" #include "sched/sched.h" #include "up_internal.h" @@ -58,7 +61,8 @@ * Name: z180_sigsetup ****************************************************************************/ -static void z180_sigsetup(FAR struct tcb_s *tcb, sig_deliver_t sigdeliver, FAR chipreg_t *regs) +static void z180_sigsetup(FAR struct tcb_s *tcb, sig_deliver_t sigdeliver, + FAR chipreg_t *regs) { /* Save the return address and interrupt state. These will be restored by * the signal trampoline after the signals have been delivered. diff --git a/configs/p112/README.txt b/configs/p112/README.txt index 0d5e8ea29d..c3bfae96a3 100644 --- a/configs/p112/README.txt +++ b/configs/p112/README.txt @@ -137,17 +137,32 @@ that connects to the P112 via the Z85230 ESCC channel A. Status ====== -2014-8-22: After some time idling away, I tried rebuilding with Windows 8, the latest MinGW -and the latest SDCC. I fixed a few things but there a still a few issues. The last "show -stopper" before I gave up for now was during building dependencies: +2014-8-22: After some time idling away, I tried rebuilding with Windows 8, + the latest MinGW and the latest SDCC. I fixed a few things but there a + still a few issues. The last "show stopper" before I gave up for now was + during building dependencies: -ASlink-Error- : "bin/mm_initialize.rel" + ASlink-Error- : "bin/mm_initialize.rel" -Clearly there is something wrong with the command line options given to SDCC because it is -trying to compile and link when we really only want dependencies. I did not spend very much -time trying to solve the problem; I assume that it is not too difficult. + Clearly there is something wrong with the command line options given to + SDCC because it is trying to compile and link when we really only want + dependencies. I did not spend very much time trying to solve the problem; + I assume that it is not too difficult. -2014-9-15: There has been a lot of change to the address environment APIs with the inegration -of address environments on the Cortex-A. It is likely that there is some breakage due to -incompatibilities with the Z180's mini-MMU. +2014-9-15: There has been a lot of change to the address environment APIs + with the integration of address environments on the Cortex-A. It is + likely that there is some breakage due to incompatibilities with the + Z180's mini-MMU. + +Known compilation problems with SDCC: + +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/p112/src/.gitignore b/configs/p112/src/.gitignore index 726d936e1e..101a872100 100644 --- a/configs/p112/src/.gitignore +++ b/configs/p112/src/.gitignore @@ -1,2 +1,16 @@ -/.depend /Make.dep +/.depend +/up_mem.h +/*.sym +/*.asm +/*.rel +/*.lst +/*.adb +/*.rst +/*.lib +/*.lnk +/*.map +/*.mem +/*.ihx +/*.hex + diff --git a/configs/z80sim/README.txt b/configs/z80sim/README.txt index 6251483b5f..8fdf9caa55 100644 --- a/configs/z80sim/README.txt +++ b/configs/z80sim/README.txt @@ -232,3 +232,5 @@ Known compilation problems: Workaround: Remove lib_strtof.c from libs/libc/stdlib/Make.defs + In arch/z80/src/z180: error 26: '_cbr' not a structure/union member + diff --git a/include/nuttx/lib/float.h b/include/nuttx/lib/float.h index 2ff2b4252c..3522506f8a 100644 --- a/include/nuttx/lib/float.h +++ b/include/nuttx/lib/float.h @@ -140,7 +140,9 @@ * representable finite floating-point number, emax. */ -#define FLT_MAX_EXP 128 +#ifndef FLT_MAX_EXP /* May be defined in system header */ +# define FLT_MAX_EXP 128 +#endif #ifdef CONFIG_HAVE_DOUBLE # define DBL_MAX_EXP 1024 @@ -158,7 +160,9 @@ * representable finite floating-point numbers. */ -#define FLT_MAX_10_EXP 38 /* 37 */ +#ifndef FLT_MAX_10_EXP /* May be defined in system header */ +# define FLT_MAX_10_EXP 38 /* 37 */ +#endif #ifdef CONFIG_HAVE_DOUBLE # define DBL_MAX_10_EXP 308 /* 37 */ @@ -174,7 +178,9 @@ /* Maximum representable finite floating-point number. */ -#define FLT_MAX 3.40282347e+38F /* 1E+37 */ +#ifndef FLT_MAX_EXP /* May be defined in system header */ +# define FLT_MAX 3.40282347e+38F /* 1E+37 */ +#endif #ifdef CONFIG_HAVE_DOUBLE # define DBL_MAX 1.7976931348623157e+308 /* 1E+37 */ @@ -192,7 +198,9 @@ * representable in the given floating-point type, b1-p. */ -#define FLT_EPSILON 1.1920929e-07F /* 1E-5 */ +#ifndef FLT_EPSILON /* May be defined in system header */ +# define FLT_EPSILON 1.1920929e-07F /* 1E-5 */ +#endif #ifdef CONFIG_HAVE_DOUBLE # define DBL_EPSILON 2.2204460492503131e-16 /* 1E-9 */ @@ -208,10 +216,12 @@ /* Minimum normalized positive floating-point number, bemin -1. */ -#define FLT_MIN 1.17549435e-38F /* 1E-37 */ +#ifndef FLT_EPSILON /* May be defined in system header */ +# define FLT_MIN 1.17549435e-38F /* 1E-37 */ +#endif #ifdef CONFIG_HAVE_DOUBLE -#define DBL_MIN 2.2250738585072014e-308 /* 1E-37 */ +# define DBL_MIN 2.2250738585072014e-308 /* 1E-37 */ #else # define DBL_MIN FLT_MIN #endif diff --git a/libs/libc/signal/sig_psignal.c b/libs/libc/signal/sig_psignal.c index 4b232e3d0a..c07e0f4bec 100644 --- a/libs/libc/signal/sig_psignal.c +++ b/libs/libc/signal/sig_psignal.c @@ -73,6 +73,7 @@ void psignal(int signum, FAR const char *message) { +#if CONFIG_NFILE_STREAMS > 0 /* For now, just a brainless write to stderr (fd == 2). C buffered I/O is * used! */ @@ -85,6 +86,18 @@ void psignal(int signum, FAR const char *message) { (void)fprintf(stderr, "%s\n", strsignal(signum)); } +#else + /* No stderr! Write to whatever alternative console is available */ + + if (message != NULL) + { + (void)printf("%s: %s\n", message, strsignal(signum)); + } + else + { + (void)printf("%s\n", strsignal(signum)); + } +#endif } /****************************************************************************