Cairo exports and more (was Re: [cairo] Re: Munging header files for export (and other) attributes)

Doodle doodle at
Thu Sep 8 00:41:06 PDT 2005

Hans Breuer wrote:
> On win32 there is DllMain() which could be used to intialize 'global'
> synchronization objects in a thread safe manner. (It is guaranteed that
> no other threads are started during DLL initialization).
> If I understand you suggestion correctly something like
> #define LOCK(hLock) do { if (!hLock) hLock = CreateMutex(...); \
>             WaitForSingleObject(hLock,INFINITE); } while (0)
> #define UNLOCK(hLock) ReleaseMutex(hLock)
> would be possible - if one is willing to leak the synchronizaion objects.
> Does not solve the intialization race though.

It is exactly what is done in the OS/2 port.

However, the synchronization objects are not leaked, because they
are cleaned up in the DLL unload branch of DllMain().

To solve the initialization race, I think the only clean solution
is to introduce new cairo_initialize() and cairo_uninitialize()
functions, which would call the initialize/uninitialize functions of
all the installed backends/fonthandlers, so they could create and
destroy their mutexes, private memory areas, etc...


More information about the cairo mailing list