timezone stuff on 64 bit machines

Erik Troan ewt at redhat.com
Wed Oct 18 16:24:56 UTC 1995

I'm trying to use the timezone stuff you maintain on a 64-bit Alpha
running Linux. It builds fine, but the timezone compiler has some
trouble (it runs forever). I tracked the problem down to this code from

        if (days >= 0)
                for ( ; ; ) {
                        yleap = isleap(y);
                        if (days < (long) year_lengths[yleap])
                        days = days - (long) year_lengths[yleap];
        else do {
                yleap = isleap(y);
                days = days + (long) year_lengths[yleap];
        } while (days < 0);

This works fine when the number of years you can represent is small, as it
is on a 32 bit machine. On a 64-bit machine however, you have some 
4 billion more years to worry about. That means this loop has to repeat
well over 4 billion times, and that takes 1 while :-)

Any ideas on how to fix this?


 "Eggheads unite!  You have nothing to lose but your yolks" - Adlai Stevenson

    Erik Troan   =   http://sunsite.unc.edu/ewt/   =   ewt at sunsite.unc.edu

More information about the tz mailing list