ddvk / remarkable2-framebuffer

remarkable2 framebuffer reversing
MIT License
284 stars 22 forks source link

sem_timedwait is based on absolute time, not relative #46

Closed snelg closed 3 years ago

snelg commented 3 years ago

Update for PR #45

snelg commented 3 years ago

Hmm, no, this doesn't work consistently

raisjn commented 3 years ago

not sure, but i think we need to do something like the below, otherwise nsec will not be a valid value sometimes

total_time = (tv.sec*1e9 + tv.nsec) + wait_time_in_ns;
sec = total_time / ns_in_sec;
nsec = total_time % ns_in_sec;

alternatively:

tv.nsec += wait_time_in_ns;
if tv.nsec > 1e9:
  tv.nsec -= 1e9
  tv.sec++
snelg commented 3 years ago

Right, fixed the nsec overflow/wraparound.