Re: On non-Windows, hard depend on uselocale(3) - Mailing list pgsql-hackers

From Andres Freund
Subject Re: On non-Windows, hard depend on uselocale(3)
Date
Msg-id 20231118000323.44rduqyxzybil4hk@awork3.anarazel.de
Whole thread Raw
In response to Re: On non-Windows, hard depend on uselocale(3)  (Thomas Munro <thomas.munro@gmail.com>)
List pgsql-hackers
Hi,

On 2023-11-17 08:57:47 +1300, Thomas Munro wrote:
> I also had a go[3] at doing it with static inlined functions, to avoid
> creating a load of new exported functions and associated function call
> overheads.  It worked fine, except on Windows: I needed a global
> variable PGTYPESclocale that all the inlined functions can see when
> called from ecpglib or pgtypeslib code, but if I put that in the
> exports list then on that platform it seems to contain garbage; there
> is probably some other magic needed to export non-function symbols
> from the DLL or something like that, I didn't look into it.  See CI
> failure + crash dumps.

I suspect you'd need __declspec(dllimport) on the variable to make that work.
I.e. use PGDLLIMPORT and define BUILDING_DLL while building the libraries, so
they see __declspec (dllexport).  I luckily forgot the details, but functions
just call into some thunk that does necessary magic, but that option doesn't
exist for variables, so the compiler/linker have to do stuff, hence needing
__declspec(dllimport).

Greetings,

Andres Freund



pgsql-hackers by date:

Previous
From: Jeff Davis
Date:
Subject: Re: Change GUC hashtable to use simplehash?
Next
From: Andres Freund
Date:
Subject: Re: Change GUC hashtable to use simplehash?