From 417e681cbb3a40dcebf2d1a94081bde45360b4ea Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Mon, 10 Jun 2019 09:49:11 -0600 Subject: [PATCH] libs/libc/time/lib_gmtimer.c: Spurious reorganization of a loop to work around and ZDD-II internal compiler error. Might be a little bigger now, but is also probably a more structured use of C. --- configs/ez80f910200kitg/README.txt | 37 +++--------------------- configs/ez80f910200zco/README.txt | 45 +++--------------------------- configs/makerlisp/README.txt | 45 +++--------------------------- libs/libc/time/lib_gmtimer.c | 40 +++++++++++++------------- 4 files changed, 32 insertions(+), 135 deletions(-) diff --git a/configs/ez80f910200kitg/README.txt b/configs/ez80f910200kitg/README.txt index 582476d996..24dc539f93 100644 --- a/configs/ez80f910200kitg/README.txt +++ b/configs/ez80f910200kitg/README.txt @@ -62,39 +62,10 @@ Version 5.2.1 Version 5.3.0 - I started verification using 5.30 on June 2, 2019. To use this toolchain, - I had to suppress the gmtime() and gmtimer() because these were causing an - internal compiler error: - - time\lib_gmtimer.c - P2: Internal Error(0xB47E59): - Please contact Technical Support - - This is the change to suppress building these files: - - diff --git a/libs/libc/time/Make.defs b/libs/libc/time/Make.defs - index 5c9b746778..8327e287f4 100644 - --- a/libs/libc/time/Make.defs - +++ b/libs/libc/time/Make.defs - @@ -44,7 +44,7 @@ ifdef CONFIG_LIBC_LOCALTIME - CSRCS += lib_localtime.c lib_asctime.c lib_asctimer.c lib_ctime.c - CSRCS += lib_ctimer.c - else - -CSRCS += lib_mktime.c lib_gmtime.c lib_gmtimer.c - +CSRCS += lib_mktime.c # lib_gmtime.c lib_gmtimer.c - ifdef CONFIG_TIME_EXTENDED - CSRCS += lib_dayofweek.c lib_asctime.c lib_asctimer.c lib_ctime.c - CSRCS += lib_ctimer.c - - The consequence is, of course, that these interfaces will not be available - to applications. - - Alternatively, you can use 'make -i' to build the system. The above - errors will occur, but will not stop the build (unless the failed build - objects are brought into the link). The has the negative side effects - that (1) the archives will always be rebuild in the directories where - the error occur, and (2) you might miss other, real compilation error - since these will no longer stop the compilation. + I verifed compilation using 5.30 on June 2, 2019. To use this version, + I had to make spurious modification to the implementation of gmtimer() to + work around an internal compiler error. I have still not verified that + are no errors in the compiled code. Other Versions If you use any version of ZDS-II other than 5.1.1, 5.2.1, or 5.3.0 or diff --git a/configs/ez80f910200zco/README.txt b/configs/ez80f910200zco/README.txt index 15c5ef1d47..bcc3faa3f7 100644 --- a/configs/ez80f910200zco/README.txt +++ b/configs/ez80f910200zco/README.txt @@ -62,47 +62,10 @@ Version 5.2.1 Version 5.3.0 - I started verification using 5.30 on June 2, 2019. To use this toolchain, - I had to suppress the gmtime() and gmtimer() because these were causing an - internal compiler error: - - time\lib_gmtimer.c - P2: Internal Error(0xB47E59): - Please contact Technical Support - - This is the change to suppress building these files: - - diff --git a/libs/libc/time/Make.defs b/libs/libc/time/Make.defs - index 5c9b746778..8327e287f4 100644 - --- a/libs/libc/time/Make.defs - +++ b/libs/libc/time/Make.defs - @@ -44,7 +44,7 @@ ifdef CONFIG_LIBC_LOCALTIME - CSRCS += lib_localtime.c lib_asctime.c lib_asctimer.c lib_ctime.c - CSRCS += lib_ctimer.c - else - -CSRCS += lib_mktime.c lib_gmtime.c lib_gmtimer.c - +CSRCS += lib_mktime.c # lib_gmtime.c lib_gmtimer.c - ifdef CONFIG_TIME_EXTENDED - CSRCS += lib_dayofweek.c lib_asctime.c lib_asctimer.c lib_ctime.c - CSRCS += lib_ctimer.c - - And this: - - stdlib\lib_strtof.c - stdlib\lib_strtof.c (76,36) : WARNING (32) Division by zero encountered - stdlib\lib_strtof.c (102,36) : WARNING (32) Division by zero encountered - - Which can be worked around by removing it from the build - - The consequence is, of course, that these interfaces will not be available - to applications. - - Alternatively, you can use 'make -i' to build the system. The above - errors will occur, but will not stop the build (unless the failed build - objects are brought into the link). The has the negative side effects - that (1) the archives will always be rebuild in the directories where - the error occur, and (2) you might miss other, real compilation error - since these will no longer stop the compilation. + I verifed compilation using 5.30 on June 2, 2019. To use this version, + I had to make spurious modification to the implementation of gmtimer() to + work around an internal compiler error. I have still not verified that + are no errors in the compiled code. Other Versions If you use any version of ZDS-II other than 5.1.1, 5.2.1, or 5.3.0 or diff --git a/configs/makerlisp/README.txt b/configs/makerlisp/README.txt index b7e8f87954..66f68409a5 100644 --- a/configs/makerlisp/README.txt +++ b/configs/makerlisp/README.txt @@ -37,47 +37,10 @@ ZDS-II Compiler Versions Version 5.3.0 - The initial bring-up of the MakerLisp board used the ZiLOG ZDS-II 5.3.0 - toolchain. To use this toolchain, I had to suppress the gmtime() and - gmtimer() because these were causing an internal compiler error: - - time\lib_gmtimer.c - P2: Internal Error(0xB47E59): - Please contact Technical Support - - This is the change to suppress building these files: - - diff --git a/libs/libc/time/Make.defs b/libs/libc/time/Make.defs - index 5c9b746778..8327e287f4 100644 - --- a/libs/libc/time/Make.defs - +++ b/libs/libc/time/Make.defs - @@ -44,7 +44,7 @@ ifdef CONFIG_LIBC_LOCALTIME - CSRCS += lib_localtime.c lib_asctime.c lib_asctimer.c lib_ctime.c - CSRCS += lib_ctimer.c - else - -CSRCS += lib_mktime.c lib_gmtime.c lib_gmtimer.c - +CSRCS += lib_mktime.c # lib_gmtime.c lib_gmtimer.c - ifdef CONFIG_TIME_EXTENDED - CSRCS += lib_dayofweek.c lib_asctime.c lib_asctimer.c lib_ctime.c - CSRCS += lib_ctimer.c - - And there is also this: - - stdlib\lib_strtof.c - stdlib\lib_strtof.c (76,36) : WARNING (32) Division by zero encountered - stdlib\lib_strtof.c (102,36) : WARNING (32) Division by zero encountered - - Which can be worked around by removing it from the build - - The consequence is, of course, that these interfaces will not be available - to applications. - - Alternatively, you can use 'make -i' to build the system. The above - errors will occur, but will not stop the build (unless the failed build - objects are brought into the link). The has the negative side effects - that (1) the archives will always be rebuild in the directories where - the error occur, and (2) you might miss other, real compilation error - since these will no longer stop the compilation. + I verifed compilation using 5.30 on June 2, 2019. To use this version, + I had to make spurious modification to the implementation of gmtimer() to + work around an internal compiler error. I have still not verified that + are no errors in the compiled code. Other Versions If you use any version of ZDS-II other than 5.3.0 or if you install ZDS-II diff --git a/libs/libc/time/lib_gmtimer.c b/libs/libc/time/lib_gmtimer.c index 67925ed9da..641a516752 100644 --- a/libs/libc/time/lib_gmtimer.c +++ b/libs/libc/time/lib_gmtimer.c @@ -188,33 +188,33 @@ static void clock_utc2calendar(time_t days, FAR int *year, FAR int *month, days -= value * (4 * 365 + 1); /* Remaining days */ value <<= 2; /* Years since the epoch */ - /* Then we will brute force the next 0-3 years */ + /* Then we will brute force the next 0-3 years + * + * Is this year a leap year? (we'll need this later too) + */ - for (; ; ) + leapyear = clock_isleapyear(value + 1970); + + /* Get the number of days in the year */ + + tmp = (leapyear ? 366 : 365); + + /* Do we have that many days left to account for? */ + + while (days >= tmp) { - /* Is this year a leap year (we'll need this later too) */ + /* Yes.. bump up the year and subtract the number of days in the year */ + + value++; + days -= tmp; + + /* Is the next year a leap year? */ leapyear = clock_isleapyear(value + 1970); - /* Get the number of days in the year */ + /* Get the number of days in the next year */ tmp = (leapyear ? 366 : 365); - - /* Do we have that many days? */ - - if (days >= tmp) - { - /* Yes.. bump up the year */ - - value++; - days -= tmp; - } - else - { - /* Nope... then go handle months */ - - break; - } } /* At this point, value has the year and days has number days into this