From 29c173399dda487df9077d15262c62624e745097 Mon Sep 17 00:00:00 2001
From: rswindell <>
Date: Sat, 15 Oct 2005 01:59:50 +0000
Subject: [PATCH] no message

---
 src/xpdev/genwrap.c | 29 ++++++++++++++++++++++++++---
 1 file changed, 26 insertions(+), 3 deletions(-)

diff --git a/src/xpdev/genwrap.c b/src/xpdev/genwrap.c
index 2f61ca59d5..560eb71c0a 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)
 {
-- 
GitLab