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.

This commit is contained in:
Gregory Nutt
2019-06-10 09:49:11 -06:00
parent 750e45ad6e
commit 417e681cbb
4 changed files with 32 additions and 135 deletions
+20 -20
View File
@@ -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