postgresql/src/include/port
Andres Freund bcb2cf41f9 Allow retrieving x86 TSC frequency/flags from CPUID
This adds additional x86 specific CPUID checks for flags needed for
determining whether the Time-Stamp Counter (TSC) is usable on a given system,
as well as a helper function to retrieve the TSC frequency from CPUID.

This is intended for a future patch that will utilize the TSC to lower the
overhead of timing instrumentation.

In passing, always make pg_cpuid_subleaf reset the variables used for its
result, to avoid accidentally using stale results if __get_cpuid_count errors
out and the caller doesn't check for it.

Author: Lukas Fittl <lukas@fittl.com>
Author: David Geier <geidav.pg@gmail.com>
Author: Andres Freund <andres@anarazel.de>
Reviewed-by: Andres Freund <andres@anarazel.de>
Reviewed-by: David Geier <geidav.pg@gmail.com>
Reviewed-by: John Naylor <john.naylor@postgresql.org>
Reviewed-by: Jakub Wartak <jakub.wartak@enterprisedb.com> (in an earlier version)
Discussion: https://www.postgresql.org/message-id/flat/20200612232810.f46nbqkdhbutzqdg%40alap3.anarazel.de
2026-04-07 13:00:24 -04:00
..
atomics Assume "inline" keyword is available. 2026-02-19 14:37:29 -06:00
win32 Fix typos and inconsistencies in code and comments 2026-01-05 09:19:15 +09:00
win32_msvc windows: msvc: Define STDIN/OUT/ERR_FILENO. 2022-07-18 17:21:54 -07:00
aix.h Restore AIX support. 2026-02-23 13:34:22 -05:00
atomics.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
cygwin.h Simplify declaring variables exported from libpgcommon and libpgport. 2021-11-29 11:00:00 -05:00
darwin.h Add prefetching support on macOS 2024-08-28 07:28:27 +02:00
freebsd.h Improve the naming in wal_sync_method code. 2023-10-13 15:16:45 -05:00
linux.h Improve the naming in wal_sync_method code. 2023-10-13 15:16:45 -05:00
netbsd.h Remove cvs keywords from all files. 2010-09-20 22:08:53 +02:00
openbsd.h Remove cvs keywords from all files. 2010-09-20 22:08:53 +02:00
pg_bitutils.h Remove bits* typedefs. 2026-03-30 16:12:08 -05:00
pg_bswap.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
pg_cpu.h Allow retrieving x86 TSC frequency/flags from CPUID 2026-04-07 13:00:24 -04:00
pg_crc32c.h Fix unportable use of __builtin_constant_p 2026-04-06 09:30:01 +07:00
pg_getopt_ctx.h Invent a variant of getopt(3) that is thread-safe 2026-03-30 20:47:13 +03:00
pg_iovec.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
pg_lfind.h Fix some -Wcast-qual warnings 2026-02-27 21:57:33 +01:00
pg_numa.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
pg_pthread.h IWYU widely useful pragmas 2025-01-15 18:57:53 +01:00
simd.h Refactor some SIMD and popcount macros. 2026-01-21 14:21:00 -06:00
solaris.h Remove traces of support for Sun Studio compiler 2025-09-12 07:39:05 +02:00
win32.h mingw: Define PGDLLEXPORT as __declspec (dllexport) as done for msvc 2022-09-30 10:50:05 -07:00
win32_port.h Fix typos and inconsistencies in code and comments 2026-01-05 09:19:15 +09:00
win32ntdll.h Update copyright for 2026 2026-01-01 13:24:10 -05:00