How to set REX prefix when using RDRAND?
Florian Weimer
fweimer@redhat.com
Mon Oct 12 19:59:00 GMT 2015
On 10/12/2015 07:41 PM, Jeffrey Walton wrote:
> while (size && safety)
> {
> char rc;
> __asm__ volatile(
> #if BOOL_X86
> "rdrandl %0 ; setc %1"
> #else
> "rdrandq %0 ; setc %1"
> #endif
> : "=rm" (val), "=qm" (rc)
> :
> : "cc"
> );
I don't think RDRAND supports memory operand, so the constraint is
incorrect, and a width suffix is not required.
> if (rc)
> {
> size_t count = (size < sizeof(val) ? size : sizeof(val));
> memcpy(output, &val, count);
> size =- count;
You forgot to increment the output variable.
Florian
More information about the Gcc-help
mailing list