+#ifdef FEATURE_PTHREAD
+/*********************************************************************
+ *
+ * Function : privoxy_mutex_lock
+ *
+ * Description : Locks a mutex using pthread_mutex_lock.
+ *
+ * Parameters :
+ * 1 : mutex = The mutex to lock.
+ *
+ * Returns : Void, exits in case of errors.
+ *
+ *********************************************************************/
+void privoxy_mutex_lock(privoxy_mutex_t *mutex)
+{
+ int err = pthread_mutex_lock(mutex);
+ if (err)
+ {
+ if (mutex != &log_mutex)
+ {
+ log_error(LOG_LEVEL_FATAL,
+ "Mutex locking failed: %s.\n", strerror(err));
+ }
+ exit(1);
+ }
+}
+
+
+/*********************************************************************
+ *
+ * Function : privoxy_mutex_unlock
+ *
+ * Description : Unlocks a mutex using pthread_mutex_unlock.
+ *
+ * Parameters :
+ * 1 : mutex = The mutex to unlock.
+ *
+ * Returns : Void, exits in case of errors.
+ *
+ *********************************************************************/
+void privoxy_mutex_unlock(privoxy_mutex_t *mutex)
+{
+ int err = pthread_mutex_unlock(mutex);
+ if (err)
+ {
+ if (mutex != &log_mutex)
+ {
+ log_error(LOG_LEVEL_FATAL,
+ "Mutex unlocking failed: %s.\n", strerror(err));
+ }
+ exit(1);
+ }
+}
+
+
+/*********************************************************************
+ *
+ * Function : privoxy_mutex_init
+ *
+ * Description : Prepares a mutex using pthread_mutex_init.
+ *
+ * Parameters :
+ * 1 : mutex = The mutex to initialize.
+ *
+ * Returns : Void, exits in case of errors.
+ *
+ *********************************************************************/
+static void privoxy_mutex_init(privoxy_mutex_t *mutex)
+{
+ int err = pthread_mutex_init(mutex, 0);
+ if (err)
+ {
+ printf("Fatal error. Mutex initialization failed: %s.\n",
+ strerror(err));
+ exit(1);
+ }
+}
+#endif /* def FEATURE_PTHREAD */
+
+