Re: GUC thread-safety approaches

Peter Eisentraut <peter@eisentraut.org>

From: Peter Eisentraut <peter@eisentraut.org>
To: Heikki Linnakangas <hlinnaka@iki.fi>, pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2025-11-18T22:15:02Z
Lists: pgsql-hackers
On 18.11.25 15:15, Heikki Linnakangas wrote:
> PS. I found this blog post on how Thread Local Storage is implemented on 
> different systems very enlightening: https://maskray.me/blog/2021-02-14- 
> all-about-thread-local-storage. I think whatever scheme we come up with 
> will be a home-grown implementation of one the methods described in that 
> article.

I read this:

 > Windows TLS

 > Referencing a TLS variable from another DLL is not supported.
 >
 > __declspec(dllimport) extern thread_local int tls;
 > // error C2492: 'tls': data with thread storage duration may not have 
dll interface


So something like

extern PGDLLIMPORT thread_local struct Port *MyProcPort;

wouldn't work (confirmed).

That might be a problem, since we now mark all global variables as 
PGDLLIMPORT.