From f8a575feb053bb180c82c2cd73f5fadf11bd97b5 Mon Sep 17 00:00:00 2001 From: Andrew Hopkins Date: Tue, 30 Apr 2024 10:46:27 -0700 Subject: [PATCH] Migrate from __FreeBSD__ to __FreeBSD_version (#1562) ### Issues: Resolves https://github.com/aws/aws-lc/issues/1557 ### Description of changes: [`__FreeBSD__`](https://docs.freebsd.org/en/books/porters-handbook/porting-dads/#porting-versions) doesn't seem to be as well supported (or as accurate) as `__FreeBSD_version`. This change migrates to [`__FreeBSD_version`](https://docs.freebsd.org/en/books/porters-handbook/versions/#versions) which appears to be the recommended way to check for versions. ### Call-outs: `__FreeBSD_version` is defined in [`sys/param.h`](https://cgit.freebsd.org/src/tree/sys/sys/param.h#n76) ### Testing: We don't have FreeBSD in our CI, a similar but not exactly the same change was tested by the requester in https://github.com/aws/aws-lc/issues/1557. By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license and the ISC license. --- crypto/fipsmodule/rand/urandom.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/crypto/fipsmodule/rand/urandom.c b/crypto/fipsmodule/rand/urandom.c index fcc3dc09ef..a85d3fe8ed 100644 --- a/crypto/fipsmodule/rand/urandom.c +++ b/crypto/fipsmodule/rand/urandom.c @@ -71,7 +71,8 @@ #if defined(OPENSSL_FREEBSD) #define URANDOM_BLOCKS_FOR_ENTROPY -#if __FreeBSD__ >= 12 +#include +#if __FreeBSD_version >= 1200000 // getrandom is supported in FreeBSD 12 and up. #define FREEBSD_GETRANDOM #include