Fix compilation on systems with empty _POSIX_TIMERS
authorLarkin Nickle <me@larbob.org>
Wed, 2 Jun 2021 18:17:40 +0000 (14:17 -0400)
committerPauli <pauli@openssl.org>
Tue, 8 Jun 2021 11:05:21 +0000 (21:05 +1000)
Systems such as Tru64 ship with broken headers that
have _POSIX_TIMERS defined but empty.

CLA: trivial

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15598)

providers/implementations/rands/seeding/rand_unix.c

index f77f6e0324aab2a3ae434f98df0ae2af2e32fa60..2e6429344c75e74eb8fd8f8738ad086e12e1f734 100644 (file)
@@ -76,7 +76,9 @@ static uint64_t get_timer_bits(void);
  * macro that might be undefined.
  */
 # undef OSSL_POSIX_TIMER_OKAY
-# if defined(_POSIX_TIMERS) && _POSIX_TIMERS > 0
+/* On some systems, _POSIX_TIMERS is defined but empty.
+ * Subtracting by 0 when comparing avoids an error in this case. */
+# if defined(_POSIX_TIMERS) && _POSIX_TIMERS -0 > 0
 #  if defined(__GLIBC__)
 #   if defined(__GLIBC_PREREQ)
 #    if __GLIBC_PREREQ(2, 17)