From 35af1c00cc1bb903da2d7c9bc953a81f13553a12 Mon Sep 17 00:00:00 2001 From: Michael R Sweet Date: Sun, 12 Sep 2004 03:46:21 +0000 Subject: [PATCH] Fixed a compile problem with the Linux 2.6 threading support (STR #483) git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@3820 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- CHANGES | 2 ++ src/Fl_lock.cxx | 18 +++++++++++------- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/CHANGES b/CHANGES index a68f0be8a..2b8343a52 100644 --- a/CHANGES +++ b/CHANGES @@ -3,6 +3,8 @@ CHANGES IN FLTK 1.1.5rc3 - Documentation updates (STR #505, STR #513) - Updated PNG library source to 1.2.6 + wutil patch. - Updated ZLIB library source to 1.2.1. + - Fixed a compile problem with the Linux 2.6 threading + support (STR #483) - Fixed problems with 2-byte Xpm files on 64-bit platforms (STR #525) - FLTK didn't handle the ReparentNotify event on X11 diff --git a/src/Fl_lock.cxx b/src/Fl_lock.cxx index 1fc8e0b7e..da2018f84 100644 --- a/src/Fl_lock.cxx +++ b/src/Fl_lock.cxx @@ -1,5 +1,5 @@ // -// "$Id: Fl_lock.cxx,v 1.13.2.5 2004/04/11 04:38:59 easysw Exp $" +// "$Id: Fl_lock.cxx,v 1.13.2.6 2004/09/12 03:46:21 easysw Exp $" // // Multi-threading support code for the Fast Light Tool Kit (FLTK). // @@ -127,12 +127,19 @@ void Fl::awake(void* msg) { # include # include -# ifdef PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP +# if defined (PTHREAD_MUTEX_RECURSIVE_NP) // Linux supports recursive locks, use them directly: -static pthread_mutex_t fltk_mutex = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP; +static bool minit; +static pthread_mutex_t fltk_mutex; +// this is needed for the Fl_Mutex constructor: +pthread_mutexattr_t Fl_Mutex_attrib = {PTHREAD_MUTEX_RECURSIVE_NP}; static void lock_function() { + if (!minit) { + pthread_mutex_init(&fltk_mutex, &Fl_Mutex_attrib); + minit = true; + } pthread_mutex_lock(&fltk_mutex); } @@ -140,9 +147,6 @@ void Fl::unlock() { pthread_mutex_unlock(&fltk_mutex); } -// this is needed for the Fl_Mutex constructor: -pthread_mutexattr_t Fl_Mutex_attrib = {PTHREAD_MUTEX_RECURSIVE_NP}; - # else // Make a recursive lock out of the pthread mutex: @@ -200,5 +204,5 @@ void Fl::awake(void* msg) { #endif // -// End of "$Id: Fl_lock.cxx,v 1.13.2.5 2004/04/11 04:38:59 easysw Exp $". +// End of "$Id: Fl_lock.cxx,v 1.13.2.6 2004/09/12 03:46:21 easysw Exp $". //