On Wed, 8 Apr 2020, Vineet Gupta via Libc-alpha wrote:

> +#  define _FPU_SETS(cw) __asm__ volatile ("bset %0, %0, 31   \r\n" \
> +                                       "sr   %0, [0x301]     \r\n" \
> +                                          : : "r" (cw))

This asm doesn't look safe; it's modifying an input operand.  I think the 
compiler will assume the register it puts %0 in is unmodified by the asm, 
because it's listed as an input.

As an architecture-specific interface, it's not very clear if the 
interface for _FPU_SETS should be that it modifies the variable passed as 
an argument, but I'd guess not.  My suggestion would be to define the 
macro (using do { ... } while (0)) to copy the argument to a temporary 
variable, and do the bit-set operation in C code on that temporary 
variable rather than as part of the asm.

-- 
Joseph S. Myers
jos...@codesourcery.com

_______________________________________________
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc

Reply via email to