 
 Upstream-Status: Inappropriate [creates Linux dependency]
 ---
- lib/global_mutex.cpp | 103 +++++++++++++++++++++++++++++++++++++++++++++++++++
- lib/global_mutex.h   |  18 +++++++++
- 2 files changed, 121 insertions(+)
+ lib/global_mutex.cpp | 173 +++++++++++++++++++++++++++++++++++++++++++++++++++
+ lib/global_mutex.h   |  18 ++++++
+ 2 files changed, 191 insertions(+)
  create mode 100644 lib/global_mutex.cpp
  create mode 100644 lib/global_mutex.h
 
 diff --git a/lib/global_mutex.cpp b/lib/global_mutex.cpp
 new file mode 100644
-index 0000000..88f57ee
+index 0000000..d842ece
 --- /dev/null
 +++ b/lib/global_mutex.cpp
-@@ -0,0 +1,103 @@
+@@ -0,0 +1,173 @@
 +/* Implementation of curl_global_mutex_lock() and curl_global_mutex_unlock().
 + * 
 + * @note This C++ source file MUST NOT throw exceptions, use RTTI, or

+			InitializeCriticalSection(&cs_);
+#elif defined VXWORKS_PPC
+			sem_ = semMCreate(SEM_Q_PRIORITY | SEM_DELETE_SAFE | SEM_INVERSION_SAFE);
+#endif
+		}
+
+		inline ~_CriticalSection()
+		{
+#ifdef _WIN32
+			DeleteCriticalSection(&cs_);
+#elif defined VXWORKS_PPC
+			semDelete(sem_);
+#endif
+		}
+

+	void curl_global_mutex_lock()
+	{
+		// Do NOT add try/catch blocks here. See comments above for details.
+#if defined(_WIN32) || defined(VXWORKS_PPC) || defined(macintosh) || defined(__APPLE__) || defined(__APPLE_CC__)
+		g_cs.lock();
+#elif defined(linux) || defined(__linux__) || defined(__gnu_linux__) || defined(__linux)
+                if (pthread_mutex_lock(&mutex_))
+                {
+                        perror("cURL fatal error: Error locking mutex");
+                        exit(-1);
+                }
+#endif
+	}
+
+	void curl_global_mutex_unlock()
+	{
+		// Do NOT add try/catch blocks here. See comments above for details.
+#if defined(_WIN32) || defined(VXWORKS_PPC) || defined(macintosh) || defined(__APPLE__) || defined(__APPLE_CC__)
+		g_cs.unlock();
+#elif defined(linux) || defined(__linux__) || defined(__gnu_linux__) || defined(__linux)
+                if (pthread_mutex_unlock(&mutex_))
+                {
+                        perror("cURL fatal error: Error unlocking mutex");
+                        exit(-1);
+                }
+#endif
+	}
+}
