[zeromq-dev] [PATCH] zmq::clock_t : return correct value in rdtsc() on solaris
Martin Pales
m.pales at gmail.com
Thu Oct 14 16:13:34 CEST 2010
On Thu, Oct 14, 2010 at 3:37 PM, Steven McCoy <steven.mccoy at miru.hk> wrote:
> On 14 October 2010 20:24, Martin Pales <m.pales at gmail.com> wrote:
>
>> Hello,
>>
>> the attached patch ensures that a correct rdtsc value is returned when
>> compiled
>> with sunstudio 12 compiler.
>>
>>
> I'm running Sun ONE Studio on Linux at it is working fine with the
> following which is pretty much the same as 0MQ's clock:
>
> uint32_t lo, hi;
>
> /* We cannot use "=A", since this would use %rax on x86_64 */
> asm volatile ("rdtsc" : "=a" (lo), "=d" (hi));
>
Yes. A completely correct code should use 32 bit registers explicitly.
It would be something like this:
asm("rdtsc; movl %%edx,%0; movl %%eax,%1"
: "=r" (hi), "=r" (lo) : : "%edx", "%eax");
However, the attached patch should also work correctly.
Martin
> return (pgm_time_t)hi << 32 | lo;
> Where pgm_time_t is effectively uint64_t.
>
> --
> Steve-o
>
>
> _______________________________________________
> zeromq-dev mailing list
> zeromq-dev at lists.zeromq.org
> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20101014/7f770cc8/attachment.htm>
More information about the zeromq-dev
mailing list