Hi all,
Occasionally I saw that some inline assembly codes in opensolaris are strange.
say:
extern __inline__ void unlock_hres_lock(void)
{
__asm__ __volatile__(
"lock; incl %0"
: /* no output */
: "m" (hres_lock)
: "cc");
}
hres_lock is an *input only* operand, but the incl instruction writes it.
Shouldn't
it to be something like this?
__asm__ __volatile__ ( "lock; incl %0": "+m"(hres_lock): : "cc" );
Another one:
extern __inline__ void atomic_or_long(ulong_t *target, ulong_t bits)
{
__asm__ __volatile__(
"lock; orq %1, (%0)"
: /* no output */
: "r" (target), "r" (bits));
}
In the example above, the orq instruction writes to a memory address
indicated by %0, but without telling gcc that "memory" is clobbered.
It seems that all functions defined in usr/src/uts/intel/asm/atomic.h
has the same problem.
I'm not sure if these functions are really needed by Solaris, after all
it can only be compiled by gcc(I have no idea if SUN Studio supports
inline assembly or not). But if they are needed, maybe they should be
fixed.
--
Thanks,
Jike Song, SW Engineer
Sun Microsystems China(ERI)
Tel: (86-10)62673147
_______________________________________________
opensolaris-code mailing list
[email protected]
http://mail.opensolaris.org/mailman/listinfo/opensolaris-code