Kaydet (Commit) fd69d1ab authored tarafından vjinoch's avatar vjinoch Kaydeden (comit) Michael Meeks

Remove GtkHookedYieldMutex and some small changes.

Change-Id: Id84a5eaa4cea4c7cce9aa873c1a7c286e5d5cc92
Reviewed-on: https://gerrit.libreoffice.org/3349Reviewed-by: 's avatarMichael Meeks <michael.meeks@suse.com>
Tested-by: 's avatarMichael Meeks <michael.meeks@suse.com>
üst c7c7b08c
...@@ -39,13 +39,18 @@ class GenPspGraphics; ...@@ -39,13 +39,18 @@ class GenPspGraphics;
class GtkYieldMutex : public SalYieldMutex class GtkYieldMutex : public SalYieldMutex
{ {
public: public:
GtkYieldMutex(); GtkYieldMutex();
virtual void acquire(); virtual void acquire();
virtual void release(); virtual void release();
virtual sal_Bool tryToAcquire(); virtual sal_Bool tryToAcquire() { return SalYieldMutex::tryToAcquire(); }
virtual int Grab(); virtual int Grab() { return 0; };
virtual void Ungrab( int ); virtual void Ungrab(int ) {};
std::list<sal_uLong> aYieldStack;
void ThreadsEnter();
void ThreadsLeave();
class GtkYieldGuard class GtkYieldGuard
{ {
...@@ -64,21 +69,6 @@ public: ...@@ -64,21 +69,6 @@ public:
}; };
}; };
class GtkHookedYieldMutex : public GtkYieldMutex
{
virtual int Grab() { return 0; };
virtual void Ungrab(int ) {};
std::list<sal_uLong> aYieldStack;
public:
GtkHookedYieldMutex();
virtual void acquire();
virtual void release();
virtual sal_Bool tryToAcquire() { return SalYieldMutex::tryToAcquire(); }
void ThreadsEnter();
void ThreadsLeave();
};
#define GTK_YIELD_GRAB() GtkYieldMutex::GtkYieldGuard aLocalGtkYieldGuard( static_cast<GtkYieldMutex*>(GetSalData()->m_pInstance->GetYieldMutex()) ) #define GTK_YIELD_GRAB() GtkYieldMutex::GtkYieldGuard aLocalGtkYieldGuard( static_cast<GtkYieldMutex*>(GetSalData()->m_pInstance->GetYieldMutex()) )
class GtkSalTimer; class GtkSalTimer;
......
...@@ -48,78 +48,29 @@ ...@@ -48,78 +48,29 @@
#include "gtkprintwrapper.hxx" #include "gtkprintwrapper.hxx"
GtkHookedYieldMutex::GtkHookedYieldMutex()
{
}
/*
* These methods always occur in pairs
* A ThreadsEnter is followed by a ThreadsLeave
* We need to queue up the recursive lock count
* for each pair, so we can accurately restore
* it later.
*/
void GtkHookedYieldMutex::ThreadsEnter()
{
acquire();
if( !aYieldStack.empty() )
{ /* Previously called ThreadsLeave() */
sal_uLong nCount = aYieldStack.front();
aYieldStack.pop_front();
while( nCount-- > 1 )
acquire();
}
}
void GtkHookedYieldMutex::ThreadsLeave()
{
aYieldStack.push_front( mnCount );
#if OSL_DEBUG_LEVEL > 1
if( mnThreadId &&
mnThreadId != osl::Thread::getCurrentIdentifier())
fprintf( stderr, "\n\n--- A different thread owns the mutex ...---\n\n\n");
#endif
while( mnCount > 1 )
release();
release();
}
void GtkHookedYieldMutex::acquire()
{
SalYieldMutex::acquire();
}
void GtkHookedYieldMutex::release()
{
SalYieldMutex::release();
}
extern "C" extern "C"
{ {
#define GET_YIELD_MUTEX() static_cast<GtkHookedYieldMutex*>(GetSalData()->m_pInstance->GetYieldMutex()) #define GET_YIELD_MUTEX() static_cast<GtkYieldMutex*>(GetSalData()->m_pInstance->GetYieldMutex())
static void GdkThreadsEnter( void ) static void GdkThreadsEnter( void )
{ {
GtkHookedYieldMutex *pYieldMutex = GET_YIELD_MUTEX(); GtkYieldMutex *pYieldMutex = GET_YIELD_MUTEX();
pYieldMutex->ThreadsEnter(); pYieldMutex->ThreadsEnter();
} }
static void GdkThreadsLeave( void ) static void GdkThreadsLeave( void )
{ {
GtkHookedYieldMutex *pYieldMutex = GET_YIELD_MUTEX(); GtkYieldMutex *pYieldMutex = GET_YIELD_MUTEX();
pYieldMutex->ThreadsLeave(); pYieldMutex->ThreadsLeave();
} }
static bool hookLocks( oslModule pModule ) static bool hookLocks( void )
{ {
#if !GTK_CHECK_VERSION(2,4,0) #if !GTK_CHECK_VERSION(2,4,0)
g_error("no lock hooking!"); #error No lock hooking!
#endif #endif
gdk_threads_set_lock_functions (GdkThreadsEnter, GdkThreadsLeave); gdk_threads_set_lock_functions (GdkThreadsEnter, GdkThreadsLeave);
#if OSL_DEBUG_LEVEL > 1 #if OSL_DEBUG_LEVEL > 1
fprintf( stderr, "Hooked gdk threads locks\n" ); fprintf( stderr, "Hooked gdk threads locks\n" );
#endif #endif
(void)pModule;
return true; return true;
} }
...@@ -130,6 +81,9 @@ extern "C" ...@@ -130,6 +81,9 @@ extern "C"
(int) gtk_major_version, (int) gtk_minor_version, (int) gtk_major_version, (int) gtk_minor_version,
(int) gtk_micro_version ); (int) gtk_micro_version );
#endif #endif
if( (int) gtk_major_version < 2 || ((int) gtk_major_version == 2 && (int) gtk_minor_version < 4))
g_warning("require a newer gtk than %d.%d for gdk_threads_set_lock_functions", (int) gtk_major_version, gtk_minor_version);
return NULL;
/* #i92121# workaround deadlocks in the X11 implementation /* #i92121# workaround deadlocks in the X11 implementation
*/ */
static const char* pNoXInitThreads = getenv( "SAL_NO_XINITTHREADS" ); static const char* pNoXInitThreads = getenv( "SAL_NO_XINITTHREADS" );
...@@ -159,8 +113,8 @@ extern "C" ...@@ -159,8 +113,8 @@ extern "C"
if ( !g_thread_supported() ) if ( !g_thread_supported() )
g_thread_init( NULL ); g_thread_init( NULL );
if ( hookLocks( pModule ) ) if ( hookLocks() )
pYieldMutex = new GtkHookedYieldMutex(); pYieldMutex = new GtkYieldMutex();
gdk_threads_init(); gdk_threads_init();
...@@ -341,30 +295,46 @@ GtkYieldMutex::GtkYieldMutex() ...@@ -341,30 +295,46 @@ GtkYieldMutex::GtkYieldMutex()
void GtkYieldMutex::acquire() void GtkYieldMutex::acquire()
{ {
g_error ("never called"); SalYieldMutex::acquire();
} }
void GtkYieldMutex::release() void GtkYieldMutex::release()
{ {
g_error ("never called"); SalYieldMutex::release();
} }
sal_Bool GtkYieldMutex::tryToAcquire() /*
* These methods always occur in pairs
* A ThreadsEnter is followed by a ThreadsLeave
* We need to queue up the recursive lock count
* for each pair, so we can accurately restore
* it later.
*/
void GtkYieldMutex::ThreadsEnter()
{ {
g_error ("never called"); acquire();
return sal_True; if( !aYieldStack.empty() )
{ /* Previously called ThreadsLeave() */
sal_uLong nCount = aYieldStack.front();
aYieldStack.pop_front();
while( nCount-- > 1 )
acquire();
}
} }
int GtkYieldMutex::Grab() void GtkYieldMutex::ThreadsLeave()
{ {
g_error ("never called"); aYieldStack.push_front( mnCount );
return sal_True;
}
void GtkYieldMutex::Ungrab( int nGrabs ) #if OSL_DEBUG_LEVEL > 1
{ if( mnThreadId &&
(void)nGrabs; mnThreadId != osl::Thread::getCurrentIdentifier())
g_error ("never called"); fprintf( stderr, "\n\n--- A different thread owns the mutex ...---\n\n\n");
#endif
while( mnCount > 1 )
release();
release();
} }
SalVirtualDevice* GtkInstance::CreateVirtualDevice( SalGraphics *pG, SalVirtualDevice* GtkInstance::CreateVirtualDevice( SalGraphics *pG,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment