cosmopolitan/libc/sock
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
..
struct Avoid linker conflicts on DescribeFoo symbols 2024-08-24 18:10:22 -07:00
accept-nt.c Get rid of .internal.h convention in LIBC_INTRIN 2024-07-19 19:38:00 -07:00
accept.c flip et / noet in modelines 2023-12-07 22:17:11 -05:00
accept4-sysv.c Fix typo in accept4-sysv.c (#1235) 2024-07-19 05:46:29 -07:00
accept4.c Get rid of .internal.h convention in LIBC_INTRIN 2024-07-19 19:38:00 -07:00
alg.h Reduce header complexity 2023-11-28 14:39:42 -08:00
basesocket.c Apply clang-format update to repo (#1154) 2024-04-25 10:38:00 -07:00
bind-nt.c flip et / noet in modelines 2023-12-07 22:17:11 -05:00
bind-sysv.c flip et / noet in modelines 2023-12-07 22:17:11 -05:00
bind.c Get rid of .internal.h convention in LIBC_INTRIN 2024-07-19 19:38:00 -07:00
BUILD.mk Update Musl Libc code 2024-07-30 22:51:29 -07:00
closesocket-nt.c flip et / noet in modelines 2023-12-07 22:17:11 -05:00
connect-nt.c Fix getpeername() bug on Windows 2024-08-25 11:28:53 -07:00
connect-sysv.c flip et / noet in modelines 2023-12-07 22:17:11 -05:00
connect.c Get rid of .internal.h convention in LIBC_INTRIN 2024-07-19 19:38:00 -07:00
fixupnewsockfd.c flip et / noet in modelines 2023-12-07 22:17:11 -05:00
gethostips.c Remove .internal from more header filenames 2024-08-04 12:52:25 -07:00
getsockname.c Fix getpeername() bug on Windows 2024-08-25 11:28:53 -07:00
getsockopt-nt.c flip et / noet in modelines 2023-12-07 22:17:11 -05:00
getsockopt.c Get rid of .internal.h convention in LIBC_INTRIN 2024-07-19 19:38:00 -07:00
goodsocket.c Apply clang-format update to repo (#1154) 2024-04-25 10:38:00 -07:00
goodsocket.internal.h Add dontthrow attribute to most libc functions 2024-01-09 01:26:03 -08:00
ifaddrs.c flip et / noet in modelines 2023-12-07 22:17:11 -05:00
ifaddrs.h Add dontthrow attribute to most libc functions 2024-01-09 01:26:03 -08:00
in.h Add libresolv from Musl Libc 2023-12-08 20:04:10 -08:00
in6addr_any.c Make improvements 2024-01-29 16:31:58 -08:00
in6addr_loopback.c Make improvements 2024-01-29 16:31:58 -08:00
inet_addr.c flip et / noet in modelines 2023-12-07 22:17:11 -05:00
inet_aton.c Fix ctype.h and wctype.h 2024-07-21 15:54:17 -07:00
inet_ntoa.c flip et / noet in modelines 2023-12-07 22:17:11 -05:00
inet_ntop.c Apply clang-format update to repo (#1154) 2024-04-25 10:38:00 -07:00
inet_pton.c Remove .internal from more header filenames 2024-08-04 12:52:25 -07:00
internal.h Fix bugs in poll(), select(), ppoll(), and pselect() 2024-09-02 00:29:52 -07:00
iovec2nt.c Remove .internal from more header filenames 2024-08-04 12:52:25 -07:00
ipclassify.internal.h Reduce header complexity 2023-11-28 14:39:42 -08:00
kntwsadata.c Get rid of .internal.h convention in LIBC_INTRIN 2024-07-19 19:38:00 -07:00
listen-nt.c flip et / noet in modelines 2023-12-07 22:17:11 -05:00
listen.c Get rid of .internal.h convention in LIBC_INTRIN 2024-07-19 19:38:00 -07:00
recv-nt.c Get rid of .internal.h convention in LIBC_INTRIN 2024-07-19 19:38:00 -07:00
recv.c Get rid of .internal.h convention in LIBC_INTRIN 2024-07-19 19:38:00 -07:00
recvfrom-nt.c Get rid of .internal.h convention in LIBC_INTRIN 2024-07-19 19:38:00 -07:00
recvfrom.c Get rid of .internal.h convention in LIBC_INTRIN 2024-07-19 19:38:00 -07:00
recvmsg.c Get rid of .internal.h convention in LIBC_INTRIN 2024-07-19 19:38:00 -07:00
select.h Rerun clang-format on the repo (#1217) 2024-06-15 16:34:48 -04:00
select.internal.h Avoid linker conflicts on DescribeFoo symbols 2024-08-24 18:10:22 -07:00
send-nt.c Get rid of .internal.h convention in LIBC_INTRIN 2024-07-19 19:38:00 -07:00
send.c Remove .internal from more header filenames 2024-08-04 12:52:25 -07:00
sendfile.c Share file offset across execve() on Windows 2024-08-03 17:48:00 -07:00
sendfile.internal.h Reduce header complexity 2023-11-28 14:39:42 -08:00
sendmsg.c Get rid of .internal.h convention in LIBC_INTRIN 2024-07-19 19:38:00 -07:00
sendto-nt.c Get rid of .internal.h convention in LIBC_INTRIN 2024-07-19 19:38:00 -07:00
sendto.c Remove .internal from more header filenames 2024-08-04 12:52:25 -07:00
setsockopt-nt.c Delve into clock rabbit hole 2024-09-04 01:32:46 -07:00
setsockopt.c Get rid of .internal.h convention in LIBC_INTRIN 2024-07-19 19:38:00 -07:00
shutdown-nt.c flip et / noet in modelines 2023-12-07 22:17:11 -05:00
shutdown.c Get rid of .internal.h convention in LIBC_INTRIN 2024-07-19 19:38:00 -07:00
sock.h Fix some static analysis issues 2024-07-27 09:16:54 -07:00
sockaddr.c Remove .internal from more header filenames 2024-08-04 12:52:25 -07:00
sockaddr2bsd.c flip et / noet in modelines 2023-12-07 22:17:11 -05:00
sockaddr2linux.c Remove .internal from more header filenames 2024-08-04 12:52:25 -07:00
sockatmark.c Get rid of .internal.h convention in LIBC_INTRIN 2024-07-19 19:38:00 -07:00
sockdebug.c Avoid linker conflicts on DescribeFoo symbols 2024-08-24 18:10:22 -07:00
socket-nt.c Apply clang-format update to repo (#1154) 2024-04-25 10:38:00 -07:00
socket-sysv.c flip et / noet in modelines 2023-12-07 22:17:11 -05:00
socket.c Get rid of .internal.h convention in LIBC_INTRIN 2024-07-19 19:38:00 -07:00
socketpair-nt.c Apply clang-format update to repo (#1154) 2024-04-25 10:38:00 -07:00
socketpair-sysv.c Apply clang-format update to repo (#1154) 2024-04-25 10:38:00 -07:00
socketpair.c Apply clang-format update to repo (#1154) 2024-04-25 10:38:00 -07:00
sys_sendfile_freebsd.S Remove .internal from more header filenames 2024-08-04 12:52:25 -07:00
sys_sendfile_xnu.S Remove .internal from more header filenames 2024-08-04 12:52:25 -07:00
syscall_fd.internal.h Get rid of .internal.h convention in LIBC_INTRIN 2024-07-19 19:38:00 -07:00
syslog.h Add dontthrow attribute to most libc functions 2024-01-09 01:26:03 -08:00
winsockblock.c Apply clang-format update to repo (#1154) 2024-04-25 10:38:00 -07:00
wsaid.c flip et / noet in modelines 2023-12-07 22:17:11 -05:00
wsaid.internal.h Reduce header complexity 2023-11-28 14:39:42 -08:00
yoink.inc Mint APE Loader v1.5 2023-07-26 13:54:49 -07:00