This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: How to set REX prefix when using RDRAND?
- From: Florian Weimer <fweimer at redhat dot com>
- To: noloader at gmail dot com, Mason <slash dot tmp at free dot fr>
- Cc: GCC help <gcc-help at gcc dot gnu dot org>
- Date: Mon, 12 Oct 2015 21:58:01 +0200
- Subject: Re: How to set REX prefix when using RDRAND?
- Authentication-results: sourceware.org; auth=none
- References: <CAH8yC8notjAYqQ4FRMvtP8rV+Ks=G7i83mbae_ttAnBMJz5rEg at mail dot gmail dot com> <561B7D6A dot 4000709 at free dot fr> <CAH8yC8=QOareae4u63-tSxPhLz_RtYOBrvzTz_8mMCmgm8cUfg at mail dot gmail dot com>
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