diff --git a/src/xpdev/genwrap.c b/src/xpdev/genwrap.c
index b0f0eade7ae0c0707d9a7a5b5215e6cddf04679b..3b1d9b5b881cfe7d8c52f8d339cd544176e7a7e6 100644
--- a/src/xpdev/genwrap.c
+++ b/src/xpdev/genwrap.c
@@ -36,6 +36,14 @@
  ****************************************************************************/
 
 #include <string.h>     /* strlen() */
+#include <stdlib.h>	/* RAND_MAX */
+#include <fcntl.h>	/* O_NOCTTY */
+#ifndef __FreeBSD__
+#include <sys/kd.h>	/* KIOCSOUND */
+#endif
+#ifdef __FreeBSD__
+#include <sys/kbio.h>
+#endif
 
 #include "genwrap.h"	/* Verify prototypes */
 
@@ -94,7 +102,7 @@ void DLLCALL unix_beep(int freq, int dur)
 	
 	if(console_fd != -1) {
 		ioctl(console_fd, KIOCSOUND, (int) (1193180 / freq));
-		mswait(dur);
+		SLEEP(dur);
 		ioctl(console_fd, KIOCSOUND, 0);	/* turn off tone */
 	}
 }