Re: pgsql: Replace random(), pg_erand48(), etc with a better PRNG API and a - Mailing list pgsql-committers

From Tom Lane
Subject Re: pgsql: Replace random(), pg_erand48(), etc with a better PRNG API and a
Date
Msg-id 1135295.1638157668@sss.pgh.pa.us
Whole thread Raw
In response to pgsql: Replace random(), pg_erand48(), etc with a better PRNG API and a  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: pgsql: Replace random(), pg_erand48(), etc with a better PRNG API and a
List pgsql-committers
Tom Lane <tgl@sss.pgh.pa.us> writes:
> Replace random(), pg_erand48(), etc with a better PRNG API and algorithm.

Hmm, fairywren doesn't like this [1]:

gcc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werror=vla -Wendif-labels
-Wmissing-format-attribute-Wimplicit-fallthrough=3 -Wcast-function-type -Wformat-security -fno-strict-aliasing -fwrapv
-fexcess-precision=standard-Wno-format-truncation -Wno-stringop-truncation -g -O2 win32ver.o pg_test_fsync.o
-L../../../src/port-L../../../src/common  -Wl,--allow-multiple-definition -Wl,--disable-auto-import  -L/c/prog/3p64/lib
-L/c/prog/3p64/openssl/lib-Wl,--as-needed   -lpgcommon -lpgport -lssl -lcrypto -lz -lws2_32 -lm  -lws2_32 -o
pg_test_fsync.exe
C:/tools/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe:
pg_test_fsync.o:in function `main': 
C:/tools/msys64/home/pgrunner/bf/root/HEAD/pgsql.build/../pgsql/src/bin/pg_test_fsync/pg_test_fsync.c:121: undefined
referenceto `__imp_pg_global_prng_state' 
collect2.exe: error: ld returned 1 exit status

I think what is going on here is that the compilation of pg_test_fsync.c
sees

extern PGDLLIMPORT pg_prng_state pg_global_prng_state;

and does something that's inappropriate when the variable is actually
coming from elsewhere in the same program.  If so, we could perhaps
fix it by doing

#ifdef FRONTEND
extern pg_prng_state pg_global_prng_state;
#else
extern PGDLLIMPORT pg_prng_state pg_global_prng_state;
#endif

Thoughts?

            regards, tom lane

[1] https://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=fairywren&dt=2021-11-29%2003%3A04%3A24



pgsql-committers by date:

Previous
From: Tom Lane
Date:
Subject: pgsql: Replace random(), pg_erand48(), etc with a better PRNG API and a
Next
From: Michael Paquier
Date:
Subject: pgsql: Centralize timestamp computation of control file on updates