[cairo] New per-scaled_font mutex to fix locking bugs

Peter Weilbacher (Mozilla) mozilla at weilbacher.org
Tue Feb 6 17:11:05 PST 2007

On Mon, 05 Feb 2007 17:00:25 -0800, Carl Worth wrote:

>For win32, I took a guess and came up with the following
>	typedef CRITICAL_SECTION cairo_mutex_t;
>	# define CAIRO_MUTEX_INIT(mutex) InitializeCriticalSection (mutex)
>	# define CAIRO_MUTEX_FINI(mutex) DeleteCriticalSection (mutex)
>The only thing I'm unsure of there is the NIL_INITIALIZER. This is
>only used when initializing the mutex for a nil surface, so the value
>won't ever be looked at, but it does need to compile at least.
>And for BeOS and OS/2 I just plain broke the compilation since I had
>no idea what the correct stuff is there. Patches welcome.

Thanks for the hint. For OS/2 I used these lines to get it to compile:

   typedef HMTX cairo_mutex_t;
   # define CAIRO_MUTEX_INIT(mutex) DosCreateMutexSem (NULL, mutex, 0L, TRUE)
   # define CAIRO_MUTEX_FINI(mutex) DosCloseMutexSem (*(mutex))

The empty brackets in the NIL_INITIALIZER caused a compile error with the
GCC we use on OS/2. I still get this warning

   cairo-scaled-font.c:90: warning: braces around scalar initializer
   cairo-scaled-font.c:90: warning: (near initialization for `_cairo_scaled_font_nil.mutex')

Not sure if I should care... I ran a test with fonts, checked that it
called the two functions involved and that it still worked without
problems, so I guess this is OK.


More information about the cairo mailing list