Merge lp:~vanvugt/compiz-core/fix-921406 into lp:compiz-core/0.9.5

Proposed by Daniel van Vugt
Status: Merged
Approved by: Sam Spilsbury
Approved revision: 2962
Merged at revision: 2963
Proposed branch: lp:~vanvugt/compiz-core/fix-921406
Merge into: lp:compiz-core/0.9.5
Diff against target: 133 lines (+51/-0)
2 files modified
plugins/composite/tests/paintscheduler/test-paintscheduler.cpp (+46/-0)
src/signalsource.cpp (+5/-0)
To merge this branch: bzr merge lp:~vanvugt/compiz-core/fix-921406
Reviewer Review Type Date Requested Status
Alan Griffiths Approve
Review via email: mp+90053@code.launchpad.net

Description of the change

Fix build failures with glib 2.30 (oneiric) (LP: #921406)

Amazingly, there is no compatible GThread/GMutex/GCond API that is compatible with both glib 2.30 (oneiric) and 2.31 (precise). So we need to #if them :(

To post a comment you must log in.
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

Messy, but if it needs to be...

review: Approve
Revision history for this message
Sam Spilsbury (smspillaz) wrote :

Ack, we also hit similar problems in unity too

Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Actually you could emulate the old 2.30 API using the new one (2.31) with a bunch of wrapper functions and/or macros. But since this is the only place in compiz affected, not worth doing (yet).

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'plugins/composite/tests/paintscheduler/test-paintscheduler.cpp'
--- plugins/composite/tests/paintscheduler/test-paintscheduler.cpp 2012-01-24 09:30:19 +0000
+++ plugins/composite/tests/paintscheduler/test-paintscheduler.cpp 2012-01-25 07:39:23 +0000
@@ -166,8 +166,13 @@
166 int drmFD;166 int drmFD;
167 DRMInfo *info;167 DRMInfo *info;
168 GThread *eventThread;168 GThread *eventThread;
169#if GLIB_CHECK_VERSION(2, 31, 0)
169 GMutex eventMutex;170 GMutex eventMutex;
170 GCond eventCondition;171 GCond eventCondition;
172#else
173 GMutex *eventMutex;
174 GCond *eventCondition;
175#endif
171 bool pendingVBlank;176 bool pendingVBlank;
172};177};
173178
@@ -456,13 +461,22 @@
456461
457 drmWaitVBlank (fd, &vbl);462 drmWaitVBlank (fd, &vbl);
458463
464#if GLIB_CHECK_VERSION(2, 31, 0)
459 g_mutex_lock (&info->self->eventMutex);465 g_mutex_lock (&info->self->eventMutex);
466#else
467 g_mutex_lock (info->self->eventMutex);
468#endif
460469
461 if (info->self->timingCount != info->self->periods.size ())470 if (info->self->timingCount != info->self->periods.size ())
462 info->self->pendingVBlank = true;471 info->self->pendingVBlank = true;
463472
473#if GLIB_CHECK_VERSION(2, 31, 0)
464 g_cond_signal (&info->self->eventCondition);474 g_cond_signal (&info->self->eventCondition);
465 g_mutex_unlock (&info->self->eventMutex);475 g_mutex_unlock (&info->self->eventMutex);
476#else
477 g_cond_signal (info->self->eventCondition);
478 g_mutex_unlock (info->self->eventMutex);
479#endif
466}480}
467481
468gpointer482gpointer
@@ -506,8 +520,13 @@
506{520{
507 const char *modules[] = { "i915", "radeon", "nouveau", "vmwgfx" };521 const char *modules[] = { "i915", "radeon", "nouveau", "vmwgfx" };
508522
523#if GLIB_CHECK_VERSION(2, 31, 0)
509 g_mutex_init (&eventMutex);524 g_mutex_init (&eventMutex);
510 g_cond_init (&eventCondition);525 g_cond_init (&eventCondition);
526#else
527 eventMutex = g_mutex_new ();
528 eventCondition = g_cond_new ();
529#endif
511530
512 for (unsigned int i = 0; i < ARRAY_SIZE (modules); i++)531 for (unsigned int i = 0; i < ARRAY_SIZE (modules); i++)
513 {532 {
@@ -555,7 +574,12 @@
555 evctx.vblank_handler = DRMVBlankWaiter::vblankHandler;574 evctx.vblank_handler = DRMVBlankWaiter::vblankHandler;
556 evctx.page_flip_handler = NULL;575 evctx.page_flip_handler = NULL;
557576
577#if GLIB_CHECK_VERSION(2, 31, 0)
558 eventThread = g_thread_try_new ("drm_wait_t", &DRMVBlankWaiter::drmEventHandlerThread, (void *) this, NULL);578 eventThread = g_thread_try_new ("drm_wait_t", &DRMVBlankWaiter::drmEventHandlerThread, (void *) this, NULL);
579#else
580 eventThread = g_thread_create (&DRMVBlankWaiter::drmEventHandlerThread,
581 (void *) this, TRUE, NULL);
582#endif
559583
560 if (!eventThread)584 if (!eventThread)
561 {585 {
@@ -571,6 +595,15 @@
571 delete info;595 delete info;
572596
573 drmClose (drmFD);597 drmClose (drmFD);
598
599#if GLIB_CHECK_VERSION(2, 31, 0)
600 g_mutex_clear (&eventMutex);
601 g_cond_clear (&eventCondition);
602#else
603 g_mutex_free (eventMutex);
604 g_cond_free (eventCondition);
605#endif
606
574}607}
575608
576NilVBlankWaiter::NilVBlankWaiter (DummyPaintDispatch *o, unsigned int n) :609NilVBlankWaiter::NilVBlankWaiter (DummyPaintDispatch *o, unsigned int n) :
@@ -606,12 +639,21 @@
606{639{
607 VBlankWaiter::time_value tv;640 VBlankWaiter::time_value tv;
608641
642#if GLIB_CHECK_VERSION(2, 31, 0)
609 g_mutex_lock (&eventMutex);643 g_mutex_lock (&eventMutex);
610 if (!pendingVBlank && !owner->isDone ())644 if (!pendingVBlank && !owner->isDone ())
611 g_cond_wait (&eventCondition, &eventMutex);645 g_cond_wait (&eventCondition, &eventMutex);
612646
613 pendingVBlank = false;647 pendingVBlank = false;
614 g_mutex_unlock (&eventMutex);648 g_mutex_unlock (&eventMutex);
649#else
650 g_mutex_lock (eventMutex);
651 if (!pendingVBlank && !owner->isDone ())
652 g_cond_wait (eventCondition, eventMutex);
653
654 pendingVBlank = false;
655 g_mutex_unlock (eventMutex);
656#endif
615657
616 gettimeofday (&tv, NULL);658 gettimeofday (&tv, NULL);
617659
@@ -679,6 +721,10 @@
679 721
680int main (void)722int main (void)
681{723{
724#if !GLIB_CHECK_VERSION(2, 31, 0)
725 g_thread_init (NULL);
726#endif
727
682 gettimeofday (&SleepVBlankWaiter::start_time, NULL);728 gettimeofday (&SleepVBlankWaiter::start_time, NULL);
683729
684 TimeoutHandler *th = new TimeoutHandler ();730 TimeoutHandler *th = new TimeoutHandler ();
685731
=== modified file 'src/signalsource.cpp'
--- src/signalsource.cpp 2012-01-21 13:34:31 +0000
+++ src/signalsource.cpp 2012-01-25 07:39:23 +0000
@@ -24,7 +24,12 @@
24 */24 */
2525
26#include "privatesignalsource.h"26#include "privatesignalsource.h"
27
28/* Add missing decls: https://bugzilla.gnome.org/show_bug.cgi?id=663880 */
29#include <glib.h>
30G_BEGIN_DECLS
27#include <glib-unix.h>31#include <glib-unix.h>
32G_END_DECLS
2833
29CompSignalSource *34CompSignalSource *
30CompSignalSource::create (int signum, const callbackFunc &f)35CompSignalSource::create (int signum, const callbackFunc &f)

Subscribers

People subscribed via source and target branches