Port-macppc archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Problems with registers save/restore on context switch?



On Tue, Dec 17, 2013 at 23:18:51 +0400, Valery Ushakov wrote:

> Attached program converts time_t t = 1; with gmtime_r(3) in a loop and
> checks tm_year of the result, expecting 70.  Sometimes (rarely) it
> will see bogus results.

*sigh* Really attached this time, hopefully :)

-uwe
#include <stdio.h>
#include <string.h>
#include <time.h>


int
main(int argc, char **argv)
{
    struct tm tm;
    time_t t;
    int i;

    t = 1;

    tzset();
    for (i = 0; i < 100000000; ++i) {
        struct tm *tmp;
        tmp = gmtime_r(&t, &tm);
        if (tmp == NULL) {
            perror("localtime");
            continue;
        }

        if (tm.tm_year != 70) {
            printf("%04d-%02d-%02dT%02d:%02d:%02d\n",
                   1900 + tm.tm_year, tm.tm_mon + 1, tm.tm_mday,
                   tm.tm_hour, tm.tm_min, tm.tm_sec);
        }
    }

    return 0;
}


Home | Main Index | Thread Index | Old Index