Is it possible to manufacture, as a macro, a sort of zero-cost cast via inline assembly?
In many instances, I would like to pass 32 bit integers, which are already “in place” through interfaces that take 64 bit integers. But C doesn’t like leaving upper bits indeterminate and casting or trying to extend the 32 bits to 64 via a union makes compilers either zero-extend or sign-extend the 32 bit number.
Example:
void g(unsigned long );
void f(int X){
unsigned long XX = (unsigned)X; //mov %edi, %edi
g(XX);
}
Is it possible to replace the cast with some JUST_PRETEND_ITS_AN_UNSIGNED_LONG_WITHOUT_DOING_ANYTHING(X)
?