Port-powerpc archive

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

Powerpc signal handler with floating point registers



Title: Powerpc signal handler with floating point registers

Hi,
I'm using NetBSD 2.0-RC4 on a powerpc 603 processor which has the hardware floating point component (enabled). I ran into a situation where it seems the powerpc floating point registers are not saved/restored properly by the signal handler.

The following testing program has a floating computing loop inside "main" routine. It also sets up a SIGALRM handler to perform another floating point calculation periodically. When it runs, we got a lot of error message from the "fprintf" below, which means the signal handler probably interferes with the main program and does not restore the floating point registers when it returns.

Any idea why this could happen? I tested on i386 ports and didn't find the same problem, so I guess the problem is architecture specific.

Thanks,
Chris

#include <stdio.h>
#include <signal.h>
#include <sys/time.h>

int alarms;

void testB_alrm_handler(int sig)
{
        static double x = 1.2;
        x = x*x;
        alarms++;
}

int main(void)
{
        register double new = 0;
        register double old = new;
        struct itimerval it;

        signal(SIGALRM, testB_alrm_handler);

        it.it_value.tv_sec = 0;
        it.it_value.tv_usec = 20000;
        it.it_interval = it.it_value;
        setitimer(ITIMER_REAL, &it, NULL);

        for (;;) {
                new = new + 1;
                if (new != old + 1)
                        fprintf(stderr, "ERROR. alarms=%d %g != %g\n", alarms, new, old);
                old = new;
        }
}



Home | Main Index | Thread Index | Old Index