The branch master has been updated
       via  4cd58771d8387c6bfbd0fd9936aaeb3ba63a6fe6 (commit)
      from  fd87700995a65d54e78630f1f8f960e258a7977a (commit)


- Log -----------------------------------------------------------------
commit 4cd58771d8387c6bfbd0fd9936aaeb3ba63a6fe6
Author: Pauli <paul.d...@oracle.com>
Date:   Thu Feb 8 11:04:30 2018 +1000

    Fix glibc version detection.
    Simplify Posix timer detection.
    
    Reviewed-by: Richard Levitte <levi...@openssl.org>
    (Merged from https://github.com/openssl/openssl/pull/5279)

-----------------------------------------------------------------------

Summary of changes:
 crypto/rand/rand_lib.c | 39 ++++++++++++++++++++++++++++++++++-----
 1 file changed, 34 insertions(+), 5 deletions(-)

diff --git a/crypto/rand/rand_lib.c b/crypto/rand/rand_lib.c
index 69c3c79..faec18d 100644
--- a/crypto/rand/rand_lib.c
+++ b/crypto/rand/rand_lib.c
@@ -25,6 +25,39 @@
 /* Macro to convert two thirty two bit values into a sixty four bit one */
 #define TWO32TO64(a, b) ((((uint64_t)(a)) << 32) + (b))
 
+/*
+ * Check for the existence and support of POSIX timers.  The standard
+ * says that the _POSIX_TIMERS macro will have a positive value if they
+ * are available.
+ *
+ * However, we want an additional constraint: that the timer support does
+ * not require an extra library dependency.  Early versions of glibc
+ * require -lrt to be specified on the link line to access the timers,
+ * so this needs to be checked for.
+ *
+ * It is worse because some libraries define __GLIBC__ but don't
+ * support the version testing macro (e.g. uClibc).  This means
+ * an extra check is needed.
+ *
+ * The final condition is:
+ *      "have posix timers and either not glibc or glibc without -lrt"
+ *
+ * The nested #if sequences are required to avoid using a parameterised
+ * macro that might be undefined.
+ */
+#undef OSSL_POSIX_TIMER_OKAY
+#if defined(_POSIX_TIMERS) && _POSIX_TIMERS > 0
+# if defined(__GLIBC__)
+#  if defined(__GLIBC_PREREQ)
+#   if __GLIBC_PREREQ(2, 17)
+#    define OSSL_POSIX_TIMER_OKAY
+#   endif
+#  endif
+# else
+#  define OSSL_POSIX_TIMER_OKAY
+# endif
+#endif
+
 #ifndef OPENSSL_NO_ENGINE
 /* non-NULL if default_RAND_meth is ENGINE-provided */
 static ENGINE *funct_ref;
@@ -228,11 +261,7 @@ static uint64_t get_timer_bits(void)
     }
 #else
 
-# if defined(_POSIX_C_SOURCE) \
-     && defined(_POSIX_TIMERS) \
-     && _POSIX_C_SOURCE >= 199309L \
-     && (!defined(__GLIBC__) \
-         || (defined(__GLIBC_PREREQ) && __GLIBC_PREREQ(2, 17)))
+#if defined(OSSL_POSIX_TIMER_OKAY)
     {
         struct timespec ts;
         clockid_t cid;
_____
openssl-commits mailing list
To unsubscribe: https://mta.openssl.org/mailman/listinfo/openssl-commits

Reply via email to