cosmopolitan/libc/nt
Justine Tunney dd8544c3bd
Delve into clock rabbit hole
The worst issue I had with consts.sh for clock_gettime is how it defined
too many clocks. So I looked into these clocks all day to figure out how
how they overlap in functionality. I discovered counter-intuitive things
such as how CLOCK_MONOTONIC should be CLOCK_UPTIME on MacOS and BSD, and
that CLOCK_BOOTTIME should be CLOCK_MONOTONIC on MacOS / BSD. Windows 10
also has some incredible new APIs, that let us simplify clock_gettime().

  - Linux CLOCK_REALTIME         -> GetSystemTimePreciseAsFileTime()
  - Linux CLOCK_MONOTONIC        -> QueryUnbiasedInterruptTimePrecise()
  - Linux CLOCK_MONOTONIC_RAW    -> QueryUnbiasedInterruptTimePrecise()
  - Linux CLOCK_REALTIME_COARSE  -> GetSystemTimeAsFileTime()
  - Linux CLOCK_MONOTONIC_COARSE -> QueryUnbiasedInterruptTime()
  - Linux CLOCK_BOOTTIME         -> QueryInterruptTimePrecise()

Documentation on the clock crew has been added to clock_gettime() in the
docstring and in redbean's documentation too. You can read that to learn
interesting facts about eight essential clocks that survived this purge.
This is original research you will not find on Google, OpenAI, or Claude

I've tested this change by porting *NSYNC to become fully clock agnostic
since it has extensive tests for spotting irregularities in time. I have
also included these tests in the default build so they no longer need to
be run manually. Both CLOCK_REALTIME and CLOCK_MONOTONIC are good across
the entire amd64 and arm64 test fleets.
2024-09-04 01:32:46 -07:00
..
advapi32 Make improvements 2024-02-12 10:23:00 -08:00
API-MS-Win-Core-Memory-l1-1-6 Make some new Windows 10 memory APIs available 2024-07-19 22:26:49 -07:00
API-MS-Win-Core-Realtime-l1-1-1 Delve into clock rabbit hole 2024-09-04 01:32:46 -07:00
API-MS-Win-Core-Synch-l1-2-0 Add OpenMP support 2024-01-28 22:39:02 -08:00
BCryptPrimitives Make improvements 2024-02-12 10:23:00 -08:00
comdlg32 Add OpenMP support 2024-01-28 22:39:02 -08:00
enum Experiment with supporting Windows Arm64 natively 2024-08-16 06:43:59 -07:00
gdi32 Add OpenMP support 2024-01-28 22:39:02 -08:00
iphlpapi Add OpenMP support 2024-01-28 22:39:02 -08:00
kernel32 Delve into clock rabbit hole 2024-09-04 01:32:46 -07:00
nt Reduce header complexity 2023-11-28 14:39:42 -08:00
ntdll Add OpenMP support 2024-01-28 22:39:02 -08:00
pdh Add OpenMP support 2024-01-28 22:39:02 -08:00
PowrProf Add OpenMP support 2024-01-28 22:39:02 -08:00
psapi Add OpenMP support 2024-01-28 22:39:02 -08:00
struct Fix the build 2024-08-26 16:44:05 -07:00
thunk Walk back most uses of __STRICT_ANSI__ 2024-02-27 04:09:49 -08:00
typedef Reduce header complexity 2023-11-28 14:39:42 -08:00
user32 Add OpenMP support 2024-01-28 22:39:02 -08:00
ws2_32 Add OpenMP support 2024-01-28 22:39:02 -08:00
accounting.h Reduce header complexity 2023-11-28 14:39:42 -08:00
automation.h Reduce header complexity 2023-11-28 14:39:42 -08:00
BUILD.mk Delve into clock rabbit hole 2024-09-04 01:32:46 -07:00
codegen.h Make improvements 2020-12-01 03:43:40 -08:00
codegen.sh more modeline errata (#1019) 2023-12-16 23:07:10 -05:00
comdlg.h Reduce header complexity 2023-11-28 14:39:42 -08:00
comms.h Reduce header complexity 2023-11-28 14:39:42 -08:00
console.h Add WIN32 pseudo console APIs 2023-12-10 01:29:25 -08:00
createfile.h Reduce header complexity 2023-11-28 14:39:42 -08:00
debug.h Reduce header complexity 2023-11-28 14:39:42 -08:00
dll.h Resurrect <windows.h> as <windowsesque.h> 2024-02-21 16:41:11 -08:00
efi.h Reduce header complexity 2023-11-28 14:39:42 -08:00
errors.h Run clang-format on most sources 2023-04-27 05:44:32 -07:00
events.h Resurrect <windows.h> as <windowsesque.h> 2024-02-21 16:41:11 -08:00
files.h Reduce header complexity 2023-11-28 14:39:42 -08:00
iocp.h Reduce header complexity 2023-11-28 14:39:42 -08:00
ipc.h Reduce header complexity 2023-11-28 14:39:42 -08:00
iphlpapi.h Reduce header complexity 2023-11-28 14:39:42 -08:00
master.sh Delve into clock rabbit hole 2024-09-04 01:32:46 -07:00
memory.h Make realloc() go 100x faster on Linux/NetBSD 2024-07-07 12:40:30 -07:00
messagebox.h Reduce header complexity 2023-11-28 14:39:42 -08:00
ntdll.h Reduce header complexity 2023-11-28 14:39:42 -08:00
ntdllimport.h Remove .internal from more header filenames 2024-08-04 12:52:25 -07:00
ntdllimport.S Remove .internal from more header filenames 2024-08-04 12:52:25 -07:00
paint.h Reduce header complexity 2023-11-28 14:39:42 -08:00
pdh.h Reduce header complexity 2023-11-28 14:39:42 -08:00
pedef.internal.h Rerun clang-format on the repo (#1217) 2024-06-15 16:34:48 -04:00
privilege.h Release Cosmopolitan v3.3 2024-02-20 13:27:59 -08:00
process.h Reduce header complexity 2023-11-28 14:39:42 -08:00
registry.h Reduce header complexity 2023-11-28 14:39:42 -08:00
runtime.h Experiment with supporting Windows Arm64 natively 2024-08-16 06:43:59 -07:00
signals.h Reduce header complexity 2023-11-28 14:39:42 -08:00
startupinfo.h Reduce header complexity 2023-11-28 14:39:42 -08:00
synchronization.h Introduce getcpu() system call from glibc 2024-02-21 18:17:20 -08:00
system.h Reduce header complexity 2023-11-28 14:39:42 -08:00
systeminfo.h Reduce header complexity 2023-11-28 14:39:42 -08:00
sysv2nt.S Fix more vi modelines (#1006) 2023-12-13 02:28:11 -05:00
thread.h Reduce header complexity 2023-11-28 14:39:42 -08:00
time.h Delve into clock rabbit hole 2024-09-04 01:32:46 -07:00
windows.h Reduce header complexity 2023-11-28 14:39:42 -08:00
winsock.h Reduce header complexity 2023-11-28 14:39:42 -08:00