diff --git a/src/xpdev/genwrap.c b/src/xpdev/genwrap.c
index 2f61ca59d5d9214fac9718e943d4d4f4735278f0..560eb71c0adb462ab4d1aa56de9d5916f95707a6 100644
--- a/src/xpdev/genwrap.c
+++ b/src/xpdev/genwrap.c
@@ -49,6 +49,7 @@
 #endif	/* __unix__ */
 
 #include "genwrap.h"	/* Verify prototypes */
+#include "xpendian.h"	/* BYTE_SWAP */
 
 /****************************************************************************/
 /* Used to replace snprintf()  guarantees to terminate.			  			*/
@@ -230,6 +231,28 @@ char* strrev(char* str)
 }
 #endif
 
+/****************************************************************************/
+/* Initialize (seed) the random number generator							*/
+/****************************************************************************/
+unsigned DLLCALL xp_randomize(void)
+{
+	unsigned thread_id = (unsigned)GetCurrentThreadId();
+	unsigned process_id = (unsigned)GetCurrentProcessId();
+	unsigned seed = time(NULL) ^ BYTE_SWAP_INT(thread_id) ^ process_id;
+
+#if defined(HAS_DEV_RANDOM) && defined(RANDOM_DEV)
+	int     rf;
+
+	if((rf=open(RANDOM_DEV, O_RDONLY))!=-1) {
+		read(rf, &seed, sizeof(seed));
+		close(rf);
+	}
+#endif
+
+ 	srand(seed);
+	return(seed);
+}
+
 /****************************************************************************/
 /* Return random number between 0 and n-1									*/
 /****************************************************************************/
@@ -380,9 +403,9 @@ char* DLLCALL asctime_r(const struct tm *tm, char *buf)
 
 #endif	/* !defined(__unix__) */
 
-/********************************************/
-/* Hi-res real-time clock implementation.	*/
-/********************************************/
+/****************************************************************/
+/* Microsoft (DOS/Win32) real-time system clock implementation.	*/
+/****************************************************************/
 #ifdef __unix__
 clock_t DLLCALL msclock(void)
 {