Port-vax archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Bad xasm in __lwp_getprivate_fast
While doing some testing I came across this not-so-correct extended
assembler in mcontext.h:
static __inline void *
__lwp_getprivate_fast(void)
{
register void *tcb __asm("r0");
__asm("chmk %0" :: "i"(SYS__lwp_getprivate) : "r0");
return tcb;
}
The result from chmk will be in r0.
The asm line says that r0 will be destroyed in the asm statement. In
this particular case it will most likely work because gcc handles tcb as
an uninitialized variable and it will get the r0 value anyway as long as
the code is not reordered (which it may be). If tcb is assigned 0 before
the asm statement it will fail.
Correct would be to write something like
__asm("chmk %0" : "=r"(tcb): "i"(SYS__lwp_getprivate));
which tells that the result will be in tcb (e.g. r0).
Comments? Otherwise I will go ahead and fix this.
-- Ragge
Home |
Main Index |
Thread Index |
Old Index