opnsense-src/sys/compat/linux
Val Packett 108de78451 Redefine CLOCK_BOOTTIME to alias CLOCK_MONOTONIC, not CLOCK_UPTIME
The suspend-awareness situation with monotonic clocks across platforms
is kind of a mess, let's try not making it worse.

On Linux, CLOCK_MONOTONIC does NOT count suspended time, and
CLOCK_BOOTTIME was introduced to INCLUDE suspended time.

On OpenBSD, CLOCK_MONOTONIC DOES count suspended time, and CLOCK_UPTIME
was introduced to EXCLUDE suspended time.

On macOS, it's the same as OpenBSD, but with CLOCK_UPTIME_RAW.

Right now, we do not have a monotonic clock that counts suspended time.
We have CLOCK_UPTIME as a distinct ID alias, and CLOCK_BOOTTIME as a
preprocessor alias, both being effectively `CLOCK_MONOTONIC` for now.

When we introduce a suspend-aware clock in the future, it would make a
lot more sense to do it the OpenBSD/macOS way, i.e. to make
CLOCK_MONOTONIC include suspended time and make CLOCK_UPTIME exclude it,
because that's what the name CLOCK_UPTIME implies: a deviation from the
default intended for the uptime command to allow it to only show the
time the system was actually up and not suspended.

Let's change the define right now to make sure software using the define
would not end up using the ID of the wrong clock in the future, and fix
the IDs in the Linux compat code to match the expected changes too.

See https://bugzilla.mozilla.org/show_bug.cgi?id=1824084
for more discussion.

