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

Re: [Minios-devel] [UNIKRAFT PATCH v2] lib/nolibc: Fix remaining time in nanosleep



Hi Dafna,

On 09/16/2018 12:09 PM, Dafna Hirschfeld wrote:
Hi,
I found some bugs when adding the nanosleep fix to newlib,
It seems that the time measurement returns wrong values.
I wrote a main function that just calls ukplat_monotonic_clock in a loop,
What you're seeing is that the output jumps between low and very high 
values, right?
I tested the code and noticed that your test code doesn't include 
uk/plat/time.h, leading to a warning about implicit declaration for 
ukplat_monotonic_clock(). While everything links in the end because the 
function is available during linking stage, this leads to a subtle 
change in behavior: The code generated for main.o assumes that 
ukplat_monotonic_clock() returns a signed int (the default assumption 
for an unknown function), so the compiler issues a movslq instruction to 
cast the return value to an __nsec. As a result, values in bits 32-63 
are lost, and if bit 31 is 1, the result, interpreted as an unsigned 
long, is very large.
Adding uk/plat/time.h as an include to your test code fixes the problem.

Cheers,
Florian

_______________________________________________
Minios-devel mailing list
Minios-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/minios-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.