diff --git configure.ac configure.ac
index 10aff04..07e149f 100644
--- configure.ac
+++ configure.ac
@@ -456,6 +456,7 @@ AC_CHECK_FUNCS([ \
 	issetugid \
 	memmove \
 	reallocarray \
+	res_randomid \
 	snprintf \
 	strdup \
 	strerror \
diff --git src/asr_private.h src/asr_private.h
index 0960e37..158e7ff 100644
--- src/asr_private.h
+++ src/asr_private.h
@@ -365,3 +365,7 @@ extern FILE * asr_debug;
 		asr_statestr((a)->as_state),	\
 		asr_statestr((s)));		\
 	(a)->as_state = (s); } while (0)
+
+#ifndef HAVE_RES_RANDOMID
+#define res_randomid(x) (0xffff & getpid())
+#endif