Fixes:		155f15118a ("clock_gettime: Add Linux aliases for CLOCK_*")
Fixes:		25ada63736 ("Map Linux CLOCK_BOOTTIME to native CLOCK_UPTIME.")
Sponsored by:	https://www.patreon.com/valpackett
Reviewed by:	kib, imp
Differential Revision:	https://reviews.freebsd.org/D39270
2024-05-31 08:45:02 -06:00
..
check_error.d sys: Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:11 -06:00
check_internal_locks.d sys: Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:11 -06:00
linux.c linux: use sa_family_t for address family conversions 2024-03-29 13:35:37 -07:00
linux.h linux(4): Update my copyrights, add SPDX tag 2023-08-17 23:54:36 +03:00
linux_common.c linux(4): Remove sys/cdefs.h inclusion where it's not needed due to 685dc743 2023-08-18 13:12:02 +03:00
linux_common.h linux: use sa_family_t for address family conversions 2024-03-29 13:35:37 -07:00
linux_dtrace.h sys: Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:11 -06:00
linux_dummy.c linux(4): Update syscalls.master to 6.5 2023-09-25 12:24:58 +03:00
linux_elf.c linux(4): Remove sys/cdefs.h inclusion where it's not needed due to 685dc743 2023-08-18 13:12:02 +03:00
linux_elf.h spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSD 2023-05-12 10:44:03 -06:00
linux_elf32.c linux(4): Remove sys/cdefs.h inclusion where it's not needed due to 685dc743 2023-08-18 13:12:02 +03:00
linux_elf64.c linux(4): Remove sys/cdefs.h inclusion where it's not needed due to 685dc743 2023-08-18 13:12:02 +03:00
linux_emul.c linux(4): Remove sys/cdefs.h inclusion where it's not needed due to 685dc743 2023-08-18 13:12:02 +03:00
linux_emul.h sys: Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:11 -06:00
linux_errno.c linux(4): Remove sys/cdefs.h inclusion where it's not needed due to 685dc743 2023-08-18 13:12:02 +03:00
linux_errno.h sys: Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:11 -06:00
linux_errno.inc sys: Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:11 -06:00
linux_event.c linux(4): Convert flags in timerfd_create 2023-09-05 11:53:02 +03:00
linux_event.h linux(4): Convert flags in timerfd_create 2023-09-05 11:53:02 +03:00
linux_file.c linux: Export linux_common_openflags() 2024-05-23 13:40:46 -06:00
linux_file.h linux: Export linux_common_openflags() 2024-05-23 13:40:46 -06:00
linux_fork.c linux(4): Remove sys/cdefs.h inclusion where it's not needed due to 685dc743 2023-08-18 13:12:02 +03:00
linux_fork.h linux(4): Update my copyrights, add SPDX tag 2023-08-17 23:54:36 +03:00
linux_futex.c linux(4): Remove sys/cdefs.h inclusion where it's not needed due to 685dc743 2023-08-18 13:12:02 +03:00
linux_futex.h sys: Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:11 -06:00
linux_getcwd.c linux(4): Remove sys/cdefs.h inclusion where it's not needed due to 685dc743 2023-08-18 13:12:02 +03:00
linux_ioctl.c linux: Check for copyout errors in ioctl handlers 2023-12-27 10:13:15 -05:00
linux_ioctl.h linux(4): Add 2 Linux socket ioctl commands 2023-08-17 22:57:16 +03:00
linux_ipc.c linux(4): Remove sys/cdefs.h inclusion where it's not needed due to 685dc743 2023-08-18 13:12:02 +03:00
linux_ipc.h sys: Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:11 -06:00
linux_ipc64.h linux(4): Fix semid64_ds structure layout 2023-10-04 21:21:12 +03:00
linux_mib.c linux(4): Remove sys/cdefs.h inclusion where it's not needed due to 685dc743 2023-08-18 13:12:02 +03:00
linux_mib.h sys: Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:11 -06:00
linux_misc.c minor style tweak. 2024-05-29 09:53:20 -06:00
linux_misc.h linux: implement PR_CHILD_SET_SUBREAPER 2024-05-29 07:56:23 -06:00
linux_mmap.c Reduce reliance on sys/sysproto.h pollution 2024-04-15 21:35:40 +01:00
linux_mmap.h sys: Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:11 -06:00
linux_netlink.c linux: allow RTM_GETADDR without full ifaddrmsg argument 2024-05-28 13:13:08 -07:00
linux_persona.h linux(4): Fix leftovers after 2ff63af9 2023-08-17 23:54:00 +03:00
linux_ptrace.c linux(4): Remove sys/cdefs.h inclusion where it's not needed due to 685dc743 2023-08-18 13:12:02 +03:00
linux_rseq.c linux(4): Remove sys/cdefs.h inclusion where it's not needed due to 685dc743 2023-08-18 13:12:02 +03:00
linux_siginfo.h sys: Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:11 -06:00
linux_signal.c linux(4): On Linux SIGKILL can not be reset to default 2023-09-18 17:53:01 +03:00
linux_signal.h linux(4): Staticize lsiginfo_to_siginfo 2023-09-18 17:52:43 +03:00
linux_socket.c Fix new users of MAXPHYS and hide it from the kernel namespace 2024-04-30 15:29:06 -04:00
linux_socket.h linux(4): Drop bogus __arm__ condition due to lack of 32-bit arm support 2023-08-17 22:57:17 +03:00
linux_stats.c linux(4): Remove sys/cdefs.h inclusion where it's not needed due to 685dc743 2023-08-18 13:12:02 +03:00
linux_sysctl.c linux(4): Add const qualifier to the value parameter of function handle_string() 2024-05-20 12:02:33 +08:00
linux_time.c Redefine CLOCK_BOOTTIME to alias CLOCK_MONOTONIC, not CLOCK_UPTIME 2024-05-31 08:45:02 -06:00
linux_time.h linux: Export linux_convert_l_sigevent 2024-05-23 13:40:46 -06:00
linux_timer.c linux: Export linux_convert_l_sigevent 2024-05-23 13:40:46 -06:00
linux_uid16.c linux(4): Remove sys/cdefs.h inclusion where it's not needed due to 685dc743 2023-08-18 13:12:02 +03:00
linux_util.c linux_pwd_onexec: do not abort image activation if emul path does not exist 2024-02-22 03:31:39 +02:00
linux_util.h Reduce reliance on sys/sysproto.h pollution 2024-04-15 21:35:40 +01:00
linux_vdso.c linux(4): Remove sys/cdefs.h inclusion where it's not needed due to 685dc743 2023-08-18 13:12:02 +03:00
linux_vdso.h linux(4): Remove include of sys/types.h from linux_vdso.h 2023-08-18 15:58:32 +03:00
linux_vdso_gtod.inc linux(4): Fix linker warning about undefined vdso symbols 2023-08-20 00:48:36 +03:00
linux_videodev2_compat.h linux(4): Fix leftovers after 2ff63af9 2023-08-17 23:54:00 +03:00
linux_videodev_compat.h linux(4): Fix leftovers after 2ff63af9 2023-08-17 23:54:00 +03:00
linux_xattr.c linux(4): Return ENOTSUP from listxattr instead of EPERM 2023-09-05 11:52:27 +03:00
stats_timing.d sys: Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:11 -06:00
trace_futexes.d sys: Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:11 -06:00