Index: src/hu/varadiistvan/scpl/Mutex.h
===================================================================
--- src/hu/varadiistvan/scpl/Mutex.h	(revision 4)
+++ src/hu/varadiistvan/scpl/Mutex.h	(revision 4)
@@ -0,0 +1,105 @@
+// Copyright (c) 2013 by István Váradi
+
+// This file is part of VSCPL, a simple cross-platform utility library
+
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+
+// 1. Redistributions of source code must retain the above copyright notice, this
+//    list of conditions and the following disclaimer.
+// 2. Redistributions in binary form must reproduce the above copyright notice,
+//    this list of conditions and the following disclaimer in the documentation
+//    and/or other materials provided with the distribution.
+
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+// The views and conclusions contained in the software and documentation are those
+// of the authors and should not be interpreted as representing official policies,
+// either expressed or implied, of the FreeBSD Project.
+
+#ifndef HU_VARADIISTVAN_SCPL_MUTEX_H
+#define HU_VARADIISTVAN_SCPL__MUTEX_H
+//------------------------------------------------------------------------------
+
+#if 0 // The public interface of Mutex
+
+//------------------------------------------------------------------------------
+
+namespace hu { namespace varadiistvan { namespace scpl {
+
+//------------------------------------------------------------------------------
+
+/**
+ * A mutual exclusion device.
+ */
+class Mutex
+{
+public:
+    /**
+     * Lock the mutex. If the mutex is locked by another thread, the
+     * caller one waits until the other thread releases the mutex.
+     */
+    void lock();
+
+    /**
+     * Try to lock the mutex. If the mutex is locked by another
+     * thread, this function returns false immediately. Otherwise it
+     * locks the mutex and returns true.
+     */
+    bool tryLock();
+
+    /**
+     * Unlock the mutex.
+     */
+    void unlock();
+};
+
+//------------------------------------------------------------------------------
+
+} /* namespace hu::varadiistvan::scpl */ } /* namespace hu::varadiistvan */ } /* namespace hu */
+
+//------------------------------------------------------------------------------
+
+#endif // 0, The public interface of Mutex
+
+//------------------------------------------------------------------------------
+
+#include "config.h"
+
+//------------------------------------------------------------------------------
+
+#if TARGET_API_POSIX
+
+#include "_posix/Mutex.h"
+
+//------------------------------------------------------------------------------
+
+#elif TARGET_API_WIN32 || TARGET_API_WIN64
+
+#include "_win32/Mutex.h"
+
+//------------------------------------------------------------------------------
+
+#else
+
+#error "Not implemented for this target!"
+
+#endif
+
+//------------------------------------------------------------------------------
+#endif // HU_VARADIISTVAN_SCPL_MUTEX_H
+
+// Local Variables:
+// mode: C++
+// c-basic-offset: 4
+// indent-tabs-mode: nil
+// End:
Index: src/hu/varadiistvan/scpl/_posix/Mutex.h
===================================================================
--- src/hu/varadiistvan/scpl/_posix/Mutex.h	(revision 4)
+++ src/hu/varadiistvan/scpl/_posix/Mutex.h	(revision 4)
@@ -0,0 +1,132 @@
+// Copyright (c) 2013 by István Váradi
+
+// This file is part of VSCPL, a simple cross-platform utility library
+
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+
+// 1. Redistributions of source code must retain the above copyright notice, this
+//    list of conditions and the following disclaimer.
+// 2. Redistributions in binary form must reproduce the above copyright notice,
+//    this list of conditions and the following disclaimer in the documentation
+//    and/or other materials provided with the distribution.
+
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+// The views and conclusions contained in the software and documentation are those
+// of the authors and should not be interpreted as representing official policies,
+// either expressed or implied, of the FreeBSD Project.
+
+#ifndef HU_VARADIISTVAN_SCPL_MUTEX_H
+#define HU_VARADIISTVAN_SCPL_MUTEX_H
+//------------------------------------------------------------------------------
+
+#include <pthread.h>
+
+//------------------------------------------------------------------------------
+
+namespace hu { namespace varadiistvan { namespace scpl {
+
+//------------------------------------------------------------------------------
+
+/**
+ * Mutual exclusion device for POSIX threads.
+ */
+class Mutex
+{
+private:
+    /**
+     * The mutex structure.
+     */
+    pthread_mutex_t mutex;
+
+public:
+    /**
+     * Construct the mutex.
+     */
+    Mutex();
+
+    /**
+     * Destroy the mutex.
+     */
+    ~Mutex();
+
+    /**
+     * Lock the mutex. If the mutex is locked by another thread, the
+     * caller one waits until the other thread releases the mutex.
+     */
+    void lock();
+
+    /**
+     * Try to lock the mutex. If the mutex is locked by another
+     * thread, this function returns false immediately. Otherwise it
+     * locks the mutex and returns true.
+     */
+    bool tryLock();
+
+    /**
+     * Unlock the mutex.
+     */
+    void unlock();
+
+    friend class CondVar;
+};
+
+//------------------------------------------------------------------------------
+// Inline definitions
+//------------------------------------------------------------------------------
+
+inline Mutex::Mutex()
+{
+    pthread_mutex_init(&mutex, 0);
+}
+
+//------------------------------------------------------------------------------
+
+inline Mutex::~Mutex()
+{
+    pthread_mutex_destroy(&mutex);
+}
+
+//------------------------------------------------------------------------------
+
+inline void Mutex::lock()
+{
+    pthread_mutex_lock(&mutex);
+}
+
+//------------------------------------------------------------------------------
+
+inline bool Mutex::tryLock()
+{
+    return pthread_mutex_trylock(&mutex)==0;
+}
+
+//------------------------------------------------------------------------------
+
+inline void Mutex::unlock()
+{
+    pthread_mutex_unlock(&mutex);
+}
+
+//------------------------------------------------------------------------------
+
+} /* namespace hu::varadiistvan::scpl */ } /* namespace hu::varadiistvan */ } /* namespace hu */
+
+//------------------------------------------------------------------------------
+#endif // HU_VARADIISTVAN_SCPL_MUTEX_H
+
+// Local Variables:
+// mode: C++
+// c-basic-offset: 4
+// indent-tabs-mode: nil
+// End:
Index: src/hu/varadiistvan/scpl/_win32/Mutex.h
===================================================================
--- src/hu/varadiistvan/scpl/_win32/Mutex.h	(revision 4)
+++ src/hu/varadiistvan/scpl/_win32/Mutex.h	(revision 4)
@@ -0,0 +1,132 @@
+// Copyright (c) 2013 by István Váradi
+
+// This file is part of VSCPL, a simple cross-platform utility library
+
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+
+// 1. Redistributions of source code must retain the above copyright notice, this
+//    list of conditions and the following disclaimer.
+// 2. Redistributions in binary form must reproduce the above copyright notice,
+//    this list of conditions and the following disclaimer in the documentation
+//    and/or other materials provided with the distribution.
+
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+// The views and conclusions contained in the software and documentation are those
+// of the authors and should not be interpreted as representing official policies,
+// either expressed or implied, of the FreeBSD Project.
+
+#ifndef HU_VARADIISTVAN_SCPL_MUTEX_H
+#define HU_VARADIISTVAN_SCPL_MUTEX_H
+//------------------------------------------------------------------------------
+
+#include <windows.h>
+
+//------------------------------------------------------------------------------
+
+namespace hu { namespace varadiistvan { namespace scpl {
+
+//------------------------------------------------------------------------------
+
+/**
+ * Mutual exclusion device implementation for Windows.
+ */
+class Mutex
+{
+private:
+    /**
+     * The handle of the mutex.
+     */
+    CRITICAL_SECTION mutex;
+
+public:
+    /**
+     * Construct the mutex.
+     */
+    Mutex();
+
+    /**
+     * Destroy the mutex.
+     */
+    ~Mutex();
+
+    /**
+     * Lock the mutex. If the mutex is locked by another thread, the
+     * caller one waits until the other thread releases the mutex.
+     */
+    void lock();
+
+    /**
+     * Try to lock the mutex. If the mutex is locked by another
+     * thread, this function returns false immediately. Otherwise it
+     * locks the mutex and returns true.
+     */
+    bool tryLock();
+
+    /**
+     * Unlock the mutex.
+     */
+    void unlock();
+
+    friend class CondVar;
+};
+
+//------------------------------------------------------------------------------
+// Inline definitions
+//------------------------------------------------------------------------------
+
+inline Mutex::Mutex()
+{
+    InitializeCriticalSection(&mutex);
+}
+
+//------------------------------------------------------------------------------
+
+inline Mutex::~Mutex()
+{
+    DeleteCriticalSection(&mutex);
+}
+
+//------------------------------------------------------------------------------
+
+inline void Mutex::lock()
+{
+    EnterCriticalSection(&mutex);
+}
+
+//------------------------------------------------------------------------------
+
+inline bool Mutex::tryLock()
+{
+    return TryEnterCriticalSection(&mutex);
+}
+
+//------------------------------------------------------------------------------
+
+inline void Mutex::unlock()
+{
+    LeaveCriticalSection(&mutex);
+}
+
+//------------------------------------------------------------------------------
+
+} /* namespace hu::varadiistvan::scpl */ } /* namespace hu::varadiistvan */ } /* namespace hu */
+
+//------------------------------------------------------------------------------
+#endif // HU_VARADIISTVAN_SCPL_MUTEX_H
+
+// Local Variables:
+// mode: C++
+// c-basic-offset: 4
+// indent-tabs-mode: nil
+// End:
Index: src/hu/varadiistvan/scpl/hgccwrapper
===================================================================
--- src/hu/varadiistvan/scpl/hgccwrapper	(revision 4)
+++ src/hu/varadiistvan/scpl/hgccwrapper	(revision 4)
@@ -0,0 +1,96 @@
+#!/bin/sh
+
+# Create a skeleton of a wrapper header for a certain class
+
+classname=$1
+uppername=`echo ${classname} | tr a-z A-Z`
+
+cat > "${classname}.h" <<EOF
+// Copyright (c) 2013 by István Váradi
+
+// This file is part of VSCPL, a simple cross-platform utility library
+
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+
+// 1. Redistributions of source code must retain the above copyright notice, this
+//    list of conditions and the following disclaimer.
+// 2. Redistributions in binary form must reproduce the above copyright notice,
+//    this list of conditions and the following disclaimer in the documentation
+//    and/or other materials provided with the distribution.
+
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+// The views and conclusions contained in the software and documentation are those
+// of the authors and should not be interpreted as representing official policies,
+// either expressed or implied, of the FreeBSD Project.
+
+#ifndef HU_VARADIISTVAN_SCPL_${uppername}_H
+#define HU_VARADIISTVAN_SCPL__${uppername}_H
+//------------------------------------------------------------------------------
+
+#if 0 // The public interface of ${classname}
+
+//------------------------------------------------------------------------------
+
+namespace hu { namespace varadiistvan { namespace scpl {
+
+//------------------------------------------------------------------------------
+
+class ${classname}
+{
+public:
+};
+
+//------------------------------------------------------------------------------
+
+} /* namespace hu::varadiistvan::scpl */ } /* namespace hu::varadiistvan */ } /* namespace hu */
+
+//------------------------------------------------------------------------------
+
+#endif // 0, The public interface of ${classname}
+
+//------------------------------------------------------------------------------
+
+#include "config.h"
+
+//------------------------------------------------------------------------------
+
+#if TARGET_API_POSIX
+
+#include "_posix/${classname}.h"
+
+//------------------------------------------------------------------------------
+
+#elif TARGET_API_WIN32 || TARGET_API_WIN64
+
+#include "_win32/${classname}.h"
+
+//------------------------------------------------------------------------------
+
+#else
+
+#error "Not implemented for this target!"
+
+#endif
+
+//------------------------------------------------------------------------------
+#endif // HU_VARADIISTVAN_SCPL_${uppername}_H
+
+// Local Variables:
+// mode: C++
+// c-basic-offset: 4
+// indent-tabs-mode: nil
+// End:
+EOF
+
+hg add "${classname}.h"
