diff --git a/libmaxsi/Makefile b/libmaxsi/Makefile
index 48ff24e6..f67ebecf 100644
--- a/libmaxsi/Makefile
+++ b/libmaxsi/Makefile
@@ -165,7 +165,7 @@ open.o \
pipe.o \
print.o \
putc.o \
-random.o \
+rand.o \
readdirents.o \
read.o \
rmdir.o \
diff --git a/libmaxsi/random.cpp b/libmaxsi/rand.cpp
similarity index 57%
rename from libmaxsi/random.cpp
rename to libmaxsi/rand.cpp
index 056ab350..2b59ce7e 100644
--- a/libmaxsi/random.cpp
+++ b/libmaxsi/rand.cpp
@@ -1,6 +1,6 @@
/*******************************************************************************
- COPYRIGHT(C) JONAS 'SORTIE' TERMANSEN 2011, 2012.
+ Copyright(C) Jonas 'Sortie' Termansen 2011, 2012.
This file is part of LibMaxsi.
@@ -17,36 +17,38 @@
You should have received a copy of the GNU Lesser General Public License
along with LibMaxsi. If not, see .
- random.cpp
- Provides access to random numbers using various algorithms.
+ rand.cpp
+ Returns a random value.
*******************************************************************************/
-namespace Maxsi
-{
- namespace Random
- {
+#include
+
#if 1
- unsigned int m_w = 1337;
- unsigned int m_z = 37;
- unsigned int RandomUnsignedInt()
- {
- m_z = 36969 * (m_z & 65535) + (m_z >> 16);
- m_w = 18000 * (m_w & 65535) + (m_w >> 16);
- return (m_z << 16) + m_w; /* 32-bit result */
- }
- extern "C" int rand()
- {
- return RandomUnsignedInt() % 32768;
- }
-#else
- unsigned random_seed = 1337;
- extern "C" int rand()
- {
- random_seed = random_seed + 37 * 1103515245 + 12345;
- return random_seed >> 16;
- }
-#endif
- }
+
+static unsigned int m_w = 1337;
+static unsigned int m_z = 37;
+
+static unsigned int RandomUnsignedInt()
+{
+ m_z = 36969 * (m_z & 65535) + (m_z >> 16);
+ m_w = 18000 * (m_w & 65535) + (m_w >> 16);
+ return (m_z << 16) + m_w; /* 32-bit result */
}
+extern "C" int rand()
+{
+ return RandomUnsignedInt() % 32768;
+}
+
+#else
+
+static unsigned random_seed = 1337;
+
+extern "C" int rand()
+{
+ random_seed = random_seed + 37 * 1103515245 + 12345;
+ return random_seed >> 16;
+}
+
+#endif