Constraint for inline assembly with one register used for both an input variable and an output variable

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

 



Hi,

When we write syscall wrappers with inline assembly, we often need to
assign one register for both an input variable and an output variable. 
Per https://gcc.gnu.org/onlinedocs/gcc/Local-Register-Variables.html,
such an inline assembly can be written

register int *p1 asm ("r0") = …;
register int *p2 asm ("r1") = …;
register int *result asm ("r0");
asm ("sysint" : "=r" (result) : "0" (p1), "r" (p2));

Note the use of constraint "0" for p1 which shares the same register as
result.  But currently in the Linux kernel vDSO, they are actually
written like

asm ("sysint" : "=r" (result) : "r" (p1), "r" (p2));

So the question here: is using "r" for p1 valid or not?  Do we need to
"fix" this everywhere for the vDSO?

-- 
Xi Ruoyao <xry111@xxxxxxxxxxx>
School of Aerospace Science and Technology, Xidian University




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux