compat UPDATE define crypt_r
diff --git a/compat/compat.c b/compat/compat.c
index d0495b2..88a3b69 100644
--- a/compat/compat.c
+++ b/compat/compat.c
@@ -16,6 +16,7 @@
 
 #include "compat.h"
 
+#include <crypt.h>
 #include <errno.h>
 #include <inttypes.h>
 #include <limits.h>
@@ -372,3 +373,21 @@
 }
 
 #endif
+
+#ifndef HAVE_CRYPT_R
+char *
+crypt_r(const char *phrase, const char *setting, struct crypt_data *data)
+{
+    static pthread_mutex_t crypt_lock = PTHREAD_MUTEX_INITIALIZER;
+    char *hash;
+
+    (void) data;
+
+    pthread_mutex_lock(&crypt_lock);
+    hash = crypt(phrase, setting);
+    pthread_mutex_unlock(&crypt_lock);
+
+    return hash;
+}
+
+#endif