From 4698adf68f4ad04621e0e1447048d59eaa4aa2a8 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Mon, 29 Oct 2018 19:14:14 +0100 Subject: [PATCH] MINOR: compat: automatically detect support for crypt_r() glibc >= 2.2 and FreeBSD >= 12.0 support crypt_r(), let's detect this and set a macro HA_HAVE_CRYPT_R for this. --- include/common/compat.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/include/common/compat.h b/include/common/compat.h index 59bc6c7e9f..8a7bbd5bf3 100644 --- a/include/common/compat.h +++ b/include/common/compat.h @@ -152,6 +152,16 @@ #include #endif +/* crypt_r() has been present in glibc since 2.2 and on FreeBSD since 12.0 + * (12000002). No other OS makes any mention of it for now. Feel free to add + * valid known combinations below if needed to relax the crypt() lock when + * using threads. + */ +#if (defined(__GNU_LIBRARY__) && (__GLIBC__ > 2 || __GLIBC__ == 2 && __GLIBC_MINOR__ >= 2)) \ + || (defined(__FreeBSD__) && __FreeBSD_version >= 1200002) +#define HA_HAVE_CRYPT_R +#endif + #endif /* _COMMON_COMPAT_H */ /*