commit: 5d644124be85b7449c992cce7f3ea67eae5ade15
parent dd9801d7c154beeca3be1f265ed4fae1192215fc
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date: Mon, 8 Jul 2024 16:34:30 +0200
configure: Add test for getentropy
Diffstat:
2 files changed, 31 insertions(+), 0 deletions(-)
diff --git a/configure b/configure
@@ -231,6 +231,11 @@ if check_conftest configure.d/posix_2024.h; then
CFLAGS="${CFLAGS} -DHAS_POSIX_2024"
fi
+if ! check_conftest configure.d/getentropy.c; then
+ echo 'Disabling cmd/mktemp'
+ target_filter="${target_filter} -e cmd/mktemp."
+fi
+
echo
## Configuration write
diff --git a/configure.d/getentropy.c b/configure.d/getentropy.c
@@ -0,0 +1,26 @@
+// utils-std: Collection of commonly available Unix tools
+// SPDX-FileCopyrightText: 2017 Haelwenn (lanodan) Monnier <contact+utils@hacktivis.me>
+// SPDX-License-Identifier: MPL-2.0
+
+#define _POSIX_C_SOURCE 202405L
+
+#ifndef HAS_POSIX_2024
+#define _DEFAULT_SOURCE // getentropy
+#endif
+
+#include <unistd.h> // getentropy
+
+int
+main(int argc, char *argv[])
+{
+ // Silence unused warnings
+ (void)argc;
+ (void)argv;
+
+#define BUFLEN 42
+ size_t buflen = BUFLEN;
+ char buf[BUFLEN] = "";
+ int res = getentropy(buf, buflen);
+
+ return res;
+}