+ union {
+ void *p;
+ int (*f)(void *buffer, size_t length);
+ } p_getentropy;
+
+ /*
+ * Do runtime detection to find getentropy().
+ *
+ * We could cache the result of the lookup, but we normally don't
+ * call this function often.
+ *
+ * Known OSs that should support this:
+ * - Darwin since 16 (OSX 10.12, IOS 10.0).
+ * - Solaris since 11.3
+ * - OpenBSD since 5.6
+ * - Linux since 3.17 with glibc 2.25
+ * - FreeBSD since 12.0 (1200061)
+ */
+ p_getentropy.p = DSO_global_lookup("getentropy");
+ if (p_getentropy.p != NULL)
+ return p_getentropy.f(buf, buflen);
+