summaryrefslogtreecommitdiff
path: root/src/SFML/System
diff options
context:
space:
mode:
authorChristoph Egger <Christoph.Egger@gmx.de>2008-05-20 13:58:13 +0200
committerChristoph Egger <Christoph.Egger@gmx.de>2008-05-20 13:58:13 +0200
commitff2dd2d0218cea258446af2c781298192404aa68 (patch)
treed36a5a7e71af593c65882d46619716cb0d82789d /src/SFML/System
Imported Upstream version 1.2
Diffstat (limited to 'src/SFML/System')
-rwxr-xr-xsrc/SFML/System/Clock.cpp60
-rwxr-xr-xsrc/SFML/System/Lock.cpp52
-rwxr-xr-xsrc/SFML/System/Makefile22
-rwxr-xr-xsrc/SFML/System/Platform.hpp45
-rwxr-xr-xsrc/SFML/System/Randomizer.cpp96
-rwxr-xr-xsrc/SFML/System/Sleep.cpp42
-rwxr-xr-xsrc/SFML/System/Unix/Mutex.cpp68
-rwxr-xr-xsrc/SFML/System/Unix/Platform.cpp58
-rwxr-xr-xsrc/SFML/System/Unix/Platform.hpp69
-rwxr-xr-xsrc/SFML/System/Unix/Thread.cpp146
-rwxr-xr-xsrc/SFML/System/Win32/Mutex.cpp68
-rwxr-xr-xsrc/SFML/System/Win32/Platform.cpp70
-rwxr-xr-xsrc/SFML/System/Win32/Platform.hpp69
-rwxr-xr-xsrc/SFML/System/Win32/Thread.cpp144
14 files changed, 1009 insertions, 0 deletions
diff --git a/src/SFML/System/Clock.cpp b/src/SFML/System/Clock.cpp
new file mode 100755
index 0000000..e7fe665
--- /dev/null
+++ b/src/SFML/System/Clock.cpp
@@ -0,0 +1,60 @@
+////////////////////////////////////////////////////////////
+//
+// SFML - Simple and Fast Multimedia Library
+// Copyright (C) 2007 Laurent Gomila (laurent.gom@gmail.com)
+//
+// This software is provided 'as-is', without any express or implied warranty.
+// In no event will the authors be held liable for any damages arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it freely,
+// subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented;
+// you must not claim that you wrote the original software.
+// If you use this software in a product, an acknowledgment
+// in the product documentation would be appreciated but is not required.
+//
+// 2. Altered source versions must be plainly marked as such,
+// and must not be misrepresented as being the original software.
+//
+// 3. This notice may not be removed or altered from any source distribution.
+//
+////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////
+// Headers
+////////////////////////////////////////////////////////////
+#include <SFML/System/Clock.hpp>
+#include <SFML/System/Platform.hpp>
+
+
+namespace sf
+{
+////////////////////////////////////////////////////////////
+/// Default constructor
+////////////////////////////////////////////////////////////
+Clock::Clock()
+{
+ Reset();
+}
+
+
+////////////////////////////////////////////////////////////
+/// Get the time elapsed since last reset
+////////////////////////////////////////////////////////////
+float Clock::GetElapsedTime() const
+{
+ return static_cast<float>(sf::priv::Platform::GetSystemTime() - myStartTime);
+}
+
+
+////////////////////////////////////////////////////////////
+/// Restart the timer
+////////////////////////////////////////////////////////////
+void Clock::Reset()
+{
+ myStartTime = sf::priv::Platform::GetSystemTime();
+}
+
+} // namespace sf
diff --git a/src/SFML/System/Lock.cpp b/src/SFML/System/Lock.cpp
new file mode 100755
index 0000000..90bbaa9
--- /dev/null
+++ b/src/SFML/System/Lock.cpp
@@ -0,0 +1,52 @@
+////////////////////////////////////////////////////////////
+//
+// SFML - Simple and Fast Multimedia Library
+// Copyright (C) 2007 Laurent Gomila (laurent.gom@gmail.com)
+//
+// This software is provided 'as-is', without any express or implied warranty.
+// In no event will the authors be held liable for any damages arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it freely,
+// subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented;
+// you must not claim that you wrote the original software.
+// If you use this software in a product, an acknowledgment
+// in the product documentation would be appreciated but is not required.
+//
+// 2. Altered source versions must be plainly marked as such,
+// and must not be misrepresented as being the original software.
+//
+// 3. This notice may not be removed or altered from any source distribution.
+//
+////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////
+// Headers
+////////////////////////////////////////////////////////////
+#include <SFML/System/Lock.hpp>
+#include <SFML/System/Mutex.hpp>
+
+
+namespace sf
+{
+////////////////////////////////////////////////////////////
+/// Construct the lock with a target mutex (lock it)
+////////////////////////////////////////////////////////////
+Lock::Lock(Mutex& Mutex) :
+myMutex(Mutex)
+{
+ myMutex.Lock();
+}
+
+
+////////////////////////////////////////////////////////////
+/// Destructor (unlocks the mutex)
+////////////////////////////////////////////////////////////
+Lock::~Lock()
+{
+ myMutex.Unlock();
+}
+
+} // namespace sf
diff --git a/src/SFML/System/Makefile b/src/SFML/System/Makefile
new file mode 100755
index 0000000..480ff66
--- /dev/null
+++ b/src/SFML/System/Makefile
@@ -0,0 +1,22 @@
+LIB = libsfml-system.so
+SRC = $(wildcard *.cpp ./Unix/*.cpp)
+OBJ = $(SRC:.cpp=.o)
+
+all: $(LIB)
+
+libsfml-system.so: $(OBJ)
+ $(CPP) $(LDFLAGS) -Wl,-soname,$(LIB).$(VERSION) -o $(LIBPATH)/$@.$(VERSION) $(OBJ) -lpthread
+
+$(OBJ): %.o: %.cpp
+ $(CPP) -o $@ -c $< $(CFLAGS)
+
+.PHONY: clean mrproper
+
+clean:
+ @rm -rf $(OBJ)
+
+mrproper: clean
+ @rm -rf $(LIBPATH)/$(LIB)
+
+install:
+ @($(CP) $(LIBPATH)/$(LIB).$(VERSION) /usr/lib && $(LN) $(LNFLAGS) /usr/lib/$(LIB).$(VERSION) /usr/lib/$(LIB)) \ No newline at end of file
diff --git a/src/SFML/System/Platform.hpp b/src/SFML/System/Platform.hpp
new file mode 100755
index 0000000..8ad9700
--- /dev/null
+++ b/src/SFML/System/Platform.hpp
@@ -0,0 +1,45 @@
+////////////////////////////////////////////////////////////
+//
+// SFML - Simple and Fast Multimedia Library
+// Copyright (C) 2007 Laurent Gomila (laurent.gom@gmail.com)
+//
+// This software is provided 'as-is', without any express or implied warranty.
+// In no event will the authors be held liable for any damages arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it freely,
+// subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented;
+// you must not claim that you wrote the original software.
+// If you use this software in a product, an acknowledgment
+// in the product documentation would be appreciated but is not required.
+//
+// 2. Altered source versions must be plainly marked as such,
+// and must not be misrepresented as being the original software.
+//
+// 3. This notice may not be removed or altered from any source distribution.
+//
+////////////////////////////////////////////////////////////
+
+#ifndef SFML_PLATFORM_HPP
+#define SFML_PLATFORM_HPP
+
+////////////////////////////////////////////////////////////
+// Headers
+////////////////////////////////////////////////////////////
+#include <SFML/Config.hpp>
+
+
+#if defined(SFML_SYSTEM_WINDOWS)
+
+ #include <SFML/System/Win32/Platform.hpp>
+
+#elif defined(SFML_SYSTEM_LINUX) || defined(SFML_SYSTEM_MACOS)
+
+ #include <SFML/System/Unix/Platform.hpp>
+
+#endif
+
+
+#endif // SFML_PLATFORM_HPP
diff --git a/src/SFML/System/Randomizer.cpp b/src/SFML/System/Randomizer.cpp
new file mode 100755
index 0000000..8b4eefc
--- /dev/null
+++ b/src/SFML/System/Randomizer.cpp
@@ -0,0 +1,96 @@
+////////////////////////////////////////////////////////////
+//
+// SFML - Simple and Fast Multimedia Library
+// Copyright (C) 2007 Laurent Gomila (laurent.gom@gmail.com)
+//
+// This software is provided 'as-is', without any express or implied warranty.
+// In no event will the authors be held liable for any damages arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it freely,
+// subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented;
+// you must not claim that you wrote the original software.
+// If you use this software in a product, an acknowledgment
+// in the product documentation would be appreciated but is not required.
+//
+// 2. Altered source versions must be plainly marked as such,
+// and must not be misrepresented as being the original software.
+//
+// 3. This notice may not be removed or altered from any source distribution.
+//
+////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////
+// Headers
+////////////////////////////////////////////////////////////
+#include <SFML/System/Randomizer.hpp>
+#include <SFML/System/Platform.hpp>
+#include <cstdlib>
+
+
+namespace
+{
+ // Set the random numbers sequence seed with the current system time, so that it is always different
+ unsigned int SetRandomSeed()
+ {
+ unsigned int Seed = static_cast<unsigned int>(sf::priv::Platform::GetSystemTime() * 1000);
+ srand(Seed);
+ return Seed;
+ }
+}
+
+
+namespace sf
+{
+////////////////////////////////////////////////////////////
+// Static member variables
+////////////////////////////////////////////////////////////
+unsigned int Randomizer::ourSeed = SetRandomSeed();
+
+
+////////////////////////////////////////////////////////////
+/// Set the seed for the generator. Using a known seed
+/// allows you to reproduce the same sequence of random number
+////////////////////////////////////////////////////////////
+void Randomizer::SetSeed(unsigned int Seed)
+{
+ srand(Seed);
+ ourSeed = Seed;
+}
+
+
+////////////////////////////////////////////////////////////
+/// Get the seed used to generate random numbers the generator.
+////////////////////////////////////////////////////////////
+unsigned int Randomizer::GetSeed()
+{
+ return ourSeed;
+}
+
+
+////////////////////////////////////////////////////////////
+/// Get a random float number in a given range
+////////////////////////////////////////////////////////////
+float Randomizer::Random(float Begin, float End)
+{
+ // This is not the best algorithm, but it is fast and will be enough in most cases
+ // (see Google for best approaches)
+
+ return static_cast<float>(rand()) / RAND_MAX * (End - Begin) + Begin;
+}
+
+
+////////////////////////////////////////////////////////////
+/// Get a random integer number in a given range
+////////////////////////////////////////////////////////////
+int Randomizer::Random(int Begin, int End)
+{
+ // This is not the best algorithm, but it is fast and will be enough in most cases
+ // (see Google for best approaches)
+
+ return rand() % (End - Begin + 1) + Begin;
+}
+
+} // namespace sf
diff --git a/src/SFML/System/Sleep.cpp b/src/SFML/System/Sleep.cpp
new file mode 100755
index 0000000..fd9f36d
--- /dev/null
+++ b/src/SFML/System/Sleep.cpp
@@ -0,0 +1,42 @@
+////////////////////////////////////////////////////////////
+//
+// SFML - Simple and Fast Multimedia Library
+// Copyright (C) 2007 Laurent Gomila (laurent.gom@gmail.com)
+//
+// This software is provided 'as-is', without any express or implied warranty.
+// In no event will the authors be held liable for any damages arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it freely,
+// subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented;
+// you must not claim that you wrote the original software.
+// If you use this software in a product, an acknowledgment
+// in the product documentation would be appreciated but is not required.
+//
+// 2. Altered source versions must be plainly marked as such,
+// and must not be misrepresented as being the original software.
+//
+// 3. This notice may not be removed or altered from any source distribution.
+//
+////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////
+// Headers
+////////////////////////////////////////////////////////////
+#include <SFML/System/Sleep.hpp>
+#include <SFML/System/Platform.hpp>
+
+
+namespace sf
+{
+////////////////////////////////////////////////////////////
+/// Make the current thread sleep for a given time
+////////////////////////////////////////////////////////////
+void Sleep(float Duration)
+{
+ priv::Platform::Sleep(Duration);
+}
+
+} // namespace sf
diff --git a/src/SFML/System/Unix/Mutex.cpp b/src/SFML/System/Unix/Mutex.cpp
new file mode 100755
index 0000000..9614361
--- /dev/null
+++ b/src/SFML/System/Unix/Mutex.cpp
@@ -0,0 +1,68 @@
+////////////////////////////////////////////////////////////
+//
+// SFML - Simple and Fast Multimedia Library
+// Copyright (C) 2007 Laurent Gomila (laurent.gom@gmail.com)
+//
+// This software is provided 'as-is', without any express or implied warranty.
+// In no event will the authors be held liable for any damages arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it freely,
+// subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented;
+// you must not claim that you wrote the original software.
+// If you use this software in a product, an acknowledgment
+// in the product documentation would be appreciated but is not required.
+//
+// 2. Altered source versions must be plainly marked as such,
+// and must not be misrepresented as being the original software.
+//
+// 3. This notice may not be removed or altered from any source distribution.
+//
+////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////
+// Headers
+////////////////////////////////////////////////////////////
+#include <SFML/System/Unix/Mutex.hpp>
+
+
+namespace sf
+{
+////////////////////////////////////////////////////////////
+/// Default constructor
+////////////////////////////////////////////////////////////
+Mutex::Mutex()
+{
+ pthread_mutex_init(&myMutex, NULL);
+}
+
+
+////////////////////////////////////////////////////////////
+/// Destructor
+////////////////////////////////////////////////////////////
+Mutex::~Mutex()
+{
+ pthread_mutex_destroy(&myMutex);
+}
+
+
+////////////////////////////////////////////////////////////
+/// Lock the mutex
+////////////////////////////////////////////////////////////
+void Mutex::Lock()
+{
+ pthread_mutex_lock(&myMutex);
+}
+
+
+////////////////////////////////////////////////////////////
+/// Unlock the mutex
+////////////////////////////////////////////////////////////
+void Mutex::Unlock()
+{
+ pthread_mutex_unlock(&myMutex);
+}
+
+} // namespace sf
diff --git a/src/SFML/System/Unix/Platform.cpp b/src/SFML/System/Unix/Platform.cpp
new file mode 100755
index 0000000..0149c36
--- /dev/null
+++ b/src/SFML/System/Unix/Platform.cpp
@@ -0,0 +1,58 @@
+////////////////////////////////////////////////////////////
+//
+// SFML - Simple and Fast Multimedia Library
+// Copyright (C) 2007 Laurent Gomila (laurent.gom@gmail.com)
+//
+// This software is provided 'as-is', without any express or implied warranty.
+// In no event will the authors be held liable for any damages arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it freely,
+// subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented;
+// you must not claim that you wrote the original software.
+// If you use this software in a product, an acknowledgment
+// in the product documentation would be appreciated but is not required.
+//
+// 2. Altered source versions must be plainly marked as such,
+// and must not be misrepresented as being the original software.
+//
+// 3. This notice may not be removed or altered from any source distribution.
+//
+////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////
+// Headers
+////////////////////////////////////////////////////////////
+#include <SFML/System/Unix/Platform.hpp>
+#include <unistd.h>
+#include <sys/time.h>
+
+namespace sf
+{
+namespace priv
+{
+////////////////////////////////////////////////////////////
+/// Get the current system time
+////////////////////////////////////////////////////////////
+double Platform::GetSystemTime()
+{
+ timeval Time = {0, 0};
+ gettimeofday(&Time, NULL);
+
+ return Time.tv_sec + Time.tv_usec / 1000000.;
+}
+
+
+////////////////////////////////////////////////////////////
+/// Suspend the execution of the current thread for a specified time
+////////////////////////////////////////////////////////////
+void Platform::Sleep(float Time)
+{
+ usleep(static_cast<unsigned long>(Time * 1000000));
+}
+
+} // namespace priv
+
+} // namespace sf
diff --git a/src/SFML/System/Unix/Platform.hpp b/src/SFML/System/Unix/Platform.hpp
new file mode 100755
index 0000000..0cd0990
--- /dev/null
+++ b/src/SFML/System/Unix/Platform.hpp
@@ -0,0 +1,69 @@
+////////////////////////////////////////////////////////////
+//
+// SFML - Simple and Fast Multimedia Library
+// Copyright (C) 2007 Laurent Gomila (laurent.gom@gmail.com)
+//
+// This software is provided 'as-is', without any express or implied warranty.
+// In no event will the authors be held liable for any damages arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it freely,
+// subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented;
+// you must not claim that you wrote the original software.
+// If you use this software in a product, an acknowledgment
+// in the product documentation would be appreciated but is not required.
+//
+// 2. Altered source versions must be plainly marked as such,
+// and must not be misrepresented as being the original software.
+//
+// 3. This notice may not be removed or altered from any source distribution.
+//
+////////////////////////////////////////////////////////////
+
+#ifndef SFML_PLATFORMUNIX_HPP
+#define SFML_PLATFORMUNIX_HPP
+
+////////////////////////////////////////////////////////////
+// Headers
+////////////////////////////////////////////////////////////
+#include <SFML/Config.hpp>
+#include <vector>
+
+
+namespace sf
+{
+namespace priv
+{
+////////////////////////////////////////////////////////////
+/// Unix implementation fo Platform
+/// Give access to various global system functions
+////////////////////////////////////////////////////////////
+class Platform
+{
+public :
+
+ ////////////////////////////////////////////////////////////
+ /// Get the current system time
+ ///
+ /// \return System time, in seconds
+ ///
+ ////////////////////////////////////////////////////////////
+ static double GetSystemTime();
+
+ ////////////////////////////////////////////////////////////
+ /// Suspend the execution of the current thread for a specified time
+ ///
+ /// \param Time : Time to sleep, in seconds
+ ///
+ ////////////////////////////////////////////////////////////
+ static void Sleep(float Time);
+};
+
+} // namespace priv
+
+} // namespace sf
+
+
+#endif // SFML_PLATFORMUNIX_HPP
diff --git a/src/SFML/System/Unix/Thread.cpp b/src/SFML/System/Unix/Thread.cpp
new file mode 100755
index 0000000..3268f61
--- /dev/null
+++ b/src/SFML/System/Unix/Thread.cpp
@@ -0,0 +1,146 @@
+////////////////////////////////////////////////////////////
+//
+// SFML - Simple and Fast Multimedia Library
+// Copyright (C) 2007 Laurent Gomila (laurent.gom@gmail.com)
+//
+// This software is provided 'as-is', without any express or implied warranty.
+// In no event will the authors be held liable for any damages arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it freely,
+// subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented;
+// you must not claim that you wrote the original software.
+// If you use this software in a product, an acknowledgment
+// in the product documentation would be appreciated but is not required.
+//
+// 2. Altered source versions must be plainly marked as such,
+// and must not be misrepresented as being the original software.
+//
+// 3. This notice may not be removed or altered from any source distribution.
+//
+////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////
+// Headers
+////////////////////////////////////////////////////////////
+#include <SFML/System/Unix/Thread.hpp>
+#include <iostream>
+
+
+namespace sf
+{
+////////////////////////////////////////////////////////////
+/// Default constructor
+////////////////////////////////////////////////////////////
+Thread::Thread() :
+myIsActive(false),
+myFunction(NULL),
+myUserData(NULL)
+{
+
+}
+
+
+////////////////////////////////////////////////////////////
+/// Construct the thread from a function pointer
+////////////////////////////////////////////////////////////
+Thread::Thread(Thread::FuncType Function, void* UserData) :
+myIsActive(false),
+myFunction(Function),
+myUserData(UserData)
+{
+
+}
+
+
+////////////////////////////////////////////////////////////
+/// Virtual destructor
+////////////////////////////////////////////////////////////
+Thread::~Thread()
+{
+ // Wait for the thread to finish before destroying the instance
+ if (myIsActive)
+ Wait();
+}
+
+
+////////////////////////////////////////////////////////////
+/// Create and run the thread
+////////////////////////////////////////////////////////////
+void Thread::Launch()
+{
+ // Create the thread
+ myIsActive = true;
+ int Error = pthread_create(&myThread, NULL, &Thread::ThreadFunc, this);
+
+ // Error ?
+ if (Error != 0)
+ {
+ std::cerr << "Failed to create thread" << std::endl;
+ myIsActive = false;
+ }
+}
+
+
+////////////////////////////////////////////////////////////
+/// Wait until the thread finishes
+////////////////////////////////////////////////////////////
+void Thread::Wait()
+{
+ if (myIsActive)
+ {
+ // Wait for the thread to finish, no timeout
+ pthread_join(myThread, NULL);
+
+ // Reset the thread state
+ myIsActive = false;
+ }
+}
+
+
+////////////////////////////////////////////////////////////
+/// Terminate the thread
+/// Terminating a thread with this function is not safe,
+/// you should rather try to make the thread function
+/// terminate by itself
+////////////////////////////////////////////////////////////
+void Thread::Terminate()
+{
+ if (myIsActive)
+ {
+ pthread_cancel(myThread);
+ myIsActive = false;
+ }
+}
+
+
+////////////////////////////////////////////////////////////
+/// Function called as the thread entry point
+////////////////////////////////////////////////////////////
+void Thread::Run()
+{
+ if (myFunction)
+ myFunction(myUserData);
+}
+
+
+////////////////////////////////////////////////////////////
+/// Actual thread entry point, dispatches to instances
+////////////////////////////////////////////////////////////
+void* Thread::ThreadFunc(void* UserData)
+{
+ // The sfThread instance is stored in the user data
+ Thread* ThreadToRun = reinterpret_cast<Thread*>(UserData);
+
+ // Tell the thread to handle cancel requests immediatly
+ pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL);
+
+ // Forward to the instance
+ ThreadToRun->Run();
+
+ return NULL;
+}
+
+} // namespace sf
diff --git a/src/SFML/System/Win32/Mutex.cpp b/src/SFML/System/Win32/Mutex.cpp
new file mode 100755
index 0000000..ab76f5e
--- /dev/null
+++ b/src/SFML/System/Win32/Mutex.cpp
@@ -0,0 +1,68 @@
+////////////////////////////////////////////////////////////
+//
+// SFML - Simple and Fast Multimedia Library
+// Copyright (C) 2007 Laurent Gomila (laurent.gom@gmail.com)
+//
+// This software is provided 'as-is', without any express or implied warranty.
+// In no event will the authors be held liable for any damages arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it freely,
+// subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented;
+// you must not claim that you wrote the original software.
+// If you use this software in a product, an acknowledgment
+// in the product documentation would be appreciated but is not required.
+//
+// 2. Altered source versions must be plainly marked as such,
+// and must not be misrepresented as being the original software.
+//
+// 3. This notice may not be removed or altered from any source distribution.
+//
+////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////
+// Headers
+////////////////////////////////////////////////////////////
+#include <SFML/System/Win32/Mutex.hpp>
+
+
+namespace sf
+{
+////////////////////////////////////////////////////////////
+/// Default constructor
+////////////////////////////////////////////////////////////
+Mutex::Mutex()
+{
+ InitializeCriticalSection(&myHandle);
+}
+
+
+////////////////////////////////////////////////////////////
+/// Destructor
+////////////////////////////////////////////////////////////
+Mutex::~Mutex()
+{
+ DeleteCriticalSection(&myHandle);
+}
+
+
+////////////////////////////////////////////////////////////
+/// Lock the mutex
+////////////////////////////////////////////////////////////
+void Mutex::Lock()
+{
+ EnterCriticalSection(&myHandle);
+}
+
+
+////////////////////////////////////////////////////////////
+/// Unlock the mutex
+////////////////////////////////////////////////////////////
+void Mutex::Unlock()
+{
+ LeaveCriticalSection(&myHandle);
+}
+
+} // namespace sf
diff --git a/src/SFML/System/Win32/Platform.cpp b/src/SFML/System/Win32/Platform.cpp
new file mode 100755
index 0000000..e05d788
--- /dev/null
+++ b/src/SFML/System/Win32/Platform.cpp
@@ -0,0 +1,70 @@
+////////////////////////////////////////////////////////////
+//
+// SFML - Simple and Fast Multimedia Library
+// Copyright (C) 2007 Laurent Gomila (laurent.gom@gmail.com)
+//
+// This software is provided 'as-is', without any express or implied warranty.
+// In no event will the authors be held liable for any damages arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it freely,
+// subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented;
+// you must not claim that you wrote the original software.
+// If you use this software in a product, an acknowledgment
+// in the product documentation would be appreciated but is not required.
+//
+// 2. Altered source versions must be plainly marked as such,
+// and must not be misrepresented as being the original software.
+//
+// 3. This notice may not be removed or altered from any source distribution.
+//
+////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////
+// Headers
+////////////////////////////////////////////////////////////
+#include <SFML/System/Win32/Platform.hpp>
+#include <windows.h>
+
+
+namespace sf
+{
+namespace priv
+{
+////////////////////////////////////////////////////////////
+/// Get the current system time
+////////////////////////////////////////////////////////////
+double Platform::GetSystemTime()
+{
+ static LARGE_INTEGER Frequency;
+ static BOOL UseHighPerformanceTimer = QueryPerformanceFrequency(&Frequency);
+
+ if (UseHighPerformanceTimer)
+ {
+ // High performance counter available : use it
+ LARGE_INTEGER CurrentTime;
+ QueryPerformanceCounter(&CurrentTime);
+
+ return static_cast<double>(CurrentTime.QuadPart) / Frequency.QuadPart;
+ }
+ else
+ {
+ // High performance counter not available : use GetTickCount (less accurate)
+ return GetTickCount() * 0.001;
+ }
+}
+
+
+////////////////////////////////////////////////////////////
+/// Suspend the execution of the current thread for a specified time
+////////////////////////////////////////////////////////////
+void Platform::Sleep(float Time)
+{
+ ::Sleep(static_cast<DWORD>(Time * 1000));
+}
+
+} // namespace priv
+
+} // namespace sf
diff --git a/src/SFML/System/Win32/Platform.hpp b/src/SFML/System/Win32/Platform.hpp
new file mode 100755
index 0000000..fb0b01e
--- /dev/null
+++ b/src/SFML/System/Win32/Platform.hpp
@@ -0,0 +1,69 @@
+////////////////////////////////////////////////////////////
+//
+// SFML - Simple and Fast Multimedia Library
+// Copyright (C) 2007 Laurent Gomila (laurent.gom@gmail.com)
+//
+// This software is provided 'as-is', without any express or implied warranty.
+// In no event will the authors be held liable for any damages arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it freely,
+// subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented;
+// you must not claim that you wrote the original software.
+// If you use this software in a product, an acknowledgment
+// in the product documentation would be appreciated but is not required.
+//
+// 2. Altered source versions must be plainly marked as such,
+// and must not be misrepresented as being the original software.
+//
+// 3. This notice may not be removed or altered from any source distribution.
+//
+////////////////////////////////////////////////////////////
+
+#ifndef SFML_PLATFORMWIN32_HPP
+#define SFML_PLATFORMWIN32_HPP
+
+////////////////////////////////////////////////////////////
+// Headers
+////////////////////////////////////////////////////////////
+#include <SFML/Config.hpp>
+#include <vector>
+
+
+namespace sf
+{
+namespace priv
+{
+////////////////////////////////////////////////////////////
+/// Win32 implementation fo Platform
+/// Give access to various global system functions
+////////////////////////////////////////////////////////////
+class Platform
+{
+public :
+
+ ////////////////////////////////////////////////////////////
+ /// Get the current system time
+ ///
+ /// \return System time, in seconds
+ ///
+ ////////////////////////////////////////////////////////////
+ static double GetSystemTime();
+
+ ////////////////////////////////////////////////////////////
+ /// Suspend the execution of the current thread for a specified time
+ ///
+ /// \param Time : Time to sleep, in seconds
+ ///
+ ////////////////////////////////////////////////////////////
+ static void Sleep(float Time);
+};
+
+} // namespace priv
+
+} // namespace sf
+
+
+#endif // SFML_PLATFORMWIN32_HPP
diff --git a/src/SFML/System/Win32/Thread.cpp b/src/SFML/System/Win32/Thread.cpp
new file mode 100755
index 0000000..d24857f
--- /dev/null
+++ b/src/SFML/System/Win32/Thread.cpp
@@ -0,0 +1,144 @@
+////////////////////////////////////////////////////////////
+//
+// SFML - Simple and Fast Multimedia Library
+// Copyright (C) 2007 Laurent Gomila (laurent.gom@gmail.com)
+//
+// This software is provided 'as-is', without any express or implied warranty.
+// In no event will the authors be held liable for any damages arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it freely,
+// subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented;
+// you must not claim that you wrote the original software.
+// If you use this software in a product, an acknowledgment
+// in the product documentation would be appreciated but is not required.
+//
+// 2. Altered source versions must be plainly marked as such,
+// and must not be misrepresented as being the original software.
+//
+// 3. This notice may not be removed or altered from any source distribution.
+//
+////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////
+// Headers
+////////////////////////////////////////////////////////////
+#include <SFML/System/Win32/Thread.hpp>
+#include <process.h>
+#include <iostream>
+
+
+namespace sf
+{
+////////////////////////////////////////////////////////////
+/// Default constructor
+////////////////////////////////////////////////////////////
+Thread::Thread() :
+myHandle (NULL),
+myFunction(NULL),
+myUserData(NULL)
+{
+
+}
+
+
+////////////////////////////////////////////////////////////
+/// Construct the thread from a function pointer
+////////////////////////////////////////////////////////////
+Thread::Thread(Thread::FuncType Function, void* UserData) :
+myHandle (NULL),
+myFunction(Function),
+myUserData(UserData)
+{
+
+}
+
+
+////////////////////////////////////////////////////////////
+/// Virtual destructor
+////////////////////////////////////////////////////////////
+Thread::~Thread()
+{
+ // Wait for the thread to finish before destroying the instance
+ if (myHandle)
+ Wait();
+}
+
+
+////////////////////////////////////////////////////////////
+/// Create and run the thread
+////////////////////////////////////////////////////////////
+void Thread::Launch()
+{
+ // Create the thread
+ myHandle = reinterpret_cast<HANDLE>(_beginthreadex(NULL, 0, &Thread::ThreadFunc, this, 0, NULL));
+
+ // Error ?
+ if (myHandle == NULL)
+ std::cerr << "Failed to create thread" << std::endl;
+}
+
+
+////////////////////////////////////////////////////////////
+/// Wait until the thread finishes
+////////////////////////////////////////////////////////////
+void Thread::Wait()
+{
+ if (myHandle)
+ {
+ // Wait for the thread to finish, no timeout
+ WaitForSingleObject(myHandle, INFINITE);
+
+ // Don't forget to close the thread handle (__endthreadex doesn't do it)
+ CloseHandle(myHandle);
+ myHandle = NULL;
+ }
+}
+
+
+////////////////////////////////////////////////////////////
+/// Terminate the thread
+/// Terminating a thread with this function is not safe,
+/// you should rather try to make the thread function
+/// terminate by itself
+////////////////////////////////////////////////////////////
+void Thread::Terminate()
+{
+ if (myHandle)
+ {
+ TerminateThread(myHandle, 0);
+ myHandle = NULL;
+ }
+}
+
+
+////////////////////////////////////////////////////////////
+/// Function called as the thread entry point
+////////////////////////////////////////////////////////////
+void Thread::Run()
+{
+ if (myFunction)
+ myFunction(myUserData);
+}
+
+
+////////////////////////////////////////////////////////////
+/// Actual thread entry point, dispatches to instances
+////////////////////////////////////////////////////////////
+unsigned int __stdcall Thread::ThreadFunc(void* UserData)
+{
+ // The sfThread instance is stored in the user data
+ Thread* ThreadInstance = reinterpret_cast<Thread*>(UserData);
+
+ // Forward to the instance
+ ThreadInstance->Run();
+
+ // Optional, but it is cleaner
+ _endthreadex(0);
+
+ return 0;
+}
+
+} // namespace sf