Replace Windows specific thread handling

Use the platform independent primitives instead.
diff --git a/common/rfb/Configuration.cxx b/common/rfb/Configuration.cxx
index 8e1ea6e..a5c2302 100644
--- a/common/rfb/Configuration.cxx
+++ b/common/rfb/Configuration.cxx
@@ -23,24 +23,14 @@
 #include <ctype.h>
 #include <string.h>
 
+#include <os/Mutex.h>
+
 #include <rfb/util.h>
 #include <rfb/Configuration.h>
 #include <rfb/LogWriter.h>
 #include <rfb/Exception.h>
-#include <rfb/Threading.h>
 
-#ifdef __RFB_THREADING_IMPL
-// On platforms that support Threading, we use Locks to make getData safe
-#define LOCK_CONFIG Lock l(*configLock())
-rfb::Mutex* configLock_ = 0;
-static rfb::Mutex* configLock() {
-  if (!configLock_)
-    configLock_ = new rfb::Mutex;
-  return configLock_;
-}
-#else
-#define LOCK_CONFIG
-#endif
+#define LOCK_CONFIG os::AutoMutex a(mutex)
 
 #include <rdr/HexOutStream.h>
 #include <rdr/HexInStream.h>
@@ -195,9 +185,12 @@
 
   _next = conf->head;
   conf->head = this;
+
+  mutex = new os::Mutex();
 }
 
 VoidParameter::~VoidParameter() {
+  delete mutex;
 }
 
 const char*
diff --git a/common/rfb/Configuration.h b/common/rfb/Configuration.h
index da93fdd..fbf161d 100644
--- a/common/rfb/Configuration.h
+++ b/common/rfb/Configuration.h
@@ -45,6 +45,8 @@
 
 #include <rfb/util.h>
 
