Port-i386 archive

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

curcpu() and curlwp()



I've just been looking at the definitions of curcpu() etc on
i386 and amd64 (they differ only in the segment register used).

in sys/arch/i386/include/cpu.h we have:

__inline static lwp_t * __attribute__ ((const))
x86_curlwp(void)
{
        lwp_t *l;

        __asm volatile("movl %%fs:%1, %0" :
            "=r" (l) :
            "m"
            (*(struct cpu_info * const *)offsetof(struct cpu_info, ci_curlwp)));
        return l;
}

I think it should be:
        "m" (((const struct cpu_info *)0)->ci_curlwp)

The actual code seems to be a reference to a pointer to 'struct cpu_info'.
The generated code is probably identical, but the inferences are different.

(cpu_set_curpri() is broken in a different, but similar way.)

I also think that the curcpu() and culwp() functions need not be volatile.

        David

-- 
David Laight: david%l8s.co.uk@localhost


Home | Main Index | Thread Index | Old Index