mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-06-27 14:58:30 +00:00
Improve Windows sleep accuracy from 15ms to 15µs
This commit is contained in:
parent
b40140e6c5
commit
b490e23d63
16 changed files with 189 additions and 67 deletions
|
@ -26,7 +26,7 @@ long __get_minsigstksz(void) {
|
|||
struct AuxiliaryValue x;
|
||||
x = __getauxval(AT_MINSIGSTKSZ);
|
||||
if (x.isfound) {
|
||||
return MAX(_MINSIGSTKSZ, x.value);
|
||||
return MAX(_MINSIGSTKSZ - 1024, x.value) + 1024;
|
||||
} else {
|
||||
return _MINSIGSTKSZ;
|
||||
}
|
||||
|
|
|
@ -17,7 +17,14 @@
|
|||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/fmt/wintime.internal.h"
|
||||
#include "libc/limits.h"
|
||||
#include "libc/stdckdint.h"
|
||||
|
||||
int64_t TimeSpecToWindowsTime(struct timespec t) {
|
||||
return t.tv_nsec / 100 + (t.tv_sec + MODERNITYSECONDS) * HECTONANOSECONDS;
|
||||
int64_t TimeSpecToWindowsTime(struct timespec time) {
|
||||
int64_t wt;
|
||||
if (ckd_add(&wt, time.tv_sec, MODERNITYSECONDS) ||
|
||||
ckd_mul(&wt, wt, HECTONANOSECONDS) ||
|
||||
ckd_add(&wt, wt, time.tv_nsec / 100))
|
||||
wt = INT64_MAX;
|
||||
return wt;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue