mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-15 07:19:18 +00:00
Make fixes and improvements
- Introduce __assert_disable global - Improve strsignal() thread safety - Make system call tracing thread safe - Fix SO_RCVTIMEO / SO_SNDTIMEO on Windows - Refactor DescribeFoo() functions into one place - Fix fork() on Windows when TLS and MAP_STACK exist - Round upwards in setsockopt(SO_RCVTIMEO) on Windows - Disable futexes on OpenBSD which seem extremely broken - Implement a better kludge for monotonic time on Windows
This commit is contained in:
parent
5d837c4e7c
commit
fbc053e018
186 changed files with 1836 additions and 1325 deletions
|
@ -16,6 +16,7 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/assert.h"
|
||||
#include "libc/bits/bits.h"
|
||||
#include "libc/bits/initializer.internal.h"
|
||||
#include "libc/bits/safemacros.internal.h"
|
||||
|
@ -44,10 +45,10 @@ static long double GetTimeSample(void) {
|
|||
uint64_t tick1, tick2;
|
||||
long double time1, time2;
|
||||
sched_yield();
|
||||
time1 = dtime(CLOCK_MONOTONIC_FAST);
|
||||
time1 = dtime(CLOCK_REALTIME_FAST);
|
||||
tick1 = rdtsc();
|
||||
nanosleep(&(struct timespec){0, 1000000}, NULL);
|
||||
time2 = dtime(CLOCK_MONOTONIC_FAST);
|
||||
time2 = dtime(CLOCK_REALTIME_FAST);
|
||||
tick2 = rdtsc();
|
||||
return (time2 - time1) * 1e9 / MAX(1, tick2 - tick1);
|
||||
}
|
||||
|
@ -75,13 +76,13 @@ static long double MeasureNanosPerCycle(void) {
|
|||
void RefreshTime(void) {
|
||||
struct Now now;
|
||||
now.cpn = MeasureNanosPerCycle();
|
||||
now.r0 = dtime(CLOCK_REALTIME);
|
||||
now.r0 = dtime(CLOCK_REALTIME_FAST);
|
||||
now.k0 = rdtsc();
|
||||
memcpy(&g_now, &now, sizeof(now));
|
||||
}
|
||||
|
||||
static long double nowl_sys(void) {
|
||||
return dtime(CLOCK_REALTIME);
|
||||
return dtime(CLOCK_REALTIME_FAST);
|
||||
}
|
||||
|
||||
static long double nowl_art(void) {
|
||||
|
@ -92,7 +93,8 @@ static long double nowl_art(void) {
|
|||
static long double nowl_vdso(void) {
|
||||
long double secs;
|
||||
struct timespec tv;
|
||||
__gettime(CLOCK_REALTIME, &tv);
|
||||
assert(__gettime);
|
||||
__gettime(CLOCK_REALTIME_FAST, &tv);
|
||||
secs = tv.tv_nsec;
|
||||
secs *= 1 / 1e9L;
|
||||
secs += tv.tv_sec;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue