Implementing Fiber-Local Storage Callbacks: sharing data between DLLs

Alexandre Julliard julliard at winehq.org
Thu Sep 1 22:08:59 CDT 2016


John Sheu <sheu at google.com> writes:

> The question is how we manage this.  One option is to introduce
> additional function call entry points to either ntdll or kernel32,
> called by the other, to manages FLS lifetime.  I see though that the
> list of entry points is pretty tightly defined in the .spec files for
> each DLL, and the convention may be (correct me if I'm wrong) not to
> introduce "weird" private Wine-only APIs to the list.  The other
> option is to use some internal structs, pointed to by the PEB and TEB
> structures.  That's the approach I'd like to go with.
>
> My proposal would be:
>
> 1.  Define a common struct to hold the FLS data array, that would be:
>       struct FlsSlots {
>         LIST_ENTRY fls_link;
>         void fls_slots[SLOT_COUNT];
>       };
> 2.  TEB.FlsSlots right now is a void** member; make this a struct
> FlsSlots* member instead.
> 3.  Link the FlsSlots struct into PEB.FlsListHead.
>
> This would require that struct FlsSlots be defined somewhere -- either
> in wine/include, as mentioned, or in <include/winternl.h>.  Since it
> isn't declared publicly in the win32 API, even as an opaque pointer --
> I'm leaning toward the former.  Maybe in "wine/include/fls.h" ?

In general adding private headers is reserved for things that are used
across a wide range of modules, and cannot possibly be done through the
Windows API.

If you really have to share a private structure like this, you can
duplicate the definition, but that should only be a last resort. In
general if there's no equivalent structure on Windows, it means that
it's supposed to work in a different way.

I'll note that recent Windows versions export functions like RtlFlsAlloc
and RtlFlsFree, which probably means it should all be handled inside
ntdll.  Of course it would first need some tests to find out what these
functions do.

-- 
Alexandre Julliard
julliard at winehq.org



More information about the wine-devel mailing list