From c85385c0e20d3ff55c62553e76b6a4b56e6341a7 Mon Sep 17 00:00:00 2001 From: rkv Date: Thu, 29 Oct 2015 10:43:23 +0300 Subject: [PATCH] 0026784: Coding rules - eliminate GCC warning -Wunused-parameter OSD_Thread - use pthread_timedjoin_np() instead of pthread_join() when available (glibc extension). Suppress unused parameter warning in OSD_Signal, NCollection_WinHeapAllocator, OpenGl_Text, OpenGl_View, V3d_View and ViewerTest. --- .../NCollection_WinHeapAllocator.cxx | 2 ++ src/OSD/OSD_Thread.cxx | 31 ++++++++++++++++--- src/OSD/OSD_signal.cxx | 6 ++++ src/OpenGl/OpenGl_Text.cxx | 2 ++ src/OpenGl/OpenGl_View_Print.cxx | 5 +++ src/V3d/V3d_View_Print.cxx | 7 ++++- src/ViewerTest/ViewerTest_ViewerCommands.cxx | 2 ++ 7 files changed, 49 insertions(+), 6 deletions(-) diff --git a/src/NCollection/NCollection_WinHeapAllocator.cxx b/src/NCollection/NCollection_WinHeapAllocator.cxx index caf647e5b1..fa28019933 100644 --- a/src/NCollection/NCollection_WinHeapAllocator.cxx +++ b/src/NCollection/NCollection_WinHeapAllocator.cxx @@ -37,6 +37,8 @@ NCollection_WinHeapAllocator::NCollection_WinHeapAllocator ULONG aHeapInfo = 2; HeapSetInformation (myHeapH, HeapCompatibilityInformation, &aHeapInfo, sizeof(aHeapInfo)); +#else + (void )theInitSizeBytes; #endif } diff --git a/src/OSD/OSD_Thread.cxx b/src/OSD/OSD_Thread.cxx index 598fa5717e..95097687c6 100644 --- a/src/OSD/OSD_Thread.cxx +++ b/src/OSD/OSD_Thread.cxx @@ -258,7 +258,7 @@ Standard_Boolean OSD_Thread::Wait (Standard_Address &result) const // OSD_Thread::Wait //============================================= -Standard_Boolean OSD_Thread::Wait (const Standard_Integer time, Standard_Address &result) const +Standard_Boolean OSD_Thread::Wait (const Standard_Integer theTimeMs, Standard_Address &result) const { // check that thread handle is not null result = 0; @@ -268,7 +268,7 @@ Standard_Boolean OSD_Thread::Wait (const Standard_Integer time, Standard_Address #ifdef _WIN32 // On Windows, wait for the thread handle to be signaled - DWORD ret = WaitForSingleObject ( myThread, time ); + DWORD ret = WaitForSingleObject (myThread, theTimeMs); if (ret == WAIT_OBJECT_0) { DWORD anExitCode; @@ -284,11 +284,32 @@ Standard_Boolean OSD_Thread::Wait (const Standard_Integer time, Standard_Address return Standard_False; #else + #if defined(__GLIBC__) && defined(__GLIBC_PREREQ) + #if __GLIBC_PREREQ(2,4) + #define HAS_TIMED_NP + #endif + #endif - // On Unix/Linux, join the thread - return ! pthread_join ( myThread, &result ); + #ifdef HAS_TIMED_NP + struct timespec aTimeout; + if (clock_gettime (CLOCK_REALTIME, &aTimeout) == -1) + { + return Standard_False; + } -#endif + time_t aSeconds = (theTimeMs / 1000); + long aMicroseconds = (theTimeMs - aSeconds * 1000) * 1000; + aTimeout.tv_sec += aSeconds; + aTimeout.tv_nsec += aMicroseconds * 1000; + + return pthread_timedjoin_np (myThread, &result, &aTimeout) == 0; + #else + // join the thread without timeout + (void )theTimeMs; + return pthread_join (myThread, &result) == 0; + #endif + +#endif } //============================================= diff --git a/src/OSD/OSD_signal.cxx b/src/OSD/OSD_signal.cxx index 9046a673c8..1f9c374397 100644 --- a/src/OSD/OSD_signal.cxx +++ b/src/OSD/OSD_signal.cxx @@ -115,7 +115,11 @@ static sigfpe_handler_type *GetOldFPE() //==== SIGSEGV is handled by "SegvHandler()" //============================================================================ #ifdef SA_SIGINFO + #if defined(HAVE_PTHREAD_H) && defined(NO_CXX_EXCEPTION) static void Handler (const int theSignal, siginfo_t *theSigInfo, const Standard_Address theContext) + #else +static void Handler (const int theSignal, siginfo_t */*theSigInfo*/, const Standard_Address /*theContext*/) + #endif #else static void Handler (const int theSignal) #endif @@ -338,6 +342,8 @@ static void SegvHandler(const int theSignal, Handler(theSignal, ip, theContext); return; } +#else + (void )theContext; #endif #ifdef linux if (fFltExceptions) diff --git a/src/OpenGl/OpenGl_Text.cxx b/src/OpenGl/OpenGl_Text.cxx index 139be47288..a27f4fdbcd 100644 --- a/src/OpenGl/OpenGl_Text.cxx +++ b/src/OpenGl/OpenGl_Text.cxx @@ -541,6 +541,8 @@ void OpenGl_Text::setupMatrix (const Handle(OpenGl_PrinterContext)& thePrintCtx, // as it is better for keeping text/3d graphics proportions Graphic3d_TransformUtils::Scale (aModViewMat, aTextScaley, aTextScaley, aTextScaley); } + #else + (void )thePrintCtx; #endif Graphic3d_TransformUtils::Scale (aModViewMat, myScaleHeight, myScaleHeight, myScaleHeight); } diff --git a/src/OpenGl/OpenGl_View_Print.cxx b/src/OpenGl/OpenGl_View_Print.cxx index 5f53f44667..3251a5e4db 100644 --- a/src/OpenGl/OpenGl_View_Print.cxx +++ b/src/OpenGl/OpenGl_View_Print.cxx @@ -761,6 +761,11 @@ Standard_Boolean OpenGl_View::Print (const Aspect_Handle thePrinterDC, return (Standard_Boolean) isDone; #else // not _WIN32 + (void )thePrinterDC; + (void )theToShowBackground; + (void )theFileName; + (void )thePrintAlgorithm; + (void )theScaleFactor; Standard_NotImplemented::Raise ("OpenGl_View::Print is implemented only on Windows"); myWorkspace->PrinterContext().Nullify(); return Standard_False; diff --git a/src/V3d/V3d_View_Print.cxx b/src/V3d/V3d_View_Print.cxx index dede6b0e4b..edeaa5903c 100644 --- a/src/V3d/V3d_View_Print.cxx +++ b/src/V3d/V3d_View_Print.cxx @@ -79,7 +79,7 @@ Device::~Device() #endif //============================================================================= -//function : SetGrid +//function : Print //purpose : //============================================================================= Standard_Boolean V3d_View::Print (const Aspect_Handle thePrintDC, @@ -143,6 +143,11 @@ Standard_Boolean V3d_View::Print (const Aspect_Handle thePrintDC, return myView->Print (device._pd.hDC, theShowBackground, theFilename, thePrintAlgorithm, aScaleFactor); } #else + (void )thePrintDC; + (void )theShowDialog; + (void )theShowBackground; + (void )theFilename; + (void )thePrintAlgorithm; Standard_NotImplemented::Raise ("V3d_View::Print is implemented only on Windows"); #endif return Standard_False; diff --git a/src/ViewerTest/ViewerTest_ViewerCommands.cxx b/src/ViewerTest/ViewerTest_ViewerCommands.cxx index 9642900302..28077010f2 100644 --- a/src/ViewerTest/ViewerTest_ViewerCommands.cxx +++ b/src/ViewerTest/ViewerTest_ViewerCommands.cxx @@ -4275,6 +4275,8 @@ static int VPrintView (Draw_Interpretor& di, Standard_Integer argc, const char** argv) { #ifndef _WIN32 + (void )argc; + (void )argv; di << "Printing implemented only for WNT!\n"; return 0; #else