diff -ur a/xdm/genauth.c b/xdm/genauth.c
--- a/xdm/genauth.c	2011-09-25 09:35:47.000000000 +0200
+++ b/xdm/genauth.c	2014-01-06 16:28:09.664060603 +0100
@@ -40,6 +40,14 @@
 
 #include <errno.h>
 
+#ifdef HAVE_ARC4RANDOM
+# ifdef __linux__
+#  include <bsd/stdlib.h>
+# else
+#  include <stdlib.h>
+# endif
+#endif
+
 #include <time.h>
 #define Time_t time_t
 
