diff --git a/src/xpdev/genwrap.c b/src/xpdev/genwrap.c
index cfaceafd2b2ab2d09db267374108dffde5da1f02..818b54f59d8ed1db0c8010c7e00f6dcc58a8805b 100644
--- a/src/xpdev/genwrap.c
+++ b/src/xpdev/genwrap.c
@@ -334,3 +334,18 @@ char* DLLCALL asctime_r(const struct tm *tm, char *buf)
 }
 
 #endif	/* !defined(__unix__) */
+
+/********************************************/
+/* Hi-res real-time clock implementation.	*/
+/********************************************/
+#ifdef __unix__
+clock_t DLLCALL msclock(void)
+{
+	long long int usecs;
+	struct timeval tv;
+	if(gettimeofday(&tv,NULL)==1)
+		return(-1);
+	usecs=tv.tv_sec*1000000+tv.tv_usec;
+	return((clock_t)(usecs/(1000000/MSCLOCKS_PER_SEC)));
+}
+#endif
diff --git a/src/xpdev/genwrap.h b/src/xpdev/genwrap.h
index 6e29e2aa317bcc140133e7a0651cd5c9932fad55..7fbfed27ec60444e8b49aaeac35350a91b8a45bc 100644
--- a/src/xpdev/genwrap.h
+++ b/src/xpdev/genwrap.h
@@ -44,6 +44,7 @@
 
 #if defined(__unix__)
 	#include <sched.h>		/* sched_yield */
+	#include <time.h>	/* clock_t */
 	#include <sys/time.h>	/* struct timeval */
 	#include <strings.h>	/* strcasecmp() */
 	#include <unistd.h>		/* usleep */
@@ -268,6 +269,13 @@ DLLEXPORT int		DLLCALL	xp_random(int);
 DLLEXPORT char*		DLLCALL os_version(char *str);
 DLLEXPORT char*		DLLCALL	lastchar(const char* str);
 DLLEXPORT int		DLLCALL safe_snprintf(char *dst, size_t size, char *fmt, ...);
+
+#if defined(_WIN32)
+#define		msclock()	clock()
+#else
+#define		MSCLOCKS_PER_SEC	1000
+clock_t		msclock(void);
+#endif
 #if defined(__cplusplus)
 }
 #endif
diff --git a/src/xpdev/wraptest.c b/src/xpdev/wraptest.c
index 80b6d0df1dd8706ccda3bfe9b5835625b1cb19c1..ec9a49545eb44348296ae0730246faede3b987e2 100644
--- a/src/xpdev/wraptest.c
+++ b/src/xpdev/wraptest.c
@@ -49,6 +49,7 @@ int main()
 	int	fd;
 	int	fd2;
 	int	canrelock=0;
+	clock_t	ticks;
 
 	/* Show platform details */
 	DESCRIBE_COMPILER(compiler);
@@ -171,8 +172,9 @@ int main()
 	t=time(NULL);
 	printf("sleeping... ");
 	fflush(stdout);
+	ticks=msclock();
 	SLEEP(5000);
-	printf("slept %ld seconds\n",time(NULL)-t);
+	printf("slept %ld seconds (%ld according to msclock)\n",time(NULL)-t,(msclock()-ticks)/MSCLOCKS_PER_SEC);
 
 	/* Thread SLEEP test */
 	printf("\nThread SLEEP(5 second) test\n");