$NetBSD$ * Part of patchset to build electron on NetBSD * Based on OpenBSD's chromium patches, and FreeBSD's electron patches --- third_party/ipcz/src/reference_drivers/random.cc.orig 2025-02-24 19:59:26.000000000 +0000 +++ third_party/ipcz/src/reference_drivers/random.cc @@ -14,7 +14,8 @@ #include #elif BUILDFLAG(IS_FUCHSIA) #include -#elif BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_ANDROID) +#elif (BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_BSD)) && \ + !BUILDFLAG(IS_NETBSD) #include #include #include @@ -25,7 +26,7 @@ #include #endif -#if BUILDFLAG(IS_POSIX) +#if BUILDFLAG(IS_POSIX) || BUILDFLAG(IS_NETBSD) #include #include #include @@ -55,7 +56,7 @@ decltype(&ProcessPrng) GetProcessPrng() } #endif -#if defined(OS_POSIX) && !BUILDFLAG(IS_MAC) +#if (defined(OS_POSIX) && !BUILDFLAG(IS_MAC)) || BUILDFLAG(IS_NETBSD) void RandomBytesFromDevUrandom(absl::Span destination) { static int urandom_fd = [] { for (;;) { @@ -86,7 +87,8 @@ void RandomBytes(absl::Span des process_prng_fn(destination.data(), destination.size()); #elif BUILDFLAG(IS_FUCHSIA) zx_cprng_draw(destination.data(), destination.size()); -#elif BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_ANDROID) +#elif (BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_BSD)) && \ + !BUILDFLAG(IS_NETBSD) while (!destination.empty()) { ssize_t result = syscall(__NR_getrandom, destination.data(), destination.size(), 0); @@ -102,7 +104,7 @@ void RandomBytes(absl::Span des #elif BUILDFLAG(IS_MAC) const bool ok = getentropy(destination.data(), destination.size()) == 0; ABSL_ASSERT(ok); -#elif BUILDFLAG(IS_IOS) +#elif BUILDFLAG(IS_IOS) || BUILDFLAG(IS_NETBSD) RandomBytesFromDevUrandom(destination); #elif BUILDFLAG(IS_NACL) while (!destination.empty()) {