postgresql/src/port
Nathan Bossart 598e0114a3 Fix code for probing availability of AVX-512.
This commit fixes a few things:
* Instead of checking for CPU support of the "xsave" extension, we
  need to check for OS support of XGETBV instructions via the
  "osxsave" flag.
* We must check that additional XCR0 bits are set to be sure the
  ZMM registers are fully enabled.
* We should use the recommended ordering of steps.  Specifically,
  we need to check that the ZMM registers are enabled prior to
  checking for AVX-512 via CPUID.

In passing, split this code into separate functions to improve
readability.

Reported-by: Andrew Kane
Reviewed-by: Akash Shankaran, Raghuveer Devulapalli
Discussion: https://postgr.es/m/20240418024459.GA3385227%40nathanxps13
2024-04-23 10:54:04 -05:00
..
.gitignore
Makefile Optimize pg_popcount() with AVX-512 instructions. 2024-04-06 21:56:23 -05:00
README Remove AIX support 2024-02-28 15:17:23 +04:00
bsearch_arg.c
chklocale.c
dirent.c
dirmod.c
explicit_bzero.c
getopt.c
getopt_long.c
getpeereid.c
inet_aton.c
inet_net_ntop.c
kill.c
meson.build Optimize pg_popcount() with AVX-512 instructions. 2024-04-06 21:56:23 -05:00
mkdtemp.c
noblock.c
open.c
path.c Use printf's %m format instead of strerror(errno) in more places 2024-03-12 10:02:54 +09:00
pg_bitutils.c Optimize visibilitymap_count() with AVX-512 instructions. 2024-04-06 22:58:23 -05:00
pg_crc32c_armv8.c
pg_crc32c_armv8_choose.c
pg_crc32c_loongarch.c
pg_crc32c_sb8.c
pg_crc32c_sse42.c
pg_crc32c_sse42_choose.c
pg_popcount_avx512.c Optimize visibilitymap_count() with AVX-512 instructions. 2024-04-06 22:58:23 -05:00
pg_popcount_avx512_choose.c Fix code for probing availability of AVX-512. 2024-04-23 10:54:04 -05:00
pg_strong_random.c
pgcheckdir.c
pgmkdirp.c
pgsleep.c
pgstrcasecmp.c
pgstrsignal.c
pqsignal.c Centralize logic for restoring errno in signal handlers. 2024-02-14 16:34:18 -06:00
pthread-win32.h Clean up Windows-specific mutex code in libpq and ecpglib. 2024-02-09 11:11:39 -05:00
pthread_barrier_wait.c
qsort.c
qsort_arg.c
quotes.c
snprintf.c
strerror.c Remove AIX support 2024-02-28 15:17:23 +04:00
strlcat.c
strlcpy.c
strnlen.c
strtof.c
system.c
tar.c
user.c
win32.ico
win32common.c Remove "#ifdef WIN32" guards from src/port/win32*.c 2024-02-12 11:57:45 +02:00
win32dlopen.c
win32env.c
win32error.c
win32fdatasync.c
win32fseek.c Remove "#ifdef WIN32" guards from src/port/win32*.c 2024-02-12 11:57:45 +02:00
win32gai_strerror.c Fix gai_strerror() thread-safety on Windows. 2024-02-12 11:14:21 +13:00
win32getrusage.c
win32gettimeofday.c
win32link.c
win32ntdll.c
win32pread.c Fix overflow in Windows replacement pg_pread/pg_pwrite. 2024-03-03 08:40:41 +13:00
win32pwrite.c Fix overflow in Windows replacement pg_pread/pg_pwrite. 2024-03-03 08:40:41 +13:00
win32security.c
win32setlocale.c
win32stat.c Remove "#ifdef WIN32" guards from src/port/win32*.c 2024-02-12 11:57:45 +02:00
win32ver.rc

README

src/port/README

libpgport
=========

libpgport must have special behavior.  It supplies functions to both
libraries and applications.  However, there are two complexities:

1)  Libraries need to use object files that are compiled with exactly
the same flags as the library.  libpgport might not use the same flags,
so it is necessary to recompile the object files for individual
libraries.  This is done by removing -lpgport from the link line:

        # Need to recompile any libpgport object files
        LIBS := $(filter-out -lpgport, $(LIBS))

and adding infrastructure to recompile the object files:

        OBJS= execute.o typename.o descriptor.o data.o error.o prepare.o memory.o \
                connect.o misc.o path.o exec.o \
                $(filter strlcat.o, $(LIBOBJS))

The problem is that there is no testing of which object files need to be
added, but missing functions usually show up when linking user
applications.

2) For applications, we use -lpgport before -lpq, so the static files
from libpgport are linked first.  This avoids having applications
dependent on symbols that are _used_ by libpq, but not intended to be
exported by libpq.  libpq's libpgport usage changes over time, so such a
dependency is a problem.  Windows, Linux, and macOS use an export
list to control the symbols exported by libpq.