From a1c4ab09ddd669810a412e5ab40d7f06326b55cc Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Fri, 23 Aug 2013 15:21:32 +0200 Subject: Properly mark callback functions as extern "C" Change-Id: Ida0a62a438ee36ef1aaecb5ca4a072325b22636d --- vcl/inc/unx/saldata.hxx | 3 -- vcl/unx/generic/app/saldata.cxx | 75 +++++++++++++++++++++-------------------- vcl/unx/gtk/app/gtkdata.cxx | 6 +++- 3 files changed, 44 insertions(+), 40 deletions(-) (limited to 'vcl') diff --git a/vcl/inc/unx/saldata.hxx b/vcl/inc/unx/saldata.hxx index f0e0bb6eef39..e986f8cda221 100644 --- a/vcl/inc/unx/saldata.hxx +++ b/vcl/inc/unx/saldata.hxx @@ -45,9 +45,6 @@ typedef unsigned int pthread_t; class VCLPLUG_GEN_PUBLIC X11SalData : public SalGenericData { - static int XErrorHdl( Display*, XErrorEvent* ); - static int XIOErrorHdl( Display* ); - struct XErrorStackEntry { bool m_bIgnore; diff --git a/vcl/unx/generic/app/saldata.cxx b/vcl/unx/generic/app/saldata.cxx index 9b5e200ad221..7f460a239506 100644 --- a/vcl/unx/generic/app/saldata.cxx +++ b/vcl/unx/generic/app/saldata.cxx @@ -83,6 +83,43 @@ X11SalData* GetX11SalData() return p2; } +extern "C" { + +static int XErrorHdl( Display *pDisplay, XErrorEvent *pEvent ) +{ + GetX11SalData()->XError( pDisplay, pEvent ); + return 0; +} + +static int XIOErrorHdl( Display * ) +{ + if (::osl::Thread::getCurrentIdentifier() == Application::GetMainThreadIdentifier()) + { + /* #106197# hack: until a real shutdown procedure exists + * _exit ASAP + */ + if( ImplGetSVData()->maAppData.mbAppQuit ) + _exit(1); + + // really bad hack + if( ! SessionManagerClient::checkDocumentsSaved() ) + /* oslSignalAction eToDo = */ osl_raiseSignal (OSL_SIGNAL_USER_X11SUBSYSTEMERROR, NULL); + } + + std::fprintf( stderr, "X IO Error\n" ); + std::fflush( stdout ); + std::fflush( stderr ); + + /* #106197# the same reasons to use _exit instead of exit in salmain + * do apply here. Since there is nothing to be done after an XIO + * error we have to _exit immediately. + */ + _exit(1); + return 0; +} + +} + static const struct timeval noyield__ = { 0, 0 }; static const struct timeval yield__ = { 0, 10000 }; @@ -224,7 +261,7 @@ X11SalData::X11SalData( SalGenericDataType t, SalInstance *pInstance ) pXLib_ = NULL; m_pPlugin = NULL; - m_aOrigXIOErrorHandler = XSetIOErrorHandler ( (XIOErrorHandler)XIOErrorHdl ); + m_aOrigXIOErrorHandler = XSetIOErrorHandler ( XIOErrorHdl ); PushXErrorLevel( !!getenv( "SAL_IGNOREXERRORS" ) ); } @@ -287,7 +324,7 @@ void X11SalData::PushXErrorLevel( bool bIgnore ) rEnt.m_bWas = false; rEnt.m_bIgnore = bIgnore; rEnt.m_nLastErrorRequest = 0; - rEnt.m_aHandler = XSetErrorHandler( (XErrorHandler)XErrorHdl ); + rEnt.m_aHandler = XSetErrorHandler( XErrorHdl ); } void X11SalData::PopXErrorLevel() @@ -299,40 +336,6 @@ void X11SalData::PopXErrorLevel() } } -int X11SalData::XErrorHdl( Display *pDisplay, XErrorEvent *pEvent ) -{ - GetX11SalData()->XError( pDisplay, pEvent ); - return 0; -} - -int X11SalData::XIOErrorHdl( Display * ) -{ - if (::osl::Thread::getCurrentIdentifier() == Application::GetMainThreadIdentifier()) - { - /* #106197# hack: until a real shutdown procedure exists - * _exit ASAP - */ - if( ImplGetSVData()->maAppData.mbAppQuit ) - _exit(1); - - // really bad hack - if( ! SessionManagerClient::checkDocumentsSaved() ) - /* oslSignalAction eToDo = */ osl_raiseSignal (OSL_SIGNAL_USER_X11SUBSYSTEMERROR, NULL); - } - - std::fprintf( stderr, "X IO Error\n" ); - std::fflush( stdout ); - std::fflush( stderr ); - - /* #106197# the same reasons to use _exit instead of exit in salmain - * do apply here. Since there is nothing to be done after an XIO - * error we have to _exit immediately. - */ - _exit(1); - return 0; -} - - SalXLib::SalXLib() { m_aTimeout.tv_sec = 0; diff --git a/vcl/unx/gtk/app/gtkdata.cxx b/vcl/unx/gtk/app/gtkdata.cxx index c2ec520ff200..9761354c3969 100644 --- a/vcl/unx/gtk/app/gtkdata.cxx +++ b/vcl/unx/gtk/app/gtkdata.cxx @@ -511,7 +511,9 @@ GtkData::GtkData( SalInstance *pInstance ) XIOErrorHandler aOrigXIOErrorHandler = NULL; -int XIOErrorHdl(Display *) +extern "C" { + +static int XIOErrorHdl(Display *) { fprintf(stderr, "X IO Error\n"); _exit(1); @@ -519,6 +521,8 @@ int XIOErrorHdl(Display *) // handlers are in progress } +} + GtkData::~GtkData() { Yield( true, true ); -- cgit