cosmopolitan/tool/build
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
..
dso Get rid of .internal.h convention in LIBC_INTRIN 2024-07-19 19:38:00 -07:00
lib Remove .internal from more header filenames 2024-08-04 12:52:25 -07:00
apelink.c Remove .internal from more header filenames 2024-08-04 12:52:25 -07:00
ar.c Remove .internal from more header filenames 2024-08-04 12:52:25 -07:00
assimilate.c Remove .internal from more header filenames 2024-08-04 12:52:25 -07:00
bigmul.c Remove .internal from more header filenames 2024-08-04 12:52:25 -07:00
BUILD.mk Fix ctype.h and wctype.h 2024-07-21 15:54:17 -07:00
chmod.c Apply clang-format update to repo (#1154) 2024-04-25 10:38:00 -07:00
cocmd.c flip et / noet in modelines 2023-12-07 22:17:11 -05:00
compile.c Delve into clock rabbit hole 2024-09-04 01:32:46 -07:00
cp.c Introduce libc/mem/tinymalloc.inc 2024-05-07 03:19:49 -07:00
dd.c Fix some static analysis issues 2024-07-27 09:16:54 -07:00
dlopen_test.c Support 40 cosmo_dlopen() function parameters 2024-01-04 13:41:26 -08:00
dropcache.c Stop using .com extension in monorepo 2024-03-03 03:12:19 -08:00
echo.c Apply clang-format update to repo (#1154) 2024-04-25 10:38:00 -07:00
elf2pe.c Experiment with supporting Windows Arm64 natively 2024-08-16 06:43:59 -07:00
elf2pe.h Experiment with supporting Windows Arm64 natively 2024-08-16 06:43:59 -07:00
false.c flip et / noet in modelines 2023-12-07 22:17:11 -05:00
fastdiff.c Apply clang-format update to repo (#1154) 2024-04-25 10:38:00 -07:00
findape.c Make improvements 2024-02-12 10:23:00 -08:00
findelf.c Make improvements 2024-02-12 10:23:00 -08:00
findpe.c Make improvements 2024-02-12 10:23:00 -08:00
fixupobj.c Make atomics faster on aarch64 2024-08-16 11:14:46 -07:00
freebsd2sysv.c Fix some static analysis issues 2024-07-27 09:16:54 -07:00
gzip.c Fix some static analysis issues 2024-07-27 09:16:54 -07:00
helpop.c Remove .internal from more header filenames 2024-08-04 12:52:25 -07:00
killall.c Remove .internal from more header filenames 2024-08-04 12:52:25 -07:00
lz4toasm.c Remove .internal from more header filenames 2024-08-04 12:52:25 -07:00
march-native.c Improve -march=native micro-architecture detection 2024-05-29 10:12:49 -07:00
mkdeps.c Remove .internal from more header filenames 2024-08-04 12:52:25 -07:00
mkdir.c Apply clang-format update to repo (#1154) 2024-04-25 10:38:00 -07:00
mktemper.c Apply clang-format update to repo (#1154) 2024-04-25 10:38:00 -07:00
mv.c Introduce libc/mem/tinymalloc.inc 2024-05-07 03:19:49 -07:00
nproc.c Cull the examples folder 2023-10-11 21:45:32 -07:00
objbincopy.c Remove .internal from more header filenames 2024-08-04 12:52:25 -07:00
package.c Remove .internal from more header filenames 2024-08-04 12:52:25 -07:00
pecheck.c Fix ctype.h and wctype.h 2024-07-21 15:54:17 -07:00
pledge.c Remove .internal from more header filenames 2024-08-04 12:52:25 -07:00
printf.c flip et / noet in modelines 2023-12-07 22:17:11 -05:00
pwd.c flip et / noet in modelines 2023-12-07 22:17:11 -05:00
reboot.c Run clang-format (#1197) 2024-06-01 16:30:43 -04:00
resymbol.c Introduce libc/mem/tinymalloc.inc 2024-05-07 03:19:49 -07:00
rm.c Introduce libc/mem/tinymalloc.inc 2024-05-07 03:19:49 -07:00
runit.c Fix some static analysis issues 2024-07-27 09:16:54 -07:00
runit.h Fix bugs and add security features to redbean 2022-04-18 00:01:26 -07:00
runitd.c Delve into clock rabbit hole 2024-09-04 01:32:46 -07:00
sha256sum.c Remove .internal from more header filenames 2024-08-04 12:52:25 -07:00
shutdown.c Cull the examples folder 2023-10-11 21:45:32 -07:00
summy.c Apply clang-format update to repo (#1154) 2024-04-25 10:38:00 -07:00
symtab.c Introduce libc/mem/tinymalloc.inc 2024-05-07 03:19:49 -07:00
touch.c Apply clang-format update to repo (#1154) 2024-04-25 10:38:00 -07:00
unbuffer.c Stop using .com extension in monorepo 2024-03-03 03:12:19 -08:00
unveil.c Apply clang-format update to repo (#1154) 2024-04-25 10:38:00 -07:00
verynice.c Apply clang-format update to repo (#1154) 2024-04-25 10:38:00 -07:00
zipcopy.c Remove .internal from more header filenames 2024-08-04 12:52:25 -07:00
zipobj.c Remove .internal from more header filenames 2024-08-04 12:52:25 -07:00