+namespace os { class Mutex; }
+
 namespace rfb {
   class VoidParameter;
   struct ParameterIterator;
@@ -174,6 +176,8 @@
     bool immutable;
     const char* name;
     const char* description;
+
+    os::Mutex* mutex;
   };
 
   class AliasParameter : public VoidParameter {
diff --git a/common/rfb/KeyRemapper.cxx b/common/rfb/KeyRemapper.cxx
index d33f0a4..b4c2793 100644
--- a/common/rfb/KeyRemapper.cxx
+++ b/common/rfb/KeyRemapper.cxx
@@ -17,6 +17,9 @@
  */
 
 #include <stdio.h>
+
+#include <os/Mutex.h>
+
 #include <rfb/KeyRemapper.h>
 #include <rfb/Configuration.h>
 #include <rfb/LogWriter.h>
@@ -27,14 +30,21 @@
 
 KeyRemapper KeyRemapper::defInstance;
 
-#ifdef __RFB_THREADING_IMPL
-static Mutex mappingLock;
-#endif
+KeyRemapper::KeyRemapper(const char* m)
+{
+  mutex = new os::Mutex;
+
+  setMapping(m);
+}
+
+KeyRemapper::~KeyRemapper()
+{
+  delete mutex;
+}
 
 void KeyRemapper::setMapping(const char* m) {
-#ifdef __RFB_THREADING_IMPL
-  Lock l(mappingLock);
-#endif
+  os::AutoMutex a(mutex);
+
   mapping.clear();
   while (m[0]) {
     int from, to;
@@ -59,9 +69,8 @@
 }
 
 rdr::U32 KeyRemapper::remapKey(rdr::U32 key) const {
-#ifdef __RFB_THREADING_IMPL
-  Lock l(mappingLock);
-#endif
+  os::AutoMutex a(mutex);
+
   std::map<rdr::U32,rdr::U32>::const_iterator i = mapping.find(key);
   if (i != mapping.end())
     return i->second;
diff --git a/common/rfb/KeyRemapper.h b/common/rfb/KeyRemapper.h
index a4b7aa0..1406bad 100644
--- a/common/rfb/KeyRemapper.h
+++ b/common/rfb/KeyRemapper.h
@@ -22,16 +22,20 @@
 #include <map>
 #include <rdr/types.h>
 
+namespace os { class Mutex; }
+
 namespace rfb {
 
   class KeyRemapper {
   public:
-    KeyRemapper(const char* m="") { setMapping(m); }
+    KeyRemapper(const char* m="");
+    ~KeyRemapper();
     void setMapping(const char* m);
     rdr::U32 remapKey(rdr::U32 key) const;
     static KeyRemapper defInstance;
   private:
     std::map<rdr::U32,rdr::U32> mapping;
+    os::Mutex* mutex;
   };
 
 };
diff --git a/common/rfb/Logger_file.cxx b/common/rfb/Logger_file.cxx
index ebe15d5..149ad40 100644
--- a/common/rfb/Logger_file.cxx
+++ b/common/rfb/Logger_file.cxx
@@ -21,36 +21,30 @@
 #include <stdlib.h>
 #include <string.h>
 
+#include <os/Mutex.h>
+
 #include <rfb/util.h>
 #include <rfb/Logger_file.h>
-#include <rfb/Threading.h>
 
 using namespace rfb;
 
-
-// If threading is available then protect the write() operation
-// from concurrent accesses
-#ifdef __RFB_THREADING_IMPL
-static Mutex logLock;
-#endif
-
-
 Logger_File::Logger_File(const char* loggerName)
   : Logger(loggerName), indent(13), width(79), m_filename(0), m_file(0),
     m_lastLogTime(0)
 {
+  mutex = new os::Mutex();
 }
 
 Logger_File::~Logger_File()
 {
   closeFile();
+  delete mutex;
 }
 
 void Logger_File::write(int level, const char *logname, const char *message)
 {
-#ifdef __RFB_THREADING_IMPL
-  Lock l(logLock);
-#endif
+  os::AutoMutex a(mutex);
+
   if (!m_file) {
     if (!m_filename) return;
     CharArray bakFilename(strlen(m_filename) + 1 + 4);
diff --git a/common/rfb/Logger_file.h b/common/rfb/Logger_file.h
index 5e0c917..5b5c34e 100644
--- a/common/rfb/Logger_file.h
+++ b/common/rfb/Logger_file.h
@@ -24,6 +24,8 @@
 #include <time.h>
 #include <rfb/Logger.h>
 
+namespace os { class Mutex; }
+
 namespace rfb {
 
   class Logger_File : public Logger {
@@ -43,6 +45,7 @@
     char* m_filename;
     FILE* m_file;
     time_t m_lastLogTime;
+    os::Mutex* mutex;
   };
 
   bool initFileLogger(const char* filename);
diff --git a/common/rfb/Logger_syslog.cxx b/common/rfb/Logger_syslog.cxx
index 291d36c..dc1d0c1 100644
--- a/common/rfb/Logger_syslog.cxx
+++ b/common/rfb/Logger_syslog.cxx
@@ -25,7 +25,6 @@
 #include <rfb/util.h>
 #include <rfb/Logger_syslog.h>
 #include <rfb/LogWriter.h>
-#include <rfb/Threading.h>
 
 using namespace rfb;
 
diff --git a/common/rfb/Threading.h b/common/rfb/Threading.h
deleted file mode 100644
index 66b3aa0..0000000
--- a/common/rfb/Threading.h
+++ /dev/null
@@ -1,31 +0,0 @@
-/* Copyright (C) 2002-2005 RealVNC Ltd.  All Rights Reserved.
- * 
- * This is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- * 
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- * 
- * You should have received a copy of the GNU General Public License
- * along with this software; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,
- * USA.
- */
-
-// -=- Threading.h
-// General purpose threading interface.
-// If the current platform supports threading then __RFB_THREADING_IMPL
-// will be defined after this header has been included.
-
-#ifndef __RFB_THREADING_H__
-#define __RFB_THREADING_H__
-
-#ifdef WIN32
-#include <rfb_win32/Threading.h>
-#endif
-
-#endif // __RFB_THREADING_H